ESP32, Deepsleep and external Wake-up sources?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ao16
Normal user
Posts: 19
Joined: 03 Oct 2018, 23:51

ESP32, Deepsleep and external Wake-up sources?

#1 Post by ao16 » 23 Jan 2022, 19:13

Hello Community,

I have been spending many hours searching through the forum to findout
if external wake-up sources are also supported with ESPEasy and an ESP32
however have not found an answer.
In one thread (of two years ago) it was mentioned "not yet" - is that still the case?

My application and why I need external wake-up from deepsleep:
I want to use an ESP32 (because I need many GPIO's for several input signals
and some signaling LEDs depending which input signal triggered the event)
that shall be run on battery power inside our car.

Thus I'd like to use deepsleep of the ESP32 and wake it up only if one
of the external trigger sources (=the pushbutton) are pressed - as most
of the time the ESP32 will be sleeping.
Additionally, periodically I also want to measure the voltage of the battery
and -if I am in coverage range of the configured WiFi APs- send the measurement
to Thingspeak and also sent an eMail if the battery is getting low.

The latter use-case I will be able to cover with the timer Sleep awake time/sleep time in the configuration tab of ESPEasy,
however the external trigger of an event (e.g. different pushbuttons are pressed
and shall now be visualized which one was pressed) does not work
and does not wake-up the ESP32 from sleeping.

Does anybody know if several external wake-up sources like pushbuttons are supported
in the meantime in ESPEasy to solve my above use-case?
Or is there another way to solve my described application?

Thanks a lot in advance for any suggestions and advice!

best regards,

AO16

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32, Deepsleep and external Wake-up sources?

#2 Post by TD-er » 23 Jan 2022, 21:22

I know what you mean and no that has not yet been implemented.
However, I do have some other recent added feature which you may help you out here.

See: https://espeasy.readthedocs.io/en/lates ... pping-pins
There is a number of special boot strapping pins on the ESP32 which can be used to trigger some special boot mode (e.g. like GPIO-0 to enter flash mode)
However those are not all being used right now, but are available in the System#bootmode event.

Just make sure to have a good look at the table right above the section I linked, as setting GPIO-12 is potentially quite dangerous as it may fry the flash chip if you set it to another state at boot.

kohleIT
Normal user
Posts: 23
Joined: 25 Jul 2021, 22:45

Re: ESP32, Deepsleep and external Wake-up sources?

#3 Post by kohleIT » 25 Jan 2022, 09:35

hi

I am also looking since a while for such solution!
It would be cool to use the existing magnetic sensor. ESP32 Built-In Hall Effect Sensor
Wake up if a magnetic field gets apply.
Is this a technical challenge?
I would spend some money – if someone can realize this.

br

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32, Deepsleep and external Wake-up sources?

#4 Post by TD-er » 25 Jan 2022, 11:21

Not all pins/inputs can be used to wake the ESP32.
Will have to check the documentation to see if the Hall effect sensor in the ESP32 can be set to act as a wake input.

umbm
New user
Posts: 7
Joined: 09 Oct 2016, 11:08

Re: ESP32, Deepsleep and external Wake-up sources?

#5 Post by umbm » 25 Jan 2022, 18:05

Do you all want to use pure ESP32 modules or a developer board with USB connector and 5V power supply?

My experience:
The ESP32 developer boards I tested are not really the best choice to use deepsleep, especially if the project is battery driven.

After all my tests I decided to use a additional TPL5110 module for wakeup with timer and/or pushbutton.
The TPL5110 cuts off the power completely from ESP32 and uses extremely low power (uA) for long battery life.
At wakeup, the ESP32 boots up, should run all measurements once and gives back a single gpio signal to TPL5110 to cut off power again.

Disadvantage: only wakeup from timer or pushbutton at TPL5110.

More here:
https://learn.adafruit.com/adafruit-tpl ... kout/usage

kohleIT
Normal user
Posts: 23
Joined: 25 Jul 2021, 22:45

Re: ESP32, Deepsleep and external Wake-up sources?

#6 Post by kohleIT » 26 Jan 2022, 10:52

Do you all want to use pure ESP32 modules or a developer board with USB connector and 5V power supply?
Actually in my Minde is following Dev Board:
https://www.dfrobot.com/product-2231.html
My experience:
The ESP32 developer boards I tested are not really the best choice to use deepsleep, especially if the project is battery driven.
Agree - I tested many of them - and nearly all were consuming to much Power. Please understand i am looking for a Baterie sulution.
Can you share some Expertise how long your ESP was running without Battery change (What Bat. got used)
After all my tests I decided to use a additional TPL5110.....
Disadvantage: only wakeup from timer or pushbutton at TPL5110.
Agree & Interesting approch.

In my Case I would like to have something to awake the ESP up and do the maintenance for couple of minutes. Still the regular awake time should be very short as this consumes power.

umbm
New user
Posts: 7
Joined: 09 Oct 2016, 11:08

