lessons learned from building a door/window sensor using the ESP-1 (8266) and this tutorial as a guide
$5 DIY Wireless MQTT Smart Home Window Sensors (original & 'fixed')
https://www.youtube.com/watch?v=BoYVr2UwWWg
https://www.youtube.com/watch?v=2kLZ7DlP9KU&t=60s
Executive Summary. Could not get the sensor to work reliably due to issues with CR2032 battery (not enough mAh to power up chip) & reed switch (stopped going completely open when magnet removed).
Even though Ithe end results were unsatisfactory it was a great learning experience covering arduino programming of a ESP-1 module and setting up an MQTT server.
Details of issues
(using arduino sensor script from the original video (i.e. without the ip address of the chip)
power.
- It was working great during bread board testing using a dedicated power supply (3.3V). When I went to test after assembling the sensor using CR2032 coin cell battery it would not work. Google searches identified potential issue with that particular chip requiring ~ 320mAh to power up and connect to wifi while the CR2032 can only provide ~200mAh.
- I then connected to 2 AAA batteries and that solved the power issue although now I did not have a nice 3d printed container
The author mentioned he had one 'power hungry' chip (of 10) that would not work unless connected to a power supply. All 5 of my ships would not work so wondering if there was a design change on the chip in the last 3 years?
reed switch
- After confirming the 2 aaa battery setup was working on a table top, I used velcro to attach the sensor and magnets to the door and got inconsistent results.
- delay in getting 'open' message.
> Initially I thought this could be due to weak wifi signal at the door from home router. signal strength at the location was in the -55 to - 60 dB range. Looked online and that should have been good enough.
> read one post that having the wifi sensor close to the ground reduces the transmit signal. As the chip was flush against the door frame was wondering if this was an issue. I aligned the wifi chip so it was perpendicular to the frame while the reed switch would still be parallel to the magnets. Inconsistent results (i.e. sometime never got a 'open' message. other times it would show up 20 seconds later)
>I then checked the reed switch resistance using a volt meter and leads hooked up to either side. I got expected reading (1) when magnet was nearby (i.e. less than 2mm) but did not always get zero when magnet moved away. When I got zero I got an 'open' message.
Final Thoughts
I am not sure I figured out the exact cause(s) but am sure I could not get the sensor to work reliably after spending hours trouble shooting.
Overall this project was a great learning experience as I start to get into DIY home automation as it tied together programming a ESP wifi chip (8266) via arduino, setting up a MQTT server, homebridge, home assistant on Rapsberry pi and flow programming (nodeRed).
-
,