book collections email follower instructable user
Picture of LEIDS - Low Energy IOT Door Sensor

What is LEIDS?

LEIDS is an IOT sensor that is based around the ESP8266. This sensor makes use of this board, a soft latching circuit, a reed switch, and some magnets to create a door sensor that will send you an alert when your door opens and closes. This sensor can be hooked up to your MQTT server, IFTTT, or many other frameworks that support the ESP8266. This instructable will use IFTTT to easily create a sensor that will send an alert to your mobile device no matter where you are. The sensor can also be setup to allow for multiple alerts from separate doors, mailboxes, ovens and anything else that has an open/close or on/off physical position. The benefit of LEIDS is that it uses minimal power and only uses power when a door is open, then when the door is closed it sends a message to alert you the door was closed and turns off. This is better than deep sleeping the module as it uses no energy if the door is not opened.

Step 1: Supplies

The lists below show the tools and parts I used for this project. The sensor can be redesigned to use different parts and look/function differently and just use similar concepts.

Tools:

  • Soldering Iron
  • ESP01-UART or Arduino Uno(programmer for ESP8266)
  • 3D printer (optional)
  • Jumper cables(optional)
  • Breadboard(optional)

Parts:

  • ESP8266 ESP-01S x 1
  • Reed Switch x 1 (preferably NC, I could only find normally open so have to use two magnets to make it work as normally closed)
  • AMS1117 3.3v Regulator
  • 2n3904 NPN Transistor x 1
  • P-Channel Mosfet x 1 (we want something that has a low VGS, preferably a NDP6020P)
  • 3.7v 100 mAh Lipo battery x 1
  • Assorted Resistors (100k ohm, 10k ohm, 220 ohm, 3k3 Ohm)
  • 6x3mm Magnets x 2
  • Double Sided mounting tape
  • Wire
  • Solder
  • Perfboard

3D Printed Parts:

  • Case for sensor
pgs0709473 months ago
Nice, comprehensive project.
You say thay N/C reed switches aren't available. They are, but you nedd to buy a reed switch with changeover contacts. I bought some recently from RS or Farnell to allow me to take the power off a sealed battery powered wireless device
RichardM3503 months ago
A nice add would be to check battery level with activation of door and alert when at maybe 25% remaining
ArturoG (author)  RichardM3503 months ago
Hey RichardM350, that is a pretty good idea. I might look into using one of the other pins to keep a tab on the battery level.
vks007 ArturoG3 months ago
Hi, Yes that's one way. Or a cheaper way is to use read the internal voltage of the ESP using ESP.getVcc() and then log it in the MQTT message. I do it that way. As the ESP can run till 3V it usually will take a few days to weeks for the voltage to fall from 3.3V to 3V on the ESP and you have ample time to respond to it and change the battery.
vks0073 months ago
Thanks for the circuit. I had built something similar but it still
consumed ~6uA current in the idle state , so this one definitely seems
better. Although I find working with MOSFETS a bit difficult as they
tend to get damaged easily with static charge when handling them.
Can you please complete the circuit diagram with connections to the ESP 01? The diagram above does not specify the same.
EDIT: I was able to figure out the pins by looking at the sketch. 1- Vcc , 2 - GPIO2 , 3 - GPIO0 , 4 - GND.
Also, I would add a a LDO like HT 7333 between the MOSFET and the ESP so that it can withstand a voltage of a fully charged Lion battery of 4.1V.
I currently use a 1000mAh 18650 battery to power the existing door sensor which consumes ~6uA and it lasts for around 5-6 months for my main door which opens and closes at least 30-40 times a day. So this one should last for a verrrrrrrrrry long time.
ArturoG (author)  vks0073 months ago
Hey vks007, I was going to try to put a better schematic together after work today but yes you are right! Also I am using an AMS1117 to regulate the voltage to the Vcc so that it outputs a clean 3.3v at 1 amp. The hope was to have something that last a long time and was small/discreet, I am only using a 100mAh battery so I would hope it would last quite a while. I have not had this little sensor setup for very long and have not kept tabs on how long it lasts so I guess I will try to speed up the testing maybe by having something open close the switch continuously until the battery runs out.
JurajP1 ArturoG3 months ago
HT7333 is better, if door is open/close offen...
ArturoG (author)  JurajP13 months ago
Hey JurajP1, I agree it is a better component since it draws less current while on. So if I was deep sleeping it would be a lot better, in my case it was easier to get the AMS1117 and I wasn't going to be deep sleeping so I was not too concerned. Thanks!
mickeypop3 months ago
Over all a very good post.

As an electronics engineer I offer 1 minor change, reduce R3 to about 20K to 50K though 20K is still the better. R3's only real purpose it to pull the gate HIGH to turn the P-MOSFET off when the gate is not high.

This will better guarantee full power off when the R5 and diode pin changes to turn off again.

If the resistance of R3 is too high and the P-channel MOSFET fails to turn "Fully Off" it can keep the ESP from properly booting on successive triggering.
ArturoG (author)  mickeypop3 months ago
I fully agree with you. The high resistance may have caused some of the bugginess I experienced. Thanks for the excellent tip!
Dram2293 months ago
Nice idea. I think i'll try it. Have you test to see how long the battery lasts before it needs replacement for an average usage scenario?
RenéB2 Dram2293 months ago
Same question here. I've heard connecting to WiFi uses so much power it would basically only last ~10 times...
ArturoG (author)  RenéB23 months ago
Hey ReneB2, you are right it uses a lot of battery to use the wifi; however, the hope is that it should only use it for such a short time it won't waste much energy. I will need to test it more to see how long it can really last (hopefully a couple months of normal usage).
ArturoG (author)  Dram2293 months ago
Hey Dram229, as per my other comment I have not really had a chance to test it extensively. I will try putting something together to open/close the switch a bunch of times or maybe leave it open and see how long it lasts.
Sounds like a nice little device and it looks really finished in the 3D printed enclosure :)