ESP32 Feather V2 Batt Monitor wrong voltage

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
djoob
 
Posts: 3
Joined: Mon Jul 04, 2022 12:04 am

ESP32 Feather V2 Batt Monitor wrong voltage

Post by djoob »

I must have my math wrong. I cannot figure out how to read the battery voltage on the ESP32 Feather V2 board.

Code: Select all

#define BAT_MON 35
float measuredvbat = 0;

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

void loop() {
  measuredvbat = analogRead(BAT_MON);
  measuredvbat *= 2;    // we divided by 2, so multiply back
  measuredvbat *= 3.3;  // Multiply by 3.3V, our reference voltage
  measuredvbat /= 4096; // convert to voltage
  Serial.print("VBat: " ); 
  Serial.println(measuredvbat);
  delay(1000);
}
Serial output says. VBat: 3.84 however a multimeter shows the battery voltage is 4.2v

The schematic shows a voltage divider that should divide the voltage in half.

Image

I've tried several variations found online with no luck getting the correct voltage.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32 Feather V2 Batt Monitor wrong voltage

Post by adafruit_support_mike »

The code looks right. What output are you getting?

User avatar
djoob
 
Posts: 3
Joined: Mon Jul 04, 2022 12:04 am

Re: ESP32 Feather V2 Batt Monitor wrong voltage

Post by djoob »

Serial output says:
VBat: 3.84

However, a multimeter shows the battery voltage is 4.2v

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32 Feather V2 Batt Monitor wrong voltage

Post by adafruit_support_mike »

There we go..

The ESP32's ADC has a 3.6V reference. Try using that value instead of 3.3V:

Code: Select all

  measuredvbat *= 3.6;  // Multiply by 3.6V, our reference voltage

User avatar
djoob
 
Posts: 3
Joined: Mon Jul 04, 2022 12:04 am

Re: ESP32 Feather V2 Batt Monitor wrong voltage

Post by djoob »

AH. Thank you!

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”