I just finished my door sensor with esphome and some cheap reed sensors.
Total cost for this project is about 15 €.
I’m using a WEMOS LOLIN32 ESP32 running on a 18650 Battery soldered to a strip board. Positive output is connected with an ADC Pin (34) and the reed sensor itself is connected with +3V and Pin 14 .
Pin 14 is defined as a binary GPIO sensor and also as the wakeup pin for the ESP itself.
If no motion is detected the ESP32 will sleep for 6 hours and wake up for 30 seconds publishing the battery value and the current door state. If the door is opened the esp awakes from deep sleep and sends the current state. See the esphome source code for further details
If the voltage of the battery drops below 3V the esp performs a complete shutdown (in theory (still to be explored in detail)).
I have tried the exact same model to automate my mailbox I want a pushbullet to be sent to my phone when the postman drops a parcel … however i find that it takes about 10 secs for the esp32 to wake-up from deep-sleep and communicate to home assistant that the door was opened (by the postman). if it takes him (or her) less than 10 secs (ie. open door, drop parcel and close the door) then the esp 32 will wake-up but no change in status will be detected… I do not see how to fix that … while in deep-sleep is there any way for the esp32 to memorize the change that occured before wifi was fully reactivated? apart from leaving a note on the mailbox that the door should be left opened for more than 10 seconds of course
Busy rooms sounds like you could have a power source there? Maybe that’s better for your usecase…
Otherwise you could try to work with filters to force the minimum sleep time to a certain level (maybe need to experiment with a filter for the pir sensor too, to don’t retrigger a wake up) but this goes for sure on the detection ‘rate’. You will have kind of a dead zone after a detection - but maybe that fits your case, can’t tell?
Problem for you is that the device sucks most of it’s energy when wakin’ up (connecting to WiFi, api…) - which does it a lot’s of times in your case.
You could count the total runtime of the board (time in wake up) for a charge of battery (maybe with the duty_cycle sensor? The uptime sensor behaves weird when powered with battery…).
Anyone tried this code with an esp8266, alot smaller and can be mounted with a small litho for windows, doors would need a larger battery. There is a guy on youtube that has done it, but he is using arduino code, I would like to be able to have a yaml file to use with esptool, but I am not familiar enough to be able to modify the code. here is a link to the youtube video, his printed case is perfect and just a bit larger than the old wired reed sensors.