Most efficient battery setup?

Schematics, Example Code and Q&A
srosti
Posts: 1
Joined: Sat Nov 09, 2019 7:33 am

Most efficient battery setup?

Unread post by srosti »

Anyone have any power efficient battery configurations that they like for an ESP32?

I am using an 18650 usb shield and I only get about 3 days of use out of the esp32. The esp32 will wake up
every 10 minutes and push some data to an mqtt server and then drop into deep sleep. I suspect I'm losing
lots of power on the cheap 18650 shield or maybe even the 18650 batteries are toast. Both are from aliexpress
so who knows how good they are. Unfortunately, I don't have a scope to measure the power draw on the shield
itself when the unit is in deep sleep.

Would a better setup be to use a li-po battery pack with a jst connector directly on the esp32?
gritnix
Posts: 3
Joined: Fri Apr 17, 2020 6:32 am

Re: Most efficient battery setup?

Unread post by gritnix »

Are you still looking for a good low power setup? Hopefully this will help someone in the future.

I've found, with multiple esp32 boards, that pin selection is everything. Some pins, for known reasons, some for unknown reasons, refuse to go into a Hi-Z state when the ESP32 is put into deep sleep. If you use these pins for sensors, you're leaking current without knowing it unless you can measure it. You don't need a scope, you need a multimeter with a uA setting for current. You should be able to get a really good read that way.

What I've found on the EZSBC board is that pins 25-27 and 32-35 are good to use. Stay away from 22 and 21 because they have pull-ups on them for I2C. Pins 2 and 4 are ok, pin 0 is no good, pin 5 is no good. I'll have to meter the others but they're easy to check. Make the board deep sleep and then just measure voltage between a pin and ground. If you're reading a fluctuating mV voltage, all good. If you're reading anything else, like 1.3V or 1.7V or 3.3V, you can't use that pin for anything when sleeping.

One other thing is you'll want to make sure to turn off all of the peripherals before deep sleeping. Turn off wifi, turn off BLE, turn off the ADC.

esp_bluedroid_disable();
esp_bt_controller_disable();
adc_power_off();

Also, turn off the various RTC stuff you don't need:
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF);

If you want to save variables between deep sleeps, you'll need to have that first one on
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_ON);
and put RTC_DATA_ATTR in front of the variable declarations that you want to keep when waking up.

The pins are the key though. I've seen the current use go from low uA (what you should be able to get) up into the low single digit mA, which is 100x change.
gritnix
Posts: 3
Joined: Fri Apr 17, 2020 6:32 am

Re: Most efficient battery setup?

Unread post by gritnix »

One other tip. If you're using I2C, try to get a low current sensor, something no more than in the 20mA range, and try to make it 3V3. Use an IO pin as the Vcc to the sensor. We'll call this the control pin. Don't hook your sensor directly to 3V3. Hook the pull-up resistors for SDA and SCL to this control pin as well. As stated earlier, don't use the SDA/SCL pins defined on the board. If using Arduino IDE, you can still use the Wire library by passing in your SDA and SCL pin numbers to Wire.begin(); In your code, have the I2C work in its own function, not in loop(). This makes sure that the TwoWire destructor gets called since there's no Wire.end(). Every single loop run, call your I2C function (if needed). In that function, set the control pin to output, set it high which powers your sensor and pulls SDA/SCL high through the resistors, make a short delay like 10-20ms, run Wire.begin(SDA,SCL), and do the work with the sensor. Then take your control pin low, essentially cutting off power to the sensor. Then manually set the control pin, your SDA pin, and your SCL pin all to input with pinMode. This last step is very important. All three of the pins you use should follow my previous post, they need to be hi-Z when in deep sleep mode or you'll be leaking when sleeping.

The point is to avoid putting ANYTHING straight to 3V3 or 5V, especially those pull-up resistors. If you have to get a 5V sensor or something that needs more current, you'll need a very low leakage, low quiescent current external component that lets you use a control pin to turn that voltage on and off to the sensor.

I'm using an I2C sensor this way and I'm currently deep sleeping at 16-17uA. I also have a pair of 470K resistors making a voltage divider from Vin to GND that I read with one of the input-only pins so I can check the battery voltage. I've got a 22uF cap on that (10 would prob be enough) to stabilize it. This leaks another ~4.5-5uA which I find acceptable so I'm up at ~22uA.
Daniel
Posts: 133
Joined: Tue Nov 13, 2012 2:10 pm

Re: Most efficient battery setup?

Unread post by Daniel »

Thanks for the very useful information.
Post Reply