RelayActuator problem - sometimes nothing happens


  • Hero Member

    My Relay actuator worked for a day turning the lights on and off. on the second day the lights did not come one until I disconnected and re-connected the node to power. I was trying to use ser2net to get a log of what's happening on the gateway (rpi with Domoticz) but nothing showed in MYScontroller. Looking at the sketch for the replay, it seems that there is no ack for the operation. Is that correct? if the relay failed, will the controller know that it did not switch? any ideas what can be the cause? I also had a repeater node before but it still got stuck. I changed the arduino and the relay, same result. maybe not enough power to flip the relay?


  • Admin

    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.


  • Hero Member

    @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.


  • Contest Winner

    @Moshe-Livne

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


  • Hero Member

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


  • Contest Winner

    @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?


  • Hero Member

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


  • Contest Winner

    @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.


  • Hero Member

    @BulldogLowell Thanks, will do



  • @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.



  • 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);
      }
    }```

  • Contest Winner

    @madmax

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



  • @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


  • Contest Winner

    @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.


Log in to reply
 

Suggested Topics

59
Online

11.4k
Users

11.1k
Topics

112.6k
Posts