Skip to content
  • 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. Troubleshooting
  3. Relay Help - Nothing Happens
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

Relay Help - Nothing Happens

Scheduled Pinned Locked Moved Troubleshooting
19 Posts 5 Posters 4.4k Views 4 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.
  • Matt PittsM Matt Pitts

    @Boots33 thanks, I'm using the sketch unaltered. When I check the serial monitor I can see the messages coming in 0 and 1 so I know the connection to the broker and therefore the radio must be working right? otherwise the messages wouldn't show up on the serial monitor right? also I see st:OK in the monitor which means messages are being delivered, is that right?

    Weirdly though I thought that once I connected 5v from the arduino to VCC and GND to GND the relay would power up, but this doesn't happen?? The relay only powers up when I connect the pin 3 to the relay. In fact it I connect the 5V from the arduino to the +IN that also powers the relay. Sorry I'm relatively new to all this and only have a very basic understanding so apologies for so many questions.

    I'm wondering if I need to alter the sketch in some way?? My current pin connections are show below in the photo. If I remove the jumper the relay doesn't work at all??

    0_1456917851573_relay-pins.jpg

    Boots33B Offline
    Boots33B Offline
    Boots33
    Hero Member
    wrote on last edited by
    #10

    @Matt-Pitts said:

    @Boots33 thanks, I'm using the sketch unaltered. When I check the serial monitor I can see the messages coming in 0 and 1 so I know the connection to the broker and therefore the radio must be working right? otherwise the messages wouldn't show up on the serial monitor right? also I see st:OK in the monitor which means messages are being delivered, is that right?

    Yes that is how i understand it should be.

    Weirdly though I thought that once I connected 5v from the arduino to VCC and GND to GND the relay would power up, but this doesn't happen?? The relay only powers up when I connect the pin 3 to the relay. In fact it I connect the 5V from the arduino to the +IN that also powers the relay.

    Nothing too weird there that is how I would expect the relay to work.

    I'm wondering if I need to alter the sketch in some way?? My current pin connections are show below in the photo. If I remove the jumper the relay doesn't work at all??

    You have it connected as I think it should be also, but bear in mind i am not sure exactly the way those relays connect up.

    By your serial debug info the sketch seems to be running ok. so you need to establish what is happening at pin 3 . remove the relay and fit a LED to see if that toggles on and off. at least then you will know the node is working ok.

    If that is working then it would seem we may have the wrong connection setup for the relay board or the relay board is drawing too much power for the arduino to supply. Either way you will need to try the simple relay code Hek has supplied to work out what connections work.

    1 Reply Last reply
    0
    • Matt PittsM Offline
      Matt PittsM Offline
      Matt Pitts
      wrote on last edited by
      #11

      Thanks @Boots33 and @hek I will give all those things a try in the morning.

      1 Reply Last reply
      0
      • Matt PittsM Offline
        Matt PittsM Offline
        Matt Pitts
        wrote on last edited by Matt Pitts
        #12

        I'm still struggling with my relay just thought i would share the serial monitor output

        YoU will see the last 4 messages are me sending on off commands

        send: 40-40-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
        send: 40-40-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=fail:1.5.4
        send: 40-40-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
        repeater started, id=40, parent=0, distance=1
        send: 40-40-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
        send: 40-40-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
        send: 40-40-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
        read: 0-0-40 s=1,c=0,t=3,pt=0,l=1,sg=0:1
        read: 0-0-40 s=1,c=0,t=3,pt=0,l=1,sg=0:0
        read: 0-0-40 s=1,c=0,t=3,pt=0,l=1,sg=0:1
        read: 0-0-40 s=1,c=0,t=3,pt=0,l=1,sg=0:0
        

        Also when I try the simple sketch from @hek the relay works, so I'm stuck

        Here are the messa0_1456999660383_Screen Shot 2016-03-03 at 10.06.30.png gaes I get when I first power up the nano

        1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #13

          Is your incomingData method called in the sketch? You can add some debug prints there perhaps?

          Matt PittsM 1 Reply Last reply
          0
          • hekH hek

            Is your incomingData method called in the sketch? You can add some debug prints there perhaps?

            Matt PittsM Offline
            Matt PittsM Offline
            Matt Pitts
            wrote on last edited by Matt Pitts
            #14

            @hek sorry I don't really understand what you mean? I'm using openhab and my messages are being send to the topic from openhab via my mosquito broker.

            I have mqtt fx subscribed to all topics so I can see incoming and outgoing messages.

            The messages in my previous post came from the relay node when I powered it on.

            The question is which of those topics should I be sending my on off commands to? I also want to understand the messages.

            The 1st message from the node is just stating 'node' which I assume just confirms that node is there?

            The second message just states '1.0' I assume this is the sketch version?

            The third message is blank but I assume this should show the state of the relay ie either 0 or 1. Is that correct?

            So based in that logic I have been sending my commands to the last tooic, but I also tried all the others just in case. But none will switch the relay.

            Is this correct

            1 Reply Last reply
            0
            • Boots33B Offline
              Boots33B Offline
              Boots33
              Hero Member
              wrote on last edited by
              #15

              n the incomingMessage function of the relay sketch there are several Serial.print statements that will be output to the serial monitor if a new message is received from the gateway.

              You have tried hek's code and that works by switching the relay on and off then the hardware hookup of the relay should be ok.

              Do you see the messages from the lines

              Serial.print("Incoming change for sensor:");
               Serial.print(message.sensor);
               Serial.print(", New status: ");
               Serial.println(message.getBool());
              
              1 Reply Last reply
              0
              • Matt PittsM Offline
                Matt PittsM Offline
                Matt Pitts
                wrote on last edited by Matt Pitts
                #16

                Hi @Boots33 This is starting to drive my a little crazy, I've managed to get lots of other mysenors working without this much trouble!! I feel like a bit of a failure at this point.

                Yes I tried @hek simple sketch which makes the relay switch on and off contiunously, so it must be wired up correctly.

                I'm not sure what the debug lines should look like?? The following appears in the serial monitor as soon as I switch on the nano

                send: 40-40-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
                send: 40-40-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=fail:1.5.4
                send: 40-40-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
                repeater started, id=40, parent=0, distance=1
                send: 40-40-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
                send: 40-40-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
                send: 40-40-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
                

                I was expecting the last send to have a something after the ok: or is that normal?

                I'm not clear as to which topic I need to send the commands to, which I think is part of the problem?

                Here's the code I have been using in my openhab items file which defiantly sends the commands to the broker as I see them appear in MQTT fx,

                Switch Testlight               "Test switch"   (Bedroom)    {mqtt=">[matt_broker:mygateway1-in/40/1/0/0/3:command:ON:1],>[matt_broker:mygateway1-in/40/1/0/0/3:command:OFF:0]"} 
                

                but as to which topic they need to go to I'm still stuck. Although I have tried all the ones that appear in the broker and none of them will switch the relay. Am I missing something really obvious here!!

                martinhjelmareM 1 Reply Last reply
                0
                • Matt PittsM Matt Pitts

                  Hi @Boots33 This is starting to drive my a little crazy, I've managed to get lots of other mysenors working without this much trouble!! I feel like a bit of a failure at this point.

                  Yes I tried @hek simple sketch which makes the relay switch on and off contiunously, so it must be wired up correctly.

                  I'm not sure what the debug lines should look like?? The following appears in the serial monitor as soon as I switch on the nano

                  send: 40-40-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
                  send: 40-40-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=fail:1.5.4
                  send: 40-40-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
                  repeater started, id=40, parent=0, distance=1
                  send: 40-40-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
                  send: 40-40-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
                  send: 40-40-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
                  

                  I was expecting the last send to have a something after the ok: or is that normal?

                  I'm not clear as to which topic I need to send the commands to, which I think is part of the problem?

                  Here's the code I have been using in my openhab items file which defiantly sends the commands to the broker as I see them appear in MQTT fx,

                  Switch Testlight               "Test switch"   (Bedroom)    {mqtt=">[matt_broker:mygateway1-in/40/1/0/0/3:command:ON:1],>[matt_broker:mygateway1-in/40/1/0/0/3:command:OFF:0]"} 
                  

                  but as to which topic they need to go to I'm still stuck. Although I have tried all the ones that appear in the broker and none of them will switch the relay. Am I missing something really obvious here!!

                  martinhjelmareM Offline
                  martinhjelmareM Offline
                  martinhjelmare
                  Plugin Developer
                  wrote on last edited by martinhjelmare
                  #17

                  @Matt-Pitts

                  Hi!

                  I can see two problems.

                  You have one failed message in the log, so radio comm is not perfect.

                  Your topic structure is wrong.

                  For the dev branch mqtt topic structure is like this:
                  Prefix/node_id/child_id/message_type/ack/message_subtype

                  So you want to use the message type set which is a 1. And for a actuator with type S_LIGHT and V_LIGHT subtype will be a 2 when doing a set message.

                  If node is 40 and child is 1, like in your example, topic structure is:
                  prefix/40/1/1/0/2

                  1 Reply Last reply
                  0
                  • Matt PittsM Offline
                    Matt PittsM Offline
                    Matt Pitts
                    wrote on last edited by
                    #18

                    @martinhjelmare Thanks for your input, I have finally got the relay working based on your example :-)

                    Thanks for your explanation of the topic structure? I'm still struggling to understand the mqtt topic structre is there somewhere I can read a good explanation?

                    I can see how you work out the prefix node_id and child_id but how do I know or work out message type ack and message_subtype?

                    I just want to understand this better for future reference.

                    Switch mqttsw1               "Test Switch"   (Bedroom)    {mqtt=">[matt_broker:mygateway1-in/40/1/1/0/2:command:ON:1],>[matt_broker:mygateway1-in/40/1/1/0/2:command:OFF:0]"}
                    
                    martinhjelmareM 1 Reply Last reply
                    0
                    • Matt PittsM Matt Pitts

                      @martinhjelmare Thanks for your input, I have finally got the relay working based on your example :-)

                      Thanks for your explanation of the topic structure? I'm still struggling to understand the mqtt topic structre is there somewhere I can read a good explanation?

                      I can see how you work out the prefix node_id and child_id but how do I know or work out message type ack and message_subtype?

                      I just want to understand this better for future reference.

                      Switch mqttsw1               "Test Switch"   (Bedroom)    {mqtt=">[matt_broker:mygateway1-in/40/1/1/0/2:command:ON:1],>[matt_broker:mygateway1-in/40/1/1/0/2:command:OFF:0]"}
                      
                      martinhjelmareM Offline
                      martinhjelmareM Offline
                      martinhjelmare
                      Plugin Developer
                      wrote on last edited by
                      #19

                      @Matt-Pitts

                      For the mqtt client on the dev branch there is a sticky guide in the forum:
                      http://forum.mysensors.org/topic/2352/guide-setting-up-and-testing-mqtt-client-gateway

                      For the message types etc see the serial API. It's my number one visited page on the mysensors web. Although I'm starting to know it by heart now.:wink:

                      http://www.mysensors.org/download/serial_api_15

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      8

                      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
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular