Site icon Renzo Mischianti

Lithium battery check with ESP32: voltage divider problem

Hi Renzo, This is off-topic but I don't know where else to turn. I want to monitor the battery voltage of this LoRa node. My understanding is that the Li-ion batteries charge at 4.2v so I'm sending that max voltage through a voltage divider to a (3.3v) ADC pin on the ESP32. Strangely (to me) the ADC is returning 4095 always, no matter what the source voltage is. Can you see what I'm doing wrongly? Thanks. `int ADCvalue; const int ADC = 25; // battery voltage pin void setup() { // put your setup code here, to run once: Serial.begin(9600); delay(500); pinMode(ADC, INPUT); pinMode(ADC, INPUT_PULLDOWN); } void loop() { ADCvalue = analogRead(ADC); Serial.print(ADCvalue); Serial.print(" "); float batVoltage = ADCvalue * 4.2 / 4096; // get battery voltage Serial.println(batVoltage); delay(1000); }'
Exit mobile version