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. Best sensor type for a push button

Best sensor type for a push button

Scheduled Pinned Locked Moved Development
6 Posts 3 Posters 1.8k Views 2 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.
  • S Offline
    S Offline
    Strixx
    wrote on last edited by
    #1

    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?

    sundberg84S 1 Reply Last reply
    0
    • S Strixx

      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?

      sundberg84S Offline
      sundberg84S Offline
      sundberg84
      Hardware Contributor
      wrote on last edited by sundberg84
      #2

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

      Controller: Proxmox VM - Home Assistant
      MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
      MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
      RFLink GW - Arduino Mega + RFLink Shield, 433mhz

      S 1 Reply Last reply
      0
      • sundberg84S sundberg84

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

        S Offline
        S Offline
        Strixx
        wrote on last edited by
        #3

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

        sundberg84S dbemowskD 2 Replies Last reply
        0
        • S Strixx

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

          sundberg84S Offline
          sundberg84S Offline
          sundberg84
          Hardware Contributor
          wrote on last edited by
          #4

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

          Controller: Proxmox VM - Home Assistant
          MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
          MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
          RFLink GW - Arduino Mega + RFLink Shield, 433mhz

          1 Reply Last reply
          0
          • S Strixx

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

            dbemowskD Offline
            dbemowskD Offline
            dbemowsk
            wrote on last edited by
            #5

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

            Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
            Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

            S 1 Reply Last reply
            1
            • dbemowskD dbemowsk

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

              S Offline
              S Offline
              Strixx
              wrote on last edited by
              #6

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

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


              14

              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