Should work up to 8
The reason is this loop
void before() {
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
and
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Register all sensors to gw (they will be created as child devices)
present(sensor, S_LIGHT);
}
Defines sensors with pin assignments from RELAY_1=4 to 20 - that is, consecutive. You use pins 4 to 11 and a second pool from 22 to 29.
This software design enforces continuity of pin numbering.
Maybe in a loop you would need to correct the pin when if(pin==12 ){ pin=22}
The second place is:
// Change relay state
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
.. also has a trickle of numbering continuity and needs to be corrected.
Added after 1 [hour] 1 [minute]: .
Suggested changes, these are just snippets - you need to tweak in your own program. A lot of it and I didn't want to tweak it.
I haven't tested it, but it should work.
grzegorz.d3 wrote:
.