Best sensor type for a push button



  • Hi,

    I am wondering what the best sensor type would be for a relay actuator which I want to control from my controller (Domoticz) with a push button.

    What I am about to build is a sensor with only a relay. No buttons on the sensor. And in the controller I want to control that relay with a push button. So when I activate the push button in my controller the relay switch on and then off again after lets say 1 second.

    The only way I have found is to present it as S_BINARY, and then put the logic in the code on both sides (sensor and controller). But is there a more native way to do this in the library that I not yet have found? So that the sensor shows up as a push button in the controller by it self without the need for extra code on any side?


  • Hardware Contributor

    @Strixx - https://www.mysensors.org/build/relay does exactly what you are asking for.



  • @sundberg84 But how will that code handle a push button in the controller, and not a switch?
    I don't have access to either my controller or MySensors hardware at the moment therefore I can not try it my self. Will the controller send on, and then off? What happens if the off doesn't reach the node?

    It is very important that the relay never stays at "on". Because I am about to attach a bell/siren /sound device to the relay. And use it give me audio notice when something is "bad" in my house. For example when the freezer has to high temperature. So the relay should only switch on, and then off again.


  • Hardware Contributor

    @Strixx well you can implement an off in the hardware after x seconds instead of relying on the controller. Have a look at a motion detector sketch. This will send on and then off after some seconds .



  • @Strixx I had something similar with my garage door controller sketch (check this thread). I needed to momentarily contact a relay when it received a signal to open or close the door. This is the bit of code that I used on the relay node:

    #define TOGGLE_INTERVAL 2000  //Tells how many milliseconds the relay will be held closed
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    void toggleDoor() {
      digitalWrite( DOOR_ACTUATOR_RELAY, RELAY_ON );
      timer.setTimeout( TOGGLE_INTERVAL, relayOff );
    }
    

    When the relay node got a signal from the push button on the controller end, it would call the toggleDoor() method which would turn the relay on, then wait for 2000 miliseconds, or two seconds and then immediately turn the relay off. Set the TOGGLE_INTERVAL to whatever length of time you want the relay to stay on for.



  • @dbemowsk Thank you! This is what I was looking for. Especially the code in your thread.


Log in to reply
 

Suggested Topics

  • 1
  • 1
  • 1
  • 3
  • 5
  • 6

25
Online

11.4k
Users

11.1k
Topics

112.7k
Posts