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. Controllers
  3. Vera
  4. Relay Actuator On/Off Status Reversed

Relay Actuator On/Off Status Reversed

Scheduled Pinned Locked Moved Vera
9 Posts 4 Posters 3.7k 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.
  • M Offline
    M Offline
    Myles L
    wrote on last edited by
    #1

    Hello,

    I am currently using the relay actuator sketch to control 6 relays for an irrigation control system using Vera (VeraLite, UI7, Ethernet gateway) but for some reason the on/off status of the devices is showing up in reverse in Vera (off when on and on when off). I could use the normally closed contacts on the relays to correct the problem but then the relays would be constantly on when the irrigation solenoids are off.

    Any suggestions on how to correct the problem are welcome, thanks.

    BulldogLowellB 1 Reply Last reply
    0
    • M Myles L

      Hello,

      I am currently using the relay actuator sketch to control 6 relays for an irrigation control system using Vera (VeraLite, UI7, Ethernet gateway) but for some reason the on/off status of the devices is showing up in reverse in Vera (off when on and on when off). I could use the normally closed contacts on the relays to correct the problem but then the relays would be constantly on when the irrigation solenoids are off.

      Any suggestions on how to correct the problem are welcome, thanks.

      BulldogLowellB Offline
      BulldogLowellB Offline
      BulldogLowell
      Contest Winner
      wrote on last edited by
      #2

      @Myles-L

      Some relays that you buy on the web are so-called 'Active Low' which means they close when brought down to ground.

      Sounds like you may have that.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Myles L
        wrote on last edited by
        #3

        Thanks, I checked the relay specs and it is active low but so is the relay in the suggested buying guide. Is there a way to mod the sketch to send 5v to the active low modules so that the relay is only triggered when the voltage drops, correcting the reversed on/off indicator?

        1 Reply Last reply
        0
        • BulldogLowellB Offline
          BulldogLowellB Offline
          BulldogLowell
          Contest Winner
          wrote on last edited by
          #4

          which sketch?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Myles L
            wrote on last edited by
            #5

            The relay actuator sketch 'RelayActuator.ino'

            // Example sketch showing how to control physical relays.
            // This example will remember relay state even after power failure.

            #include <MySensor.h>
            #include <SPI.h>

            #define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
            #define NUMBER_OF_RELAYS 1 // Total number of attached relays
            #define RELAY_ON 1 // GPIO value to write to turn on attached relay
            #define RELAY_OFF 0 // GPIO value to write to turn off attached relay

            MySensor gw;

            void setup()
            {
            // Initialize library and add callback for incoming messages
            gw.begin(incomingMessage, AUTO, true);
            // Send the sketch version information to the gateway and Controller
            gw.sendSketchInfo("Relay", "1.0");

            // Fetch relay status
            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)
            gw.present(sensor, S_LIGHT);
            // Then set relay pins in output mode
            pinMode(pin, OUTPUT);
            // Set relay to last known state (using eeprom storage)
            digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
            }
            }

            void loop()
            {
            // Alway process incoming messages whenever possible
            gw.process();
            }

            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
            • G Offline
              G Offline
              griffinsaic
              wrote on last edited by
              #6

              I changed the following to get mine to work. Not sure if it will work for you.

              @Myles-L said:

              define RELAY_ON 1 // GPIO value to write to turn on attached relay
              define RELAY_OFF 0 // GPIO value to write to turn off attached relay

              switch to
              define RELAY_ON 0 // GPIO value to write to turn on attached relay
              define RELAY_OFF 1 // GPIO value to write to turn off attached relay

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Myles L
                wrote on last edited by
                #7

                Thanks, I did try that as it seemed like the logical choice but no success. now that I know it works I will be more persistent!

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Myles L
                  wrote on last edited by
                  #8

                  Works like a charm. For anyone else having the same problem I had to upload the sketch as normal, add the device to vera then modify the sketch using griffinsaic suggestion for it to work. Thanks again

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    Burtonian
                    wrote on last edited by
                    #9

                    I have been scratching my head wondering how to reverse the relay. Thank you

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


                    10

                    Online

                    11.7k

                    Users

                    11.2k

                    Topics

                    113.1k

                    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