logo elektroda
logo elektroda
X
logo elektroda

Domoticz control code with Arduino - inactive after 6 attempts. Corrections?

grzegorz.d3 399 1
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19596933
    grzegorz.d3
    Level 14  
    Hello I have a problem with the code downloaded from the internet to control the Dormowicz with arduino only works up to 6 the rest not .
    What needs to be corrected in this code.
    I am just starting to play with this Domoticz and writing programs in arduino.
    Code: C / C++
    Log in, to see the code
    .
    Do you have a problem with Arduino? Ask question. Visit our forum Arduino.
  • ADVERTISEMENT
  • #2 19597181
    starob
    Level 29  
    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:
    .
    Code: C / C++
    Log in, to see the code
    .
ADVERTISEMENT