ESP32-DevKit-Lipo Power Switch

Started by wezzer, July 25, 2025, 09:11:55 PM

Previous topic - Next topic

wezzer

I have a new ESP32-DevKit-Lipo and 3-7v 1200mAh LiPo battery. I need to be able to power down the device I am building when not in use.

Am I able to insert a simple latching switch into the positive lead of the battery so that if the USB power supply cable is disconnected the switch will control whether the processor is on or off ?

I accept that the new switch will need to be on in order to recharge the LiPo battery when the unit is powered from the USB lead.

Are there any issues that I have overlooked in this instance ?

Kind Regards

Wezzer

LubOlimex

#1
You don't need extra circuitry friend. There is battery measurement and external power sense built in the design. They are disabled by default to free pins but you can enable them if you solder together a couple of jumpers. Download the schematic and find "Battery Measurement" and "External Power Sense" in the top left corner:

https://github.com/OLIMEX/ESP32-DevKit-LiPo/blob/master/HARDWARE/ESP32-DevKit-LiPo-Rev.D/ESP32-DevKit-Lipo_Rev_D.pdf

Close SMT jumpers PWR_SENS_E1, BAT_PWR_E1, BAT_SENS_E1. Then you have battery measurement on GPI35, and external power sense on GPI39. This is Arduino code to see results:

//demonstration for power sense and battery sense
//for most Olimex boards
//for other boards you might need to change pins in define
//some other boards might require hardware adjustments to
//enable power sense or/and battery sense

#define POWER_SENSE 39
#define BATTERY 35

void setup()
{
  Serial.begin (115200);
  pinMode (POWER_SENSE, INPUT);
  pinMode (BATTERY, INPUT);
}

void loop()
{
  Serial.print ("External power sense: ");
  Serial.println (digitalRead (POWER_SENSE));

  Serial.print ("Battery measurement: ");
  Serial.print (analogReadMilliVolts (BATTERY)*2);
  Serial.println (" mV");

  Serial.println ();

  delay (250);
}

Let me know if you have questions about the jumpers and how to get them working.
Technical support and documentation manager at Olimex

wezzer

Hi. Thank you for responding.

I was probably not expressing very clearly what I was trying to achieve, I am building a device that has the ESP32-DevKit-Lipo at its core. It has an external usb power supply which will be connected only when required to charge the LiPo battery.

As this unit will be used for a few hours at a time and then put away I am hoping to charge the LiPo battery whilst connected to the usb after the device has been used and then remove the usb connection leaving the battery fully charged for the next use which will be away from any external power source.

I have very little experience of using LiPo batteries and so wanted to know whether by inseting an latching switch in the LiPo positive lead I could turn the ESP32 off in storage and so keep the LiPo battery fully charged ready for the unit's next use.

As stated before, I accept that the new switch will need to be on in order to recharge the LiPo battery when the unit is powered from the USB lead.

This unit may well be left off for a number of weeks between uses.

Thanks for your help,

Wezzer

LubOlimex

Sure you can do that, it is just not very elegant and no way to tell when battery is charged. Using the external power sense and battery measurement you can have some feedback on what is connected when and when battery is going empty or full then trigger events.
Technical support and documentation manager at Olimex