Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. Multi Button Relay switch

Multi Button Relay switch

Scheduled Pinned Locked Moved Hardware
43 Posts 13 Posters 25.5k Views 8 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • AWIA AWI

    @jeylites I took a deeper look at your sketch and think I found the cause. You are writing and reading from different EEPROM locations. The "standard" way is to use the "Sensor number" as location reference. Whereas the sketch also used "relayPin[i]" to store values. I took the liberty of adapting your sketch as I found it hard to read. Also added storing the value in EEPROM after pushing a button.
    I have not build the circuit so were not able to test it in real life :) Have fun and let me know if it worked for you.

    https://codebender.cc/sketch:92964

    jeylitesJ Offline
    jeylitesJ Offline
    jeylites
    wrote on last edited by jeylites
    #25

    @AWI Thank you so much. This is awesome! I bet so many people is going to benefit from this script.

    I had some time off today and ran the script. It didn't work the fist time, but I made some minor changes to "Relay_ON & Relay_OFF and also activated " Start State of Relays" and it worked. I'm guessing it didn't the first time because my relays are Active Low.

    Also, while toying around with it, I realize that it doesn't send back the status of the relay & actuator to the Controller (Homeseer). On Homeseer, suppose you have it at “ON” there is a maker that indicates its state and vice versa. I noticed that worked on Binary Switch & Motion Sensor but not on Relay & Relay Button Actuator sketch. Don't know if it's a script or Homeseer issue though.

    Again, thanks, everyone who helped pointing out the problem. I'm new to My Sensor and I'm glad to be here and making progress.

    #define RELAY_ON 0 //switch around for relay HIGH/LOW state
    #define RELAY_OFF 1

    pinMode(Relays[i].relayPin, OUTPUT);

    jeylitesJ 1 Reply Last reply
    0
    • jeylitesJ jeylites

      @AWI Thank you so much. This is awesome! I bet so many people is going to benefit from this script.

      I had some time off today and ran the script. It didn't work the fist time, but I made some minor changes to "Relay_ON & Relay_OFF and also activated " Start State of Relays" and it worked. I'm guessing it didn't the first time because my relays are Active Low.

      Also, while toying around with it, I realize that it doesn't send back the status of the relay & actuator to the Controller (Homeseer). On Homeseer, suppose you have it at “ON” there is a maker that indicates its state and vice versa. I noticed that worked on Binary Switch & Motion Sensor but not on Relay & Relay Button Actuator sketch. Don't know if it's a script or Homeseer issue though.

      Again, thanks, everyone who helped pointing out the problem. I'm new to My Sensor and I'm glad to be here and making progress.

      #define RELAY_ON 0 //switch around for relay HIGH/LOW state
      #define RELAY_OFF 1

      pinMode(Relays[i].relayPin, OUTPUT);

      jeylitesJ Offline
      jeylitesJ Offline
      jeylites
      wrote on last edited by jeylites
      #26

      @AWI I just realize another thing. The is a long delay for the sensor to sends its presentation during inclusion mode. Is there something to do with the number of sensors in one node or sketch? Essentially, I would have to reset the sensor several times to get it discovered.
      It's pretty quick on a single or double sensor node.

      AWIA 1 Reply Last reply
      0
      • jeylitesJ jeylites

        @AWI I just realize another thing. The is a long delay for the sensor to sends its presentation during inclusion mode. Is there something to do with the number of sensors in one node or sketch? Essentially, I would have to reset the sensor several times to get it discovered.
        It's pretty quick on a single or double sensor node.

        AWIA Offline
        AWIA Offline
        AWI
        Hero Member
        wrote on last edited by
        #27

        @jeylites I don't have experience with Homeseer as controller.and don't fully understand your questions, so just give it a shot..

        The multi relay sketch is firing a large amount of messages to the gateway/ controller during presentation. If you have transmission problems and/or a slow controller it could get into trouble. I suggest you monitor on the serial port of the sensor if there are "fail" messages. (need to turn on DEBUG = default) If there are it could be a power problem or...

        The real fun (and headache) is in the debugging :) The serial monitor can give you lost of clues

        Depending on how long is "long". there are also 250 ms delays between the individual presentations of the relays. ..'
        have fun ;)

        jeylitesJ 1 Reply Last reply
        0
        • AWIA AWI

          @jeylites I don't have experience with Homeseer as controller.and don't fully understand your questions, so just give it a shot..

          The multi relay sketch is firing a large amount of messages to the gateway/ controller during presentation. If you have transmission problems and/or a slow controller it could get into trouble. I suggest you monitor on the serial port of the sensor if there are "fail" messages. (need to turn on DEBUG = default) If there are it could be a power problem or...

          The real fun (and headache) is in the debugging :) The serial monitor can give you lost of clues

          Depending on how long is "long". there are also 250 ms delays between the individual presentations of the relays. ..'
          have fun ;)

          jeylitesJ Offline
          jeylitesJ Offline
          jeylites
          wrote on last edited by
          #28

          @AWI

          I think you're right on the controller. I've been getting some glitch running HS3 on Mac. I don't know if its a plugin or software issue, but I will like to get to the bottom of it. In addition, a buddy of mine is loaning his Vera edge so I might run some test on that too.

          Meanwhile, will take your advice on serial monitor and will let you know the outcome. Cheers!

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            quocanhcgd
            wrote on last edited by
            #29

            Thanks for sharing.
            I have a problem with this scripts. My relay auto start then off every gateway check node. How can i fix it?
            Thanks

            1 Reply Last reply
            0
            • jeylitesJ Offline
              jeylitesJ Offline
              jeylites
              wrote on last edited by
              #30

              @quocanhcgd

              You will need to activate this line pinMode(Relays[i].relayPin, OUTPUT);

              It should work right after.

              Q 1 Reply Last reply
              0
              • jeylitesJ jeylites

                @quocanhcgd

                You will need to activate this line pinMode(Relays[i].relayPin, OUTPUT);

                It should work right after.

                Q Offline
                Q Offline
                quocanhcgd
                wrote on last edited by
                #31

                I activated this line but no result. may be openhab work wrong? What the controller you use?
                @jeylites said:

                @quocanhcgd

                You will need to activate this line pinMode(Relays[i].relayPin, OUTPUT);

                It should work right after.

                jeylitesJ 1 Reply Last reply
                0
                • Q quocanhcgd

                  I activated this line but no result. may be openhab work wrong? What the controller you use?
                  @jeylites said:

                  @quocanhcgd

                  You will need to activate this line pinMode(Relays[i].relayPin, OUTPUT);

                  It should work right after.

                  jeylitesJ Offline
                  jeylitesJ Offline
                  jeylites
                  wrote on last edited by
                  #32

                  @quocanhcgd Homeseer

                  jeylitesJ 1 Reply Last reply
                  0
                  • jeylitesJ jeylites

                    @quocanhcgd Homeseer

                    jeylitesJ Offline
                    jeylitesJ Offline
                    jeylites
                    wrote on last edited by jeylites
                    #33

                    @quocanhcgd

                    I have tested the sketch on vera Ui7 & Homeseer but I don't know why it takes a very long time for the sketch to send individual presentations of the relay to the controller. Sometimes it doesn't send it at all. I have changed power supply as @AWI suggested and the relays are not connected to the Arduino at this time. Still nothing. Anyone here knows what the fail messages are. Below is the serial messages I got....

                    repeater started, id 2
                    send: 2-2-0-0 s=255,c=0,t=18,pt=0,l=5,st=fail:1.4.1
                    send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0
                    send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=16,st=ok:MultiRelayButton
                    send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=4,st=ok:0.9b
                    send: 2-2-0-0 s=0,c=1,t=2,pt=2,l=2,st=fail:1
                    send: 2-2-0-0 s=0,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                    send: 2-2-0-0 s=1,c=1,t=2,pt=2,l=2,st=fail:1
                    send: 2-2-0-0 s=1,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                    send: 2-2-0-0 s=2,c=1,t=2,pt=2,l=2,st=fail:1
                    send: 2-2-0-0 s=2,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                    send: 2-2-0-0 s=3,c=1,t=2,pt=2,l=2,st=fail:0
                    send: 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
                    send: 2-2-0-0 s=3,c=0,t=3,pt=0,l=5,st=fail:1.4.1

                    AWIA 1 Reply Last reply
                    0
                    • jeylitesJ jeylites

                      @quocanhcgd

                      I have tested the sketch on vera Ui7 & Homeseer but I don't know why it takes a very long time for the sketch to send individual presentations of the relay to the controller. Sometimes it doesn't send it at all. I have changed power supply as @AWI suggested and the relays are not connected to the Arduino at this time. Still nothing. Anyone here knows what the fail messages are. Below is the serial messages I got....

                      repeater started, id 2
                      send: 2-2-0-0 s=255,c=0,t=18,pt=0,l=5,st=fail:1.4.1
                      send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0
                      send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=16,st=ok:MultiRelayButton
                      send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=4,st=ok:0.9b
                      send: 2-2-0-0 s=0,c=1,t=2,pt=2,l=2,st=fail:1
                      send: 2-2-0-0 s=0,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                      send: 2-2-0-0 s=1,c=1,t=2,pt=2,l=2,st=fail:1
                      send: 2-2-0-0 s=1,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                      send: 2-2-0-0 s=2,c=1,t=2,pt=2,l=2,st=fail:1
                      send: 2-2-0-0 s=2,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                      send: 2-2-0-0 s=3,c=1,t=2,pt=2,l=2,st=fail:0
                      send: 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
                      send: 2-2-0-0 s=3,c=0,t=3,pt=0,l=5,st=fail:1.4.1

                      AWIA Offline
                      AWIA Offline
                      AWI
                      Hero Member
                      wrote on last edited by
                      #34

                      @jeylites I would suggest you take a closer look at the hardware. Almost all messages are failing and in most cases radio reception is the cause. Have you used capacitors on the radio's?

                      jeylitesJ 1 Reply Last reply
                      0
                      • AWIA AWI

                        @jeylites I would suggest you take a closer look at the hardware. Almost all messages are failing and in most cases radio reception is the cause. Have you used capacitors on the radio's?

                        jeylitesJ Offline
                        jeylitesJ Offline
                        jeylites
                        wrote on last edited by
                        #35

                        @AWI
                        No. Now that you mention it. I'm going to work on that. What does "st=fail:1.4.1" mean?

                        1 Reply Last reply
                        0
                        • sj44kS Offline
                          sj44kS Offline
                          sj44k
                          wrote on last edited by
                          #36

                          That there is an issue in the radio communication, and most probably the reason why it's taking so long, as all the failed transmissions will be retransmitted.
                          Like mentioned above (and on the webpage) you should install the capacitors on the radio.

                          Check the decoupling capacitor part of this page how to do this :
                          http://www.mysensors.org/build/connect_radio

                          1 Reply Last reply
                          0
                          • jeylitesJ Offline
                            jeylitesJ Offline
                            jeylites
                            wrote on last edited by jeylites
                            #37

                            Still get the same error message despite putting a 4.7uf cap across GND and VCC (3.3v) on the radio for both sensor and gateway. But I don't get any fail messages using a different My Sensor sketch. What is error message: "st=fail:1.4.1" suggesting?

                            repeater started, id 1
                            send: 1-1-0-0 s=255,c=0,t=18,pt=0,l=5,st=ok:1.4.1
                            send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
                            read: 0-0-1 s=255,c=3,t=6,pt=0,l=1:M
                            send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=16,st=ok:MultiRelayButton
                            send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=4,st=ok:0.9b
                            send: 1-1-0-0 s=0,c=1,t=2,pt=2,l=2,st=ok:0
                            send: 1-1-0-0 s=0,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                            send: 1-1-0-0 s=1,c=1,t=2,pt=2,l=2,st=ok:0
                            send: 1-1-0-0 s=1,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                            send: 1-1-0-0 s=2,c=1,t=2,pt=2,l=2,st=ok:0
                            send: 1-1-0-0 s=2,c=0,t=3,pt=0,l=5,st=ok:1.4.1
                            send: 1-1-0-0 s=3,c=1,t=2,pt=2,l=2,st=ok:1
                            send: 1-1-0-0 s=3,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                            read: 0-0-1 s=2,c=1,t=2,pt=2,l=2:0
                            This is an ack from gateway

                            AWIA 1 Reply Last reply
                            0
                            • jeylitesJ jeylites

                              Still get the same error message despite putting a 4.7uf cap across GND and VCC (3.3v) on the radio for both sensor and gateway. But I don't get any fail messages using a different My Sensor sketch. What is error message: "st=fail:1.4.1" suggesting?

                              repeater started, id 1
                              send: 1-1-0-0 s=255,c=0,t=18,pt=0,l=5,st=ok:1.4.1
                              send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
                              read: 0-0-1 s=255,c=3,t=6,pt=0,l=1:M
                              send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=16,st=ok:MultiRelayButton
                              send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=4,st=ok:0.9b
                              send: 1-1-0-0 s=0,c=1,t=2,pt=2,l=2,st=ok:0
                              send: 1-1-0-0 s=0,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                              send: 1-1-0-0 s=1,c=1,t=2,pt=2,l=2,st=ok:0
                              send: 1-1-0-0 s=1,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                              send: 1-1-0-0 s=2,c=1,t=2,pt=2,l=2,st=ok:0
                              send: 1-1-0-0 s=2,c=0,t=3,pt=0,l=5,st=ok:1.4.1
                              send: 1-1-0-0 s=3,c=1,t=2,pt=2,l=2,st=ok:1
                              send: 1-1-0-0 s=3,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                              read: 0-0-1 s=2,c=1,t=2,pt=2,l=2:0
                              This is an ack from gateway

                              AWIA Offline
                              AWIA Offline
                              AWI
                              Hero Member
                              wrote on last edited by
                              #38

                              @jeylites What I read from the log is that there seems to be a little problem with sending a bunch of messages after another. (intermittent failures) probably because the radio power supply is not keeping up. Possible solutions: hardware: increase the capacitor size (eg. 47 uF) ; software: avoid sending messages after another and put a delay in between (like the 250ms delay used in your original setup() code).

                              Fail:1..4.1 means that something went wrong in communication with MySensors version 1.4.1. The good news is that the number of fail messages is decreasing with respect to the earlier log :clap:

                              1 Reply Last reply
                              0
                              • rvendrameR Offline
                                rvendrameR Offline
                                rvendrame
                                Hero Member
                                wrote on last edited by
                                #39

                                @jeylites you can also try adding some delay between each gw.send or gw.present. In my case it did the difference.

                                Home Assistant / Vera Plus UI7
                                ESP8266 GW + mySensors 2.3.2
                                Alexa / Google Home

                                1 Reply Last reply
                                1
                                • jeylitesJ Offline
                                  jeylitesJ Offline
                                  jeylites
                                  wrote on last edited by
                                  #40

                                  @AWI said:

                                  sending messages after another

                                  I have put a 47uf, 100V capacitor in parallel with GND and 3.3V on the radio side and needless to say, it did help in reducing the number of fails. I have yet to receive my 5V to 3.3 radio adapter from China so I'm currently running of a two 1.5Vdc battery wired in series to the NRF radio.

                                  In addition, I've also put a 250ms delay between sending messages after another. With every precaution in place, I'm still getting these same messages. I'm only having this problem with this particular sketch.

                                  repeater started, id 2
                                  send: 2-2-0-0 s=255,c=0,t=18,pt=0,l=5,st=ok:1.4.1
                                  send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
                                  read: 0-0-2 s=255,c=3,t=6,pt=0,l=1:M
                                  send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=16,st=ok:MultiRelayButton
                                  send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=4,st=ok:0.9b
                                  send: 2-2-0-0 s=0,c=1,t=2,pt=2,l=2,st=ok:0
                                  send: 2-2-0-0 s=0,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                                  send: 2-2-0-0 s=1,c=1,t=2,pt=2,l=2,st=ok:0
                                  send: 2-2-0-0 s=1,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                                  send: 2-2-0-0 s=2,c=1,t=2,pt=2,l=2,st=ok:1
                                  send: 2-2-0-0 s=2,c=0,t=3,pt=0,l=5,st=fail:1.4.1
                                  send: 2-2-0-0 s=3,c=1,t=2,pt=2,l=2,st=ok:1
                                  send: 2-2-0-0 s=3,c=0,t=3,pt=0,l=5,st=fail:1.4.1

                                  1 Reply Last reply
                                  0
                                  • rvendrameR Offline
                                    rvendrameR Offline
                                    rvendrame
                                    Hero Member
                                    wrote on last edited by
                                    #41

                                    Maybe it worth a try, to remove the ACK requests? Remove the last 'true' from every gw.send line:

                                      gw.send(msg[i].set(Relays[i].relayState? true : false) ) ;
                                    

                                    Some fake radios don't play well with ACK messages. At least it worked for me.

                                    Home Assistant / Vera Plus UI7
                                    ESP8266 GW + mySensors 2.3.2
                                    Alexa / Google Home

                                    jeylitesJ 1 Reply Last reply
                                    0
                                    • rvendrameR rvendrame

                                      Maybe it worth a try, to remove the ACK requests? Remove the last 'true' from every gw.send line:

                                        gw.send(msg[i].set(Relays[i].relayState? true : false) ) ;
                                      

                                      Some fake radios don't play well with ACK messages. At least it worked for me.

                                      jeylitesJ Offline
                                      jeylitesJ Offline
                                      jeylites
                                      wrote on last edited by jeylites
                                      #42

                                      @rvendrame

                                      Ever since I removed ACK & true, I have not been having any fails at all.

                                      Everything works and I have posted the final sketch in Array Relay Button Actuator as linked below... Hope it comes in handy. Thanks again MYS community!

                                      http://forum.mysensors.org/topic/1299/array-relay-button-actuator/12

                                      1 Reply Last reply
                                      0
                                      • SzmaluS Offline
                                        SzmaluS Offline
                                        Szmalu
                                        wrote on last edited by Szmalu
                                        #43
                                        This post is deleted!
                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        21

                                        Online

                                        11.7k

                                        Users

                                        11.2k

                                        Topics

                                        113.0k

                                        Posts


                                        Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • MySensors
                                        • OpenHardware.io
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular