Low power door sensor using ESP8266


#1

I am planing to make low power consumption door sensor with ESP8266. My requirements are ,

  1. It has to work with battery for long time.
  2. It has to send MQTT topic if door is opened or closed.

Note: I googled a lot, I got confused, anybody have any ideas?. They are using Atiny85, deep sleep, wake using interupt, etc…

Thanks in advance…


#2

For low power consumption, the ESP8266’s Deep Sleep is required and use interruptions when the door is opened or closed, minimizing consumption.
I do not know how long a battery attached to an ESP8266 can last, but it should be for a good time.
For reading the sensor I recommend using the MK-DoorSensor code, I’m using it and it works perfectly.
MK-DoorSensor

I also recommend taking a look at these articles, can give you some more ideas for this project:
https://stackoverflow.com/questions/39481196/how-to-wake-esp8266-from-deep-sleep-without-continuous-resets
http://playground.arduino.cc/Learning/ArduinoSleepCode
https://forum.micropython.org/viewtopic.php?t=3051

I’ve never used this function, I hope it can help.


#3

Here is what I did. Take esp 8266 solder the first pin on the chip to reset so it can go to deep sleep and be woken up via an interupt. An inturupt is nothing but some Ground or Negetive voltage from battery to Reset pin.

Now once that is done, connect a battery preferably a LiPo to + and - and a magnetic reed switch to the ground of the battery and Reset of the esp.

In your sketch do everything in the setup part and nothing on the loop part. In the last line of the setup part put esp to sleep for infinity.

So now what happens is when the magnetic switch is closed there will be power going to reset pin however since its not an interuption after a while esp will go to sleep and consume very low power, but once door is open it power will get cut off and this acts like a interupt. So the sketch will load do its thing and go to sleep.

In my experience a 1000mah batter didn’t last more than 3 weeks in this setup.

You can easily revese the system to detect closing by adding one more reed switch with and gluing a magnet behind the switch so it becomes reverse.


#4

Here is another way which doesn’t need esp to sleep. Take esp8266 and put the positive to positve part of the battery and negetive should be connected to the magnetic reed switch connected to the battery negetive.

Magnetic reed switches are in ON state when the other part the Magnet is brought close to it. However i have successfully reversed it by adding a small magnet parmanently glued on the other side of the switch. Now this is in a continuous ON state and when another slightly more powerful magnet is brought near on the other end its pull being higher and since the switch is also designed to go the other side it detaches and turns OFF making it work the reverse way.

Now once thats done and a sketch uploaded to esp that does everything on setup. When door opens it detaches and the switch is on giving esp the power to run the sketch and send the notif.

This works ok and you can check the state of the door being still Open however this take a bit longer to do its job than the previous method. And is in my experience less relaible.