Having an ESP32 control a reed switch with wifi and deep sleep on LIPO battery

Thread Starter


Joined Mar 20, 2009
I’m looking to create a project for my home. I am wanting to place window and door sensors (reed switch) and hook it up to my ESP32 wroom-32 (wemos) microprocessor. The version I have has the JST connector to hook up a LIPO battery to. I have 20 of these to use with a reed switch and a custom 3D printed enclose for it.

I found the website that allows me to input the specs of my esp32 and see how long the battery would last depending on the size of the battery. For my math I came up with the following:

Capacity rating of battery = 1700mAh
Current consumption of device during sleep = 0.02 mA
Current consumption of device during wake = 5 mA
Number of wakeups per hour = 120 (every 2 minutes)
Duration of wake time = 1000 ms

This puts it just shy of 1 year (323.7 days) on the LIPO only.

I plan on utilizing the deep sleep function that the esp32 has. I’ve seen that its around 150 µA (0.15 mA) and replacing that value with the one provided above (0.02 mA) with the calculator gives me an even lower amount of days. So, I will only wake it up using the external source which would be the reed switch (ext0/vp) and use the Timer function to send and receive data every 2 minutes and then go back to sleep for another 2 minutes

The big question I have though is this – How much does waking every 2 minutes, turning on the Wi-Fi and RX/TX a json string take in mA? Each time I am wanting it to send via WIFI a json string to my home server API to let update my dashboard so it knows that esp32 status (open or closed window/door) and battery level (10-100%).

Now the even bigger question is – how would I be able to send a command to the esp32 to let it know if it needs to alarm when it detects the reed switch connection or if I simply want to open the window to get some fresh air without it tripping the alarm? That can be done with every 2 minutes it wakes and send data – I could just send json string back letting it know to not worry if the reed switch is tripped or not. But again, I do not know how much current all that would take to achieve all this?

So, to summarize:
- I want to place the esp32 into deep sleep every 2-5 minutes.
- I want to send a json string every 2 minutes to my API.
- I want to send back a json string for “disable” to not care about the reed switch status or “Enable” which would mean to care about the reed switch status.
- I want to turn on the Wi-Fi just enough to be able to send and receive json data.

I’m sure there’s somebody out there that has done this type of setup or close to it that can lend some helpful advice.


Joined Jan 23, 2018
If this is for a security system, it seems like you want to create a wireless link. Or is the intention to have wire connections? And you are asking about things by model number, (esp32) which gives me no clue at all what it is. So there is a lot of missing information.
Also, a security system needs to check more often than every 2 minutes, but that may just be the interval between hand-shakes with the sensors.