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. Troubleshooting
  3. How to get relay state?

How to get relay state?

Scheduled Pinned Locked Moved Troubleshooting
5 Posts 3 Posters 2.0k Views 1 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.
  • C Offline
    C Offline
    C.r.a.z.y.
    wrote on last edited by
    #1

    repeater started, id 100
    send: 100-100-0-0 s=255,c=0,t=18,pt=0,l=5,st=ok:1.4.1
    send: 100-100-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
    send: 100-100-0-0 s=255,c=3,t=11,pt=0,l=5,st=ok:Relay
    send: 100-100-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
    send: 100-100-0-0 s=1,c=0,t=3,pt=0,l=5,st=ok:1.4.1
    send: 100-100-0-0 s=2,c=0,t=3,pt=0,l=5,st=ok:1.4.1
    send: 100-100-0-0 s=3,c=0,t=3,pt=0,l=5,st=ok:1.4.1

    I have 3 relays and i want to make a logic something like this; if 3.relay is on than 1. relay is off

    How can i get relay status in orginal sketch?

    "
    void incomingMessage(const MyMessage &message) {
    // We only expect one type of message from controller. But we better check anyway.
    if (message.type==V_LIGHT) {
    // Change relay state
    digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
    // Store state in eeprom
    gw.saveState(message.sensor, message.getBool());
    // Write some debug info
    Serial.print("Incoming change for sensor:");
    Serial.print(message.sensor);
    Serial.print(", New status: ");
    Serial.println(message.getBool());
    }
    "

    1 Reply Last reply
    0
    • D Offline
      D Offline
      daulagari
      Hero Member
      wrote on last edited by
      #2

      On http://www.mysensors.org/build/relay you will find apart from the Relay also a RelayWithButtonActuator Example.

      Do you have some kind of feedback from the relay indicating it's status? If so, connect that to the button input and done!

      C 1 Reply Last reply
      0
      • D daulagari

        On http://www.mysensors.org/build/relay you will find apart from the Relay also a RelayWithButtonActuator Example.

        Do you have some kind of feedback from the relay indicating it's status? If so, connect that to the button input and done!

        C Offline
        C Offline
        C.r.a.z.y.
        wrote on last edited by
        #3

        @daulagari Thank you. i am trying to learn "message.xxxxx" but it is hard for me.

        How can i get 1-2-3 variables from "message.xxxxx"? So i can find which relay get a command.

        send: 100-100-0-0 s=1,c=0,t=3,pt=0,l=5,st=ok:1.4.1
        send: 100-100-0-0 s=2,c=0,t=3,pt=0,l=5,st=ok:1.4.1
        send: 100-100-0-0 s=3,c=0,t=3,pt=0,l=5,st=ok:1.4.1

        http://www.mysensors.org/build/sensor_api#the-full-api this link is very useful but very hard for me...

        +++ i have some trouble with your link ; http://forum.mysensors.org/topic/738/relaywithbuttonactuator-example-with-touch-sensor/7

        B 1 Reply Last reply
        0
        • C C.r.a.z.y.

          @daulagari Thank you. i am trying to learn "message.xxxxx" but it is hard for me.

          How can i get 1-2-3 variables from "message.xxxxx"? So i can find which relay get a command.

          send: 100-100-0-0 s=1,c=0,t=3,pt=0,l=5,st=ok:1.4.1
          send: 100-100-0-0 s=2,c=0,t=3,pt=0,l=5,st=ok:1.4.1
          send: 100-100-0-0 s=3,c=0,t=3,pt=0,l=5,st=ok:1.4.1

          http://www.mysensors.org/build/sensor_api#the-full-api this link is very useful but very hard for me...

          +++ i have some trouble with your link ; http://forum.mysensors.org/topic/738/relaywithbuttonactuator-example-with-touch-sensor/7

          B Offline
          B Offline
          BulldogLowell
          Contest Winner
          wrote on last edited by
          #4

          @C.r.a.z.y.

          something like:

          if (message.sensor == CHILD_ID)
          {
            if (message.type == V_VAR2)
            //etc....
          
          C 1 Reply Last reply
          1
          • B BulldogLowell

            @C.r.a.z.y.

            something like:

            if (message.sensor == CHILD_ID)
            {
              if (message.type == V_VAR2)
              //etc....
            
            C Offline
            C Offline
            C.r.a.z.y.
            wrote on last edited by
            #5

            @BulldogLowell That's it! Thank you :+1:

            if (message.sensor==1 && message.getBool()==true)
            {....

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            13

            Online

            12.0k

            Users

            11.2k

            Topics

            113.4k

            Posts


            Copyright 2025 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