control the impulse relay of the House eletrical installation



  • Hello,

    The electrical installation of the house is made with some impulse relays connected to momentary physical switch. I would like to control the light with mySensors gateway.
    To activate the impulse relay, i have to generate a quick pulse of the relay in MySensors code, I have compiled the following code but it is not working.
    => i have to press 2 times the switch button in my gateway to generate the pulse.
    Any suggestions will be welcome 🙂

    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Enable repeater functionality for this node
    #define MY_REPEATER_FEATURE
    
    #include <MySensors.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
    
    
    void before()
    {
    	for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
    		// Then set relay pins in output mode
    		pinMode(pin, OUTPUT);
    		// Set relay to last known state (using eeprom storage)
    	//	digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
    		   
    		  if (loadState(sensor) == RELAY_ON) {
              digitalWrite(pin, RELAY_ON);
              wait(500);
              digitalWrite(pin, RELAY_OFF);
    		  }
    	}
    }
    
    void setup()
    {
    
    }
    
    void presentation()
    {
    	// Send the sketch version information to the gateway and Controller
    	sendSketchInfo("Relay", "1.0");
    
    	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)
    		present(sensor, S_BINARY);
    	}
    }
    
    
    void loop()
    {
    
    }
    
    void receive(const MyMessage &message)
    {
    	// We only expect one type of message from controller. But we better check anyway.
    	if (message.type==V_STATUS) {
    		// Change relay state
    		//digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
    		
    		 if (message.getBool() == RELAY_ON) {
            digitalWrite(message.sensor-1+RELAY_1, RELAY_ON);
            wait(500);
            digitalWrite(message.sensor-1+RELAY_1, RELAY_OFF);
            }
    		
    		
    		
    		// Store state in eeprom
    		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());
    	}
    }
    
    


  • @jeremushka said in control the impulse relay of the House eletrical installation:

    Hello,

    The electrical installation of the house is made with some impulse relays connected to momentary physical switch. I would like to control the light with mySensors gateway.

    Hello @jeremushka , i am new tot Mysensors, but maybe you can read in the state of te relay, i think it is not working because Mysensors cannot see the state of the relay.
    When you press one of the buttons in your house the relay will switch on (from off off course), and when you want to switch the relay from mysensors, mysensors do not know if is't already on.

    on some impulse relay's there are a on, off and pulse input possible, if you connected the my sensors to the on (or off) connection than it is possible that the impulse relay only what to switch on (or off)


  • Mod

    If you have your node close to the relay, you could install one of those mains voltage detectors to have a feedback on the status



  • ![Thanks for your replies. Actually, the problem is to trigger the pulse of the relay with the function "delay". It is working but sometimes during the "delay" function, the gateway has not received the information of the first pulse yet. So, the second pulse "digital write..." will not work. I will have to press several times. It is a coding optimization i think.
    For the status i have used a ACS712 sensor to know if the light is on or off.

    i attached for you the electrical diagram of the "standard" impulse relay on a french house installation which is located in the main board in the garage. Push button are connected. This relay is trigger with 2 quick pulses when you press the push button, then the light will turn on or off. To insert Mysensors project to this original electricall installation i directly connected the mysensors Node with an NO NC relay directly on the same wires than the push button. From the gateway, i trigger the relay with 2 pulses.
    0_1535352294566_telerupteur.jpg


 

397
Online

7.7k
Users

8.6k
Topics

92.5k
Posts