Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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

StealthRT

Member
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.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Your requirements are always going to greatly restrict battery life - I would suggest having the ESP in deepsleep, and waking it via the reed input only. The ESP modules also tend to have extra unwanted consumption via the USB chip etc.

I tend to use a PIC for such purposes, and use that to power up the ESP module (or GSM module) only when required. The PIC's also run an RTC, so wake every second to update that, and check if it should be doing something. Often they only transmit once a week, with battery life more than five years - during the transmission they also check for any changes to how they should operate - such as how often and when they transmit.

To do what you're suggesting, you neeed MUCH larger batteries.
 

Latest threads

EE World Online Articles

Loading
Top