Reading as accurate as possible voltage with ESP32 dev kit lipo

Started by smith, July 27, 2024, 01:41:01 PM

Previous topic - Next topic

smith

I have DevKit-Lipo Rev_C, connected to a single 18650 LiPo cell.
I've soldered BAT_PWR_E1, BAT_SENS_E1 and PWR_SENS_E jumpers.

I read the pins like this:

const int GPI_VOLTAGE_SENS = 39;
const int GPI_POWER_SENS = 36;
....
pinMode(GPI_VOLTAGE_SENS, INPUT);
pinMode(GPI_POWER_SENS, INPUT);
....
const int voltage_sensor_reading = analogReadRaw(voltageSnesorPin);
const int power_present_reading = analogRead (powerSensorPin);

The readings I get are:
If charging:
voltage is between 3000 and 4095
power present is between 200 and 400
If discharging:
voltage is between 310 and 270
power present is 0, occasionally making a single jump to 200

All these numbers vary on different boards.
My question is - what is your recommendation to translate these numbers into as accurate as possible voltage?

LubOlimex

Technical support and documentation manager at Olimex

smith

Ok, It seems that I've been reading the wrong pins.
Apparently for 'DevKitLipo Rev C' voltage pin is 35 and power present pin is 39, I could not figure this out after reading the documentation, thank you for your help.

LubOlimex

Technical support and documentation manager at Olimex

smith

Yes, but also this image:
https://www.olimex.com/Products/IoT/ESP32/ESP32-DevKit-LiPo/resources/ESP32-DevKit-Lipo-GPIOs.png

So I tested several configurations and got confused eventually.
Anyway - thanks for the help, works great now.

LubOlimex

This image looks wrong, better trust the schematic, I will see if I can remake in future since I can't find the source at the moment.
Technical support and documentation manager at Olimex