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. Development
  3. RelayActuator problem - sometimes nothing happens

RelayActuator problem - sometimes nothing happens

Scheduled Pinned Locked Moved Development
14 Posts 5 Posters 4.1k 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.
  • hekH Offline
    hekH Offline
    hek
    Admin
    wrote on last edited by
    #2

    Yeah, I'd say you have a power issue with the relays. It has been discussed many times here on the forum. Power relay separately from the arduino.

    Moshe LivneM 1 Reply Last reply
    0
    • hekH hek

      Yeah, I'd say you have a power issue with the relays. It has been discussed many times here on the forum. Power relay separately from the arduino.

      Moshe LivneM Offline
      Moshe LivneM Offline
      Moshe Livne
      Hero Member
      wrote on last edited by
      #3

      @hek Thanks, will do that as soon as I figure out how. I DID try to look it up. "RelayActuator power" does not yield anything meaningful, same with "relay power". The note in the example say that only if you use more than one relay but this got me thinking that this can be the problem.

      BulldogLowellB 1 Reply Last reply
      0
      • Moshe LivneM Moshe Livne

        @hek Thanks, will do that as soon as I figure out how. I DID try to look it up. "RelayActuator power" does not yield anything meaningful, same with "relay power". The note in the example say that only if you use more than one relay but this got me thinking that this can be the problem.

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

        @Moshe-Livne

        You could show a schematic of your rig and detail what type/size power supply you are using.

        Moshe LivneM 1 Reply Last reply
        0
        • BulldogLowellB BulldogLowell

          @Moshe-Livne

          You could show a schematic of your rig and detail what type/size power supply you are using.

          Moshe LivneM Offline
          Moshe LivneM Offline
          Moshe Livne
          Hero Member
          wrote on last edited by
          #5

          @BulldogLowell Calling it schematic would be an overkill. It is a nano powered by a 1A wall socket.

          BulldogLowellB 1 Reply Last reply
          0
          • Moshe LivneM Moshe Livne

            @BulldogLowell Calling it schematic would be an overkill. It is a nano powered by a 1A wall socket.

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

            @Moshe-Livne said:

            @BulldogLowell Calling it schematic would be an overkill. It is a nano powered by a 1A wall socket.

            Are you powering the relay in parallel <to> edit: with the Arduino or from Arduino's Vcc?

            1 Reply Last reply
            0
            • Moshe LivneM Offline
              Moshe LivneM Offline
              Moshe Livne
              Hero Member
              wrote on last edited by
              #7

              currently from the arduino vcc. I have no idea how to wire it directly from the wall power. without breaking it, that it.

              BulldogLowellB 1 Reply Last reply
              0
              • Moshe LivneM Moshe Livne

                currently from the arduino vcc. I have no idea how to wire it directly from the wall power. without breaking it, that it.

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

                @Moshe-Livne said:

                currently from the arduino vcc. I have no idea how to wire it directly from the wall power. without breaking it, that it.

                Assuming you have a 5V power supply and a single channel 5V relay, it will have a Ground, Vcc and IN pins.

                Connect with a wire from arduino's Vin (not Vcc) and arduino's ground. The third third (IN) will go to the arduino pin you are using to control the relay... start there.

                Moshe LivneM 1 Reply Last reply
                0
                • BulldogLowellB BulldogLowell

                  @Moshe-Livne said:

                  currently from the arduino vcc. I have no idea how to wire it directly from the wall power. without breaking it, that it.

                  Assuming you have a 5V power supply and a single channel 5V relay, it will have a Ground, Vcc and IN pins.

                  Connect with a wire from arduino's Vin (not Vcc) and arduino's ground. The third third (IN) will go to the arduino pin you are using to control the relay... start there.

                  Moshe LivneM Offline
                  Moshe LivneM Offline
                  Moshe Livne
                  Hero Member
                  wrote on last edited by
                  #9

                  @BulldogLowell Thanks, will do

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Chester
                    wrote on last edited by
                    #10

                    @Moshe-Livne Depending on whether your incoming power is replaceable or hard wired in your module...

                    You could look into picking up one of those dual voltage wall warts, that have one output with 1A, and one output with 2.1A. You could then just use one USB lead from the 1A output to run the Arduino and radio, then use the 2.1A output to power the relay board with a sufficient loading ability.

                    I have done this with my 8 port SSR relay card, and so far in testing it has been super stable, and I have had no glitches in radio performance due to power drops from turning on or off the relays.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      madmax
                      wrote on last edited by
                      #11

                      Hello

                      i have a sketch with dth22 motion and relay

                      it's not optimal but it works

                      i want to add another relay but it doesn't work have you a soluce

                      thanks

                      #include <MySensor.h>
                      #include <DHT.h>
                      #include <SimpleTimer.h>
                      
                      #define CHILD_ID_HUM 1
                      #define CHILD_ID_TEMP 2
                      #define CHILD_ID_MOTION 3
                      #define CHILD_ID_RELAY 4
                      
                      #define MOTION_SENSOR_DIGITAL_PIN 3
                      #define HUMIDITY_SENSOR_DIGITAL_PIN 4
                      #define INTERRUPT MOTION_SENSOR_DIGITAL_PIN-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
                      #define RELAY  5// Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                      #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
                      
                      unsigned long SLEEP_TIME = 600000; // Sleep time between reads (in milliseconds) - 10mins
                      
                      DHT dht;
                      SimpleTimer timer;
                      float lastTemp;
                      float lastHum;
                      boolean lastTripped;
                      boolean metric = true;
                      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
                      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
                      MyMessage msg(CHILD_ID_MOTION, V_TRIPPED);
                      
                      MySensor gw;
                      void setup()  
                      { 
                        // Initialize library and add callback for incoming messages
                        gw.begin(incomingMessage, AUTO, true);
                        
                        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
                      
                        // Send the Sketch Version Information to the Gateway
                        gw.sendSketchInfo("HumTempRelayMotion", "1.0");
                      
                        // Register all sensors to gw (they will be created as child devices)
                        gw.present(CHILD_ID_HUM, S_HUM);
                        gw.present(CHILD_ID_TEMP, S_TEMP);
                        gw.present(CHILD_ID_MOTION, S_MOTION);
                        gw.present(CHILD_ID_RELAY, S_LIGHT);
                        pinMode(RELAY, OUTPUT);
                        digitalWrite(RELAY, gw.loadState(RELAY)?RELAY_OFF:RELAY_ON);
                        
                        //Serial.begin(9600);
                        timer.setInterval(30000, getMeasure);
                        metric = gw.getConfig().isMetric;
                        
                      }
                      
                      void loop()      
                      {  
                        // Alway process incoming messages whenever possible
                        gw.process();
                        timer.run();
                        
                        boolean tripped = digitalRead(MOTION_SENSOR_DIGITAL_PIN) == HIGH;    
                        if (tripped != lastTripped) {
                          lastTripped = tripped;
                          Serial.print("M: ");
                          Serial.println(tripped);
                          gw.send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
                        }
                      
                      }
                      
                      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-CHILD_ID_RELAY+RELAY, 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());
                         } 
                      }
                      
                      void getMeasure() {
                        delay(dht.getMinimumSamplingPeriod());
                      
                        float temperature = dht.getTemperature();
                        if (isnan(temperature)) {
                            Serial.println("Failed reading temperature from DHT");
                        } else if (temperature != lastTemp) {
                          lastTemp = temperature;
                          if (!metric) {
                            temperature = dht.toFahrenheit(temperature);
                          }
                          gw.send(msgTemp.set(temperature, 1));
                          Serial.print("T: ");
                          Serial.println(temperature);
                        }
                        
                        float humidity = dht.getHumidity();
                        if (isnan(humidity)) {
                            Serial.println("Failed reading humidity from DHT");
                        } else if (humidity != lastHum) {
                            lastHum = humidity;
                            gw.send(msgHum.set(humidity, 1));
                            Serial.print("H: ");
                            Serial.println(humidity);
                        }
                      }```
                      BulldogLowellB 1 Reply Last reply
                      0
                      • M madmax

                        Hello

                        i have a sketch with dth22 motion and relay

                        it's not optimal but it works

                        i want to add another relay but it doesn't work have you a soluce

                        thanks

                        #include <MySensor.h>
                        #include <DHT.h>
                        #include <SimpleTimer.h>
                        
                        #define CHILD_ID_HUM 1
                        #define CHILD_ID_TEMP 2
                        #define CHILD_ID_MOTION 3
                        #define CHILD_ID_RELAY 4
                        
                        #define MOTION_SENSOR_DIGITAL_PIN 3
                        #define HUMIDITY_SENSOR_DIGITAL_PIN 4
                        #define INTERRUPT MOTION_SENSOR_DIGITAL_PIN-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
                        #define RELAY  5// Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                        #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
                        
                        unsigned long SLEEP_TIME = 600000; // Sleep time between reads (in milliseconds) - 10mins
                        
                        DHT dht;
                        SimpleTimer timer;
                        float lastTemp;
                        float lastHum;
                        boolean lastTripped;
                        boolean metric = true;
                        MyMessage msgHum(CHILD_ID_HUM, V_HUM);
                        MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
                        MyMessage msg(CHILD_ID_MOTION, V_TRIPPED);
                        
                        MySensor gw;
                        void setup()  
                        { 
                          // Initialize library and add callback for incoming messages
                          gw.begin(incomingMessage, AUTO, true);
                          
                          dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
                        
                          // Send the Sketch Version Information to the Gateway
                          gw.sendSketchInfo("HumTempRelayMotion", "1.0");
                        
                          // Register all sensors to gw (they will be created as child devices)
                          gw.present(CHILD_ID_HUM, S_HUM);
                          gw.present(CHILD_ID_TEMP, S_TEMP);
                          gw.present(CHILD_ID_MOTION, S_MOTION);
                          gw.present(CHILD_ID_RELAY, S_LIGHT);
                          pinMode(RELAY, OUTPUT);
                          digitalWrite(RELAY, gw.loadState(RELAY)?RELAY_OFF:RELAY_ON);
                          
                          //Serial.begin(9600);
                          timer.setInterval(30000, getMeasure);
                          metric = gw.getConfig().isMetric;
                          
                        }
                        
                        void loop()      
                        {  
                          // Alway process incoming messages whenever possible
                          gw.process();
                          timer.run();
                          
                          boolean tripped = digitalRead(MOTION_SENSOR_DIGITAL_PIN) == HIGH;    
                          if (tripped != lastTripped) {
                            lastTripped = tripped;
                            Serial.print("M: ");
                            Serial.println(tripped);
                            gw.send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
                          }
                        
                        }
                        
                        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-CHILD_ID_RELAY+RELAY, 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());
                           } 
                        }
                        
                        void getMeasure() {
                          delay(dht.getMinimumSamplingPeriod());
                        
                          float temperature = dht.getTemperature();
                          if (isnan(temperature)) {
                              Serial.println("Failed reading temperature from DHT");
                          } else if (temperature != lastTemp) {
                            lastTemp = temperature;
                            if (!metric) {
                              temperature = dht.toFahrenheit(temperature);
                            }
                            gw.send(msgTemp.set(temperature, 1));
                            Serial.print("T: ");
                            Serial.println(temperature);
                          }
                          
                          float humidity = dht.getHumidity();
                          if (isnan(humidity)) {
                              Serial.println("Failed reading humidity from DHT");
                          } else if (humidity != lastHum) {
                              lastHum = humidity;
                              gw.send(msgHum.set(humidity, 1));
                              Serial.print("H: ");
                              Serial.println(humidity);
                          }
                        }```
                        BulldogLowellB Offline
                        BulldogLowellB Offline
                        BulldogLowell
                        Contest Winner
                        wrote on last edited by
                        #12

                        @madmax

                        there are examples on the forum on multiple relays on one MCU... try searching the forum.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          madmax
                          wrote on last edited by
                          #13

                          @BulldogLowell said:

                          are examples on the forum on multiple relays on one MCU... try searching the forum.

                          yes i see but with dth 22 it's difficult
                          i use simpletimer.h with this

                          BulldogLowellB 1 Reply Last reply
                          0
                          • M madmax

                            @BulldogLowell said:

                            are examples on the forum on multiple relays on one MCU... try searching the forum.

                            yes i see but with dth 22 it's difficult
                            i use simpletimer.h with this

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

                            @madmax

                            yes, so go to mutlti relay, add your libraries for simple timer and DHT. Thge relay code is non-blocking so you should be able to fold it in quite nicely.

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


                            12

                            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