💬 Door, Window and Push-button Sensor
-
I did just build a similar sensor based on my small sensor node. I think the example code here isn't really perfect though (although its very basic, perhaps that was the only goal).
As I wanted to use this with batteries I used an interrupt and sleep(). The deboucing library isn't really need, a short gw.wait(50); did it for me too.
Here is my code (not yet updated to mysensors 2). Any comments? Perhaps we could update the example code too. -
Dont forget to add a 10K resistor between GND and your PIN (in this example pin3)
-
Dont forget to add a 10K resistor between GND and your PIN (in this example pin3)
@janvier123 Do you really need that? Shouldn't the internal pullups be enough?
pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); -
for some reason the value was always "1" untill i "pushed the button" => then i got "0"
however ive added an 10K resistors between the pin and gnd, and now it works fine :)maybe because its not an official UNO board?
-
i don't why, but debouncer.read(); always return 1, i was never able to send the status of the door, however, digitalRead(BUTTON_PIN) returns the actual value.
since i am using this for reed switch, i believe i don't need the debouncing functionality do i ?
-
i don't why, but debouncer.read(); always return 1, i was never able to send the status of the door, however, digitalRead(BUTTON_PIN) returns the actual value.
since i am using this for reed switch, i believe i don't need the debouncing functionality do i ?
@Meshx86 said:
i don't why, but debouncer.read(); always return 1, i was never able to send the status of the door, however, digitalRead(BUTTON_PIN) returns the actual value.
since i am using this for reed switch, i believe i don't need the debouncing functionality do i ?
Hello,
yes you can get rid of the debouncing stuff for your reed switch (or any physical switch) if you are sleeping and waking up on interrupt, just add a little wait before you read the value to let the switch settle.
If you are running at 1MHz then the time to wake up from sleep is longer (45ms if I remember well) and you don't even need the sleep. -
What is the way to put the sketch on a sensebender with battery powered ?
-
Is the BinarySwitchSleepSensor a good answer ?
-
I have the same problem, when I use the bounce library to read my reed switch I always read "1". If I use digitalRead I get an bounce error.
I have an arduino compatible, configure it for 1Mhz, 1M resistor for the reed switch and 2 AA battery.
Someone has a similar one working? -
I have the same problem, when I use the bounce library to read my reed switch I always read "1". If I use digitalRead I get an bounce error.
I have an arduino compatible, configure it for 1Mhz, 1M resistor for the reed switch and 2 AA battery.
Someone has a similar one working? -
Nuub here..
Thinking about building this in my mailbox..
AND if possible set a green light diode to start light when box is opened and stop when its opened again.That way i would see when i come home if someone has opened the mailbox or not.. Sure push notifications work aswell but it would be a nice touch for the wifey
-
Nuub here..
Thinking about building this in my mailbox..
AND if possible set a green light diode to start light when box is opened and stop when its opened again.That way i would see when i come home if someone has opened the mailbox or not.. Sure push notifications work aswell but it would be a nice touch for the wifey
@meanmrgreen if you use a led it will draw a few mA when on and battery life will be poor.
At best you could wake up every few seconds and flash it briefly (like 100ms or less). In that case use a low value current limiting resistor to have an intense flash, and probably a red LED is better.
To stop the blinking why not use a button (or touch button, check TTP223 in AliExpress) inside the mailbox ? -
Not sure if it more battery friendly, but maybe sending a bluetooth low energy beacon is better than a led? Higher nerd factor for sure, but maybe less spouse friendly (depending on how good the ble app on the phone is).
Seems like it would be possible by using an extra nrf24: https://github.com/floe/BTLE/blob/master/examples/send/send.ino
On the other hand, if a smartphone is required you might as well open the app for your controller and check the status there :)
Maybe use a battery-friendly PIR and only light/blink the led when motion is detected?
-
You lost me at bluetooth beacon? :)
Me personally is using the app but wifey and kids ain't really as interested as i am ;)
So therefore I would need a indicator of some sorts around the mailbox that is about 30 meters from the house in the road up to the house.
Maybe a solar led light or similar to light up? Or a flag on a servo?
Will start with building the switch and figure out the indicator later.
-
Hi Everyone
Be carefull a newby here... :-)I have ordered all the parts for my sensor network. My plan is to have battery powered sensor sensing the following: Door/window status AND temp/humidity. Doing all this in a low power fashion.
My question is: Would these code in the build section be easily combined (dooe switch and temp/hum) in a way that it measures the temp/hum regurarly (every 15-30 min) and if during the sleep a door event happens it sends the door event to the gateway (and probably since we are awake do a temp/hum measurement as well)?
Every piece of direction, advice is appreciated.
Atesz
-
Like I said..newby here. Hold back your horses for a moment, I did a deep search and found some interesting forum topics here :-)