Re: ESP32, Deepsleep and external Wake-up sources?

#7 Post by umbm » 27 Jan 2022, 19:56

With one Samsung ICR18650 (2600mAh), deepsleep 20 min, active max 50 sec I got 2 weeks in maximum.

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32, Deepsleep and external Wake-up sources?

#8 Post by TD-er » 27 Jan 2022, 22:17

You may want to have a look at the used voltage regulators and perhaps some other components.
Most voltage regulators have a relative high quiescent current (e.g. the AMS1117 even has 5 - 10 mA minimal current)

kohleIT
Normal user
Posts: 23
Joined: 25 Jul 2021, 22:45

Re: ESP32, Deepsleep and external Wake-up sources?

#9 Post by kohleIT » 30 Jan 2022, 18:22

i would have one more question:
In my case the µC regularly switching on - send data via MQTT and is going back to sleep. My Problem is to do Maintenance as the awake time is very short.
Question 1:
What Pin could is use for enable Maintenance mode (maintenance Mode = continues running without going to sleep)
Question 2:
Can I use a simple read switch (magnetic) and influence the mode with rules? ( press reset & read switch together)
How ?

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32, Deepsleep and external Wake-up sources?

#10 Post by TD-er » 30 Jan 2022, 21:54

You could use the rules to turn the ESP into deepsleep mode.
This way you can also check the pin state of any pin at boot (or when trying to enter deep sleep) and decide on the pin value whether you want to go to sleep or not.

Or just use the boot strapping pins I mentioned before.

ao16
Normal user
Posts: 19
Joined: 03 Oct 2018, 23:51

Re: ESP32, Deepsleep and external Wake-up sources?

#11 Post by ao16 » 12 Feb 2022, 22:37

Thank you TD'er and the others for all your hints!

Well, I found another solution that seems to work on my breadboard for my above use-case:
I connected a 2u2 capacitor (in parallel a 330k resistor) to the EN pin.
The other end of this RC parallel combination is connected to a pushbutton that is connected to GND
The junction point of the pushbutton and the RC is connected also to a GPIO configured as input.

Now when pressing the pushbutton, it reset's the ESP32 and wakes it up manually from deepsleep.
After a short moment, the capacitor is fully charged, thus the ESP32 is booting and running
and not kept in RESET state anymore.

At the same time, I readout the GPIO (OLED_ON#state) and store the value in a dummyvar (1 or 0) and use this
later on to evaluate which button was pressed. With more than one button, several RC's will be needed,
for each button the same RC network - and then also the GPIO's to read in the state of the pushbutton.

Here's the code that I use to detect if the OLED_ON-Button was pressed and evaluate later the DummyVar
and depending if it was pressed or the ESP32 came out of deepsleep due to another reason I start
different subroutines (one is called "LongOn", the other is called "ShortOn".

Code: Select all

on System#Wake do
   if [OLED_ON#State]=0   //when OLED_ON button pressed
      TaskValueSet,Dummy,OLED_ON,1   // LongOn
   else
      TaskValueSet,Dummy,OLED_ON,0  // ShortOn
   endif

   if [Dummy#OLED_ON]=1
      oledframedcmd,display,on
      TaskValueSet,Status,LongOn,1  // 4debug
      TaskValueSet,Status,ShortOn,0 // 4debug
   else
      oledframedcmd,display,off
      TaskValueSet,Status,ShortOn,1 // 4debug
      TaskValueSet,Status,LongOn,0  // 4debug
   endif
endon

Regarding the board:
I first wanted to use a bare ESP32 module, however wiring it to a standard 2.54mm pinhole board
I then did not wanted to do. So I used a ESP32 Devkit V1.

The power consumption during deep sleep with the AMS1117 was in my case indeed around 9 mA.
I replaced it by a HT7833.
However the CP2102 still consumed several mA - so I cut the Vsup and Vreg to disable the chip
and suddenly the current consumption was <1mA. Through the decoupling resistor of 1k between
the still soldered CP2102 and also the 4k7 pull-up at the RES-Pin of the CP2102 still flew several hundret uA's.
Removing them I had issues that the ESP32 was sometimes not booting...so I changed the 4k7 to 22k
and the 1k to 10k and now my sleep current is around 150uA. Probably by removing the CP2102 it would
go down even more..however with 150uA I can accomodate with my target application.

Maybe this experiences are helpful for anyone having a similar use-case to solve.

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32, Deepsleep and external Wake-up sources?

#12 Post by TD-er » 13 Feb 2022, 09:44

Just curious, how do you measure those currents?
A normal multimeter cannot do it, so you must either use some current preamp and a scope (or multimeter) or something like the PowerProfiler from Nordic (have one myself too) https://www.nordicsemi.com/Products/Dev ... iler-Kit-2
This Power Profiler kit (version 2, as that one can deliver/measure upto 1A) is a great tool for such analysis.
I also use it to evaluate WiFi issues and since you can also log upto 8 GPIO pin states, you can also track behavior based on events.

I have been looking into voltage regulators with low quiescent current myself and it is hard to find one that's widely available (lots have lead times of over half a year) and can handle a peak current of 500 mA or more.
This HT7833 does look nice.
Maybe we should have a section on the documentation page for good picks of components for issues like these.

Do you have more options for low quiescent current regulators?

Also found this discussion regarding the HT7833: https://www.esp32.com/viewtopic.php?t=7319

Which HT7833 do you use?
The 5 pin or the 4 pin with wider strip?
The 5 pin does have a ChipEnable pin, which can be useful for turning it really off. For example with an external circuit to protect some battery charged by a solar panel.

ao16
Normal user
Posts: 19
Joined: 03 Oct 2018, 23:51

Re: ESP32, Deepsleep and external Wake-up sources?

#13 Post by ao16 » 14 Feb 2022, 21:02

Yes, that's true, you are right - measuring those currents if the ESP is in full operation
and all is highly dynamic is not possible with a normal multimeter.
No, I also did not use a scope nor a current preamp for that differential measurement nor a PowerProfiler.
The PowerProfiler indeed is a very nice tool, I just had a look on the link that you provided.

The basis on my measurements to optimize the sleep current was
that the whole device is in a kind of "static mode" during deep sleep - WiFi, UART
and all other high consumptions drivers of the ESP are all off.

So what I did is just to measure the voltage across the resistors during deep sleep with a multimeter
and then calculated the current through that resistor with Ohm's law
as I had its resistance and now also the voltage accross it.

E.g. taking the 1k decoupling resistor that connects the TXD Pin of the CP2102 and the RXD GPIO of the ESP32 on the DEVKIT V1.
If I remember right, I measured around 0.6V...0.8V - that leads to around 600uA...800uA flowing through that resistor during deep sleep.

I was quite amazed about that this leakage current is flowing because the CP2102's VDD and VREG
were disconnected from the 3V3 supply voltage and there was no USB-Connection so also the VBUS Pin as well the D+ and D- were not connected.
So I thought it is in high impedance.
The only Pin's of the CP2102 that were still connected were RST (4k7 Pullup to 3V3),
the decoupling resistors that connect CP2102's RXD and TXD to the ESP's UART and the GND-Pin.
However only through one of both 1k resistors there was a current flow. At the 2nd resistor, the voltage measured accross was 0V.
That's the reason why I changed the decoupling resistor and the RST Pullup to a slightly higher value and
thus reduced the currents.

Sure, removing the CP2102 would be the best way...however I just did not want to desolder that IC and still had in mind
if on one day I want to easy re-programm the ESP32 again via USB for any reason, I just need to connect the VDD and REGIN Pin to 3V3 again.

By changing the above resistors, I was able to verify that the total deep sleep current of the DEVKIT V1
that can be measured now with a good multimeter just in series to the mains 5V supply was reduced by the calculated value.

Also to mention, the 1k pre-resistor of the red LED on the DEVKIT that just visualizes that 3V3 is present
I also removed because these mA's for a continous lit LED are a waste for the deep sleep.


Regarding the voltage regulators, it is not easy to find one that's widely available, I can confirm that.
I was reading and digging through many, many websites and also assessing what people experienced there.
Some users reported that they had success with MCP1700/1703 (also easily available at www.reichelt.de) that also
has a very low quiscent current however the max current is 250mA and using a big cap to buffer the peak currents of ESP32.
For me, this appeared too risky for my use-case so I decided for the Holtek HT7833 that supports up to 500mA
with a quiscent current of typical 4uA - completly fine for me.
I am using the SOT89 housing that has 4pins, so without a ChipEnable - however with that low quiscent current I am very fine.

I ordered some for very low price via Aliexpress but on the other hand, I also wanted to have some *very fast* :-) ...so I ordered here:
https://www.shotech.de/de/ht7833-sot89.html

Regarding your question for more low quiscent current LDO's besides the HT7833,
I noted the following ones during my research on the web also.
Below is just a copy and paste of my selection that I found at different sites*, stated data not verified:

XC6203(XC6203E33):
Range voltage: 8 v Max
Max current out: 400 mA
Quiescent current: 8 uA
Drop out voltage: 300 mV

AP2112:
Max current out: 600 mA
Quiescent current: 55 uA
Drop out voltage: 250 mV

RT9013:
Range voltage: 5.5 v Max
Max current out: 500 mA
Quiescent current: 25 uA
Drop out voltage: 250 mV

SPX3819:
Range voltage: 16 V Max
Max current out: 500 mA
Quiescent current: 8 uA
Drop out voltage: 550 mV

*https://www.esp8266.com/viewtopic.php?f=13&t=19801


Another list I found here <https://arduinodiy.wordpress.com/2020/0 ... n-esp8266/>

Out of that list, the ME6211 also looks interesting. (40uA quiscent, max inp. 6.5V, max Out 300..50mA)

Oh...that was now quite a long text....anyway, hope it helps.

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests