Mailbox esp32s deep sleep mode, I need help

Hey Guys

I´m making a mailbox sensor system with a nodemcu esp32s and the code works very good, but I have problems with the deep sleep mode, I don´t think its setup correct.

The code works on that way that there are 3 switches, 1 for letter, 1 for packages and 1 for reset for letter/packages, the codes works good.
Then there are reaction on one of the sensors the esp32s wakes up and connects to the wifi and send the state message to home assistant via mqtt and goes back to deep sleep.

I want it to run on battery and I have measured power consumption when the board is in hibernate rtc it consumes ca.
8 mah per minute,
480 mah per hour.
11,520 mah per day.
and approx. 345.600mah 1 month.

I think there is a problem in the code about the deep sleep mode.

Are there one of your people in this forum there could look my code though and maybe tell me what the problem is and maybe could edit it for me ?
I have uploaded the code to pastebin on this link -> https://pastebin.com/Frny82w6

Best Regards Stig

1 Like

While I can’t offer you help directly, I did do a similar project using an arduino nano in deep sleep mode, and the 2x AA’s powering it last roughly a year. I only have a door contact sensor connected to sense when the mailbox door opens.

It doesn’t look like you’re shutting down WiFi before going to sleep?

I have recently been working on a weather station with the ESP8266 and MicroPython. I know, apples and oranges, but mine takes about 70 uA in deep sleep.