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

stealthrt
Posts: 6
Joined: Sat Aug 28, 2021 1:22 am

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

Postby stealthrt » Fri Nov 12, 2021 9:34 pm

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.

boarchuz
Posts: 600
Joined: Tue Aug 21, 2018 5:28 am

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

Postby boarchuz » Sat Nov 13, 2021 7:14 am

  • 20uA sleep current is easily achievable, excluding poor component selection or design error. No problems there.
  • 5mA average active current is too low, considering most of that time will be actively transmitting/receiving over WiFi and doing work (TLS handshake, JSON construction).
  • Wakeups per hour should be 30, not 120
The active time is by far the most significant factor here. Wake up time and WiFi connection time could benefit from optimisation, or reducing the wakeup interval.
If you're not committed to WiFi, this would be a good fit for ESP-NOW with one always-on master connected to WiFi/ethernet, relaying data to/from the 20 nodes. It's much faster than establishing a WiFi connection.

This is an ESP-NOW wakeup+transmission I captured a while ago (38.9ms @ average 53.2mA = 574nAh):
espnow.png
espnow.png (32.27 KiB) Viewed 2285 times

Who is online

Users browsing this forum: No registered users and 68 guests