ESP32 power conditioning

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: ESP32 power conditioning

Post by Capstan » Wed Mar 21, 2018 11:26 pm

Capstan wrote:
Wed Mar 21, 2018 6:01 pm
I'm going to assemble another board with 'raw' voltage input in the meantime, should be able to perform these tests with something that starts off in a known good state.
The plot thickens. I assembled a fresh board with no regulator and it behaves in exactly the same way as the previous one. When I saw this I put a regulator on the first 'raw power' board and fed it 7.5V, it works just fine. So possibly there is something about the 3.3V power supply I am using. I put an oscilloscope on it and it looks clean, just some slight ripple of a few mV.

Will see what happens with LiFePo4 batteries.

Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: ESP32 power conditioning

Post by Capstan » Thu Mar 22, 2018 11:09 pm

LiFePo4 batteries did not help.

I was tearing my hair out over this and went through a process of elimination, it turned out that the plug-in breadboard I was using to wire power sources, the current monitor, and the ESP32 together was the problem somehow. Added resistance or something, even just on the power rail? I would not have expected it but hey, the breadboard only cost about USD $3. Chalking that up to experience. Connecting directly from power sources to the ESP32 board (and keeping the INA219 in the circuit) works.

Testing on a board with no regulator, and the only components are 10K pullup resistors to the enable and program pins. The power draw at the Python prompt is 100mA, more than I expected. Turning on WiFi with the following code bumps this to 120mA!;

Code: Select all

import network
wlan = network.WLAN(network.STA_IF)
Being connected to a WiFi network doesn't cost any extra power after the negotiation has completed.

Entering into deep sleep with the following code showed a draw of 1-1.5mA. Is this typical? I was expecting some micro-amps, are we not going into the deep deep sleep?

Code: Select all

import machine
machine.deepsleep(20000)

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: ESP32 power conditioning

Post by loboris » Fri Mar 23, 2018 10:44 am

@Capstan

How exactly your test ESP32 board and setup looks like and how are you are measurring the current?

I've tested ESP-WROOM-32 & ESP-WROVER modules (running MicroPython) on a simple breakout boards (so no other power loads are present), powered by LiFePO4 battery and got 5.5 uA power consumption in deepsleep mode and less than 40 mA at MicroPython prompt (without WiFi started).

Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: ESP32 power conditioning

Post by Capstan » Fri Mar 23, 2018 2:41 pm

I'm using a INA219 in series with the positive supply line as shown in the photo I posted;

http://cdwilson.us/articles/understanding-the-INA219/

I'm using a 3.3V power supply that reportedly will deliver up to an amp, and it is connected directly to the Wroom-32 VCC pin 2. Which sleep mode are we entering when machine.deepsleep() is called? Several possible modes are listed in the documentation;

https://www.espressif.com/sites/default ... eet_en.pdf

One of them is "association sleep" where there is active RF, said to draw 1-4mA. I don't have the ULP co-processor enabled in the build menu, does that affect anything?

My test yesterday involved running a program at bootup that connects to WiFi, and then hitting control-c to get to the python prompt. Apparently this leaves WiFi running. Booting up straight to the prompt shows a power draw of 44mA which is more like what you are seeing.

Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: ESP32 power conditioning

Post by Capstan » Fri Mar 23, 2018 3:16 pm

Invoking deepsleep() without having enabled WiFi shows a vastly lower power draw, about .001mA, so maybe the trick is to disable WiFi before entering sleep.

ARTaylor
Posts: 29
Joined: Fri Mar 23, 2018 4:04 pm
Contact:

Re: ESP32 power conditioning

Post by ARTaylor » Thu Mar 29, 2018 10:54 pm

I'm looking for the same answer as you capstan - did my usual thing of posting before searching :P I have a 1000mAh lipo battery and at full charge will run my application for 10 hours - I'm using the machine.deepsleep module now and got up to 72 hours - this is the app running for under 10 seconds with 15mins of sleep in between - I expected a bit more?

I have good bench supplies in my lab in work that report current, but I am not back in until the 5th of April - I have a couple Lolin32 lites and Lolin32 pros - happy to run any tests you send my way

my other thread is here with a bit more info: viewtopic.php?f=18&t=4588 but I put an edit in to redirect here...
Grow something!

ARTaylor
Posts: 29
Joined: Fri Mar 23, 2018 4:04 pm
Contact:

Re: ESP32 power conditioning

Post by ARTaylor » Thu Mar 29, 2018 10:57 pm

Capstan wrote:
Fri Mar 23, 2018 3:16 pm
Invoking deepsleep() without having enabled WiFi shows a vastly lower power draw, about .001mA, so maybe the trick is to disable WiFi before entering sleep.
Once I have charged my 1000mAh battery back up I will try this out and report back
Grow something!

Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: ESP32 power conditioning

Post by Capstan » Fri Mar 30, 2018 12:01 am

I did an experiment with a 700 mAH LiFePO4 battery. It is the 14500 form-factor which matches the AA size here in the USA and puts out 3.2 volts.

I wrote a Python program that runs at boot time as main.py. It examines the wakeup reason, does various things that would consume a little power, and sleeps for a while in order to recycle. You can hit control-c to break out of it.

Code: Select all

    cause, reason = machine.wake_reason()
    if cause == 3:  # woke from deep sleep
        # do stuff
        machine.deepsleep(5000)
    elif cause == 6:    # soft reset
        # do other stuff
On my homebrew ESP32 boards I have the input voltage attached to a GPIO/ADC pin through a resistor voltage divider so that I can monitor the status of the input power to some extent. Ideally I would be able to determine when a battery was nearing depletion for example. The program sleep-cycled overnight more than 3,000 times and the input voltage didn't budge. The battery is rechargeable, I put it in the charger and it topped up in under 5 minutes. Encouraging!

Also I am seeing that I have to be more careful with the wiring at this low voltage than I realized (due to inexperience). 3.2V is not very much, and any resistance at all in the power and ground circuitry can starve the ESP32 of current which makes it behave erratically. On my boards I have been using the default trace width for everything and not paying much attention to trace lengths. That is probably okay for logic-level signals, but the default traces are microscopically narrow (makes routing easier). Probably not appropriate for moving a couple-hundred mA at 3.2V. I rearranged my layout to get power input closer to the ESP32 and made the power traces much wider.

ARTaylor
Posts: 29
Joined: Fri Mar 23, 2018 4:04 pm
Contact:

Re: ESP32 power conditioning

Post by ARTaylor » Fri Mar 30, 2018 7:59 am

Capstan wrote:
Fri Mar 30, 2018 12:01 am

Code: Select all

    cause, reason = machine.wake_reason()
    if cause == 3:  # woke from deep sleep
        # do stuff
        machine.deepsleep(5000)
    elif cause == 6:    # soft reset
        # do other stuff
This is a useful snippit, thanks! - I've just got a "debug" pin on my setup at the moment, pull low to prevent loop.
Capstan wrote:
Fri Mar 30, 2018 12:01 am
On my homebrew ESP32 boards I have the input voltage attached to a GPIO/ADC pin through a resistor voltage divider so that I can monitor the status of the input power to some extent. Ideally I would be able to determine when a battery was nearing depletion for example.
I am interested in this as well, I wouldn't mind reporting something that represents battery V to ThingSpeak - but I was worried to try implementing it as I wasn't sure what behaviour you would get once the battery drops too low to power the ESP32 if there is a direct connection (through a resistor) to a pin - what happens if I can't get to the circuit for a couple of days? I am perhaps over thinking it.

I have started a new battery test - ThingSpeak - when the channel stops updating the battery has died or my code has stopped for some other reason :lol:

I am using station.connect(ssid, pass) and station.disconnect() at the moment - not sure if I need to do anything like station.active(false) as well >>> here is my project
Grow something!

Capstan
Posts: 117
Joined: Sun Jan 29, 2017 4:03 pm
Location: Texas, USA

Re: ESP32 power conditioning

Post by Capstan » Fri Mar 30, 2018 2:44 pm

It has been my experience that once you turn on WiFi and then enter deepsleep() you will draw power in the low milli-amps, even if you attempt to turn it back off first with station.active(false). Entering deepsleep shortly after a reset gets you the micro-amp mode. If you have a chance to experiment with this please report what you see.

The firmware has a brownout detector, I think it shuts things down when voltage drops below a critical value, but I was seeing some odd behavior in my experiments where the filesystem could get corrupted before that happens. Reads would result in bad data, and on several occasions I had to reflash the filesystem image. My suspicion is that the flash memory is more susceptible to low voltage or inadequate current supply than the other ESP32 components.

Post Reply