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. General Discussion
  3. Combining BinarySwitch with PressureSensor

Combining BinarySwitch with PressureSensor

Scheduled Pinned Locked Moved General Discussion
14 Posts 3 Posters 2.9k Views 3 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.
  • mfalkviddM Offline
    mfalkviddM Offline
    mfalkvidd
    Mod
    wrote on last edited by
    #4

    The node will wake up at SLEEP_TIME if the window switch doesn't change, so you'll get data at least as often as SLEEP_TIME.

    1 Reply Last reply
    0
    • Øyvind LauritzenØ Offline
      Øyvind LauritzenØ Offline
      Øyvind Lauritzen
      wrote on last edited by
      #5

      I've change the line

      gw.sleep(SLEEP_TIME);
      

      to

      gw.sleep(digitalPinToInterrupt(BUTTON_PIN), CHANGE, SLEEP_TIME);
      

      This was what you meant? It doesn't seem to do more than wake up as you said every 60 seconds to transfer the status of all sensors - pressure, switch and temp.

      Did I misunderstand what you meant maybe? :)

      TIA

      1 Reply Last reply
      0
      • mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #6

        Good thinking. Let's make sure we have the same goal :-)

        • The sensor should send temp/pressure data at least every 60 seconds
        • The sensor should also send switch information every time there is a change (window is opened or closed)

        correct?

        Øyvind LauritzenØ 1 Reply Last reply
        0
        • mfalkviddM mfalkvidd

          Good thinking. Let's make sure we have the same goal :-)

          • The sensor should send temp/pressure data at least every 60 seconds
          • The sensor should also send switch information every time there is a change (window is opened or closed)

          correct?

          Øyvind LauritzenØ Offline
          Øyvind LauritzenØ Offline
          Øyvind Lauritzen
          wrote on last edited by
          #7

          @mfalkvidd Yes as far as I understand that should be it, unless the forecast algorithm is not for some reason depending on it updating exactly every 60 seconds?

          I am actually gonna be using the switch info to know the state of my garage door, making sure it's not by mistake left open when it shouldn't.

          1 Reply Last reply
          0
          • mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #8

            Great. Then your code change should be enough. What does the serial debug log of the node say?

            1 Reply Last reply
            0
            • Øyvind LauritzenØ Offline
              Øyvind LauritzenØ Offline
              Øyvind Lauritzen
              wrote on last edited by Øyvind Lauritzen
              #9

              From what the serial monitor is telling me is that it is updating at least temp and pressure, I don't know where I see the actual switch? Domoticz only update temp and pressure every time the switch is triggered, it is not telling me the new state of the switch until at least 60sec from what it seems.

              send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1019
              Temperature = 25.40 *C
              Pressure = 1019.35 hPa
              Forecast = stable
              send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1019
              Temperature = 25.40 *C
              Pressure = 1019.32 hPa
              Forecast = stable
              send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1019
              Temperature = 25.40 *C
              Pressure = 1019.37 hPa
              Forecast = stable
              send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1019
              Temperature = 25.40 *C
              Pressure = 1019.38 hPa
              Forecast = stable
              send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1019

              1 Reply Last reply
              0
              • mfalkviddM Offline
                mfalkviddM Offline
                mfalkvidd
                Mod
                wrote on last edited by
                #10

                Could you include output from startup as well? You should get at least one switch message when the node is reset.

                Next step is probably to add som Serial.println in various places to see what is happening.

                You have double-checked the wiring? The switch is connected to GND on one side and pin 3 on the other sie?

                1 Reply Last reply
                0
                • Øyvind LauritzenØ Offline
                  Øyvind LauritzenØ Offline
                  Øyvind Lauritzen
                  wrote on last edited by Øyvind Lauritzen
                  #11

                  Yes it is clear that it is working partly because it will eventually update the state of the switch, but it will not do this as often as temp/pressure. Temp/pressure is updated every time switch is triggered, but still the state of the switch is not reported every time , only when 60+ seconds have passed.

                  This is the startup.

                  send: 2-2-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
                  send: 2-2-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.4
                  send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
                  read: 0-0-2 s=255,c=3,t=6,pt=0,l=1,sg=0:M
                  sensor started, id=2, parent=0, distance=1
                  send: 2-2-0-0 s=3,c=0,t=0,pt=0,l=0,sg=0,st=ok:
                  send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=15,sg=0,st=ok:Pressure Sensor
                  send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.1
                  send: 2-2-0-0 s=0,c=0,t=8,pt=0,l=0,sg=0,st=ok:
                  send: 2-2-0-0 s=1,c=0,t=6,pt=0,l=0,sg=0,st=ok:
                  send: 2-2-0-0 s=3,c=1,t=16,pt=2,l=2,sg=0,st=ok:0
                  Temperature = 25.30 *C
                  Pressure = 1019.42 hPa
                  Forecast = unknown
                  send: 2-2-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:25.3
                  send: 2-2-0-0 s=0,c=1,t=4,pt=7,l=5,sg=0,st=ok:1019
                  send: 2-2-0-0 s=0,c=1,t=5,pt=0,l=7,sg=0,st=ok:unknown

                  1 Reply Last reply
                  0
                  • mfalkviddM Offline
                    mfalkviddM Offline
                    mfalkvidd
                    Mod
                    wrote on last edited by
                    #12

                    If you load the pure binary switch example, does the switch work then? My best guess is that the reed switch is broken or incorrectly wired.

                    1 Reply Last reply
                    0
                    • Øyvind LauritzenØ Offline
                      Øyvind LauritzenØ Offline
                      Øyvind Lauritzen
                      wrote on last edited by
                      #13

                      I've actually already tried that, worked with no problem. Maybe i've missed something or something similair, lets see what happens after a good nights sleep. Thank you for you help so far. :)

                      martinhjelmareM 1 Reply Last reply
                      1
                      • Øyvind LauritzenØ Øyvind Lauritzen

                        I've actually already tried that, worked with no problem. Maybe i've missed something or something similair, lets see what happens after a good nights sleep. Thank you for you help so far. :)

                        martinhjelmareM Offline
                        martinhjelmareM Offline
                        martinhjelmare
                        Plugin Developer
                        wrote on last edited by
                        #14

                        @Øyvind-Lauritzen

                        Debouncer Bounce won't work with sleep. Use a short sleep of 5 ms to debounce instead. Look at the binary switch sleep example.

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


                        23

                        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