Combining BinarySwitch with PressureSensor
-
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
-
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?
@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.
-
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 -
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?
-
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 -
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. :)
-
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. :)
Debouncer Bounce won't work with sleep. Use a short sleep of 5 ms to debounce instead. Look at the binary switch sleep example.