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);
}
The schematic shows a voltage divider that should divide the voltage in half.
I've tried several variations found online with no luck getting the correct voltage.