+BAT -> A0 of ESP32. Common Grounds.
Code: Select all
const int analogPin = A0;
void setup() {
Serial.begin(115200);
//only measure during bootup, works for our use case
int batteryValue = analogRead(analogPin);
float batteryVoltage = batteryValue * (3.3 / 4095.0); // Convert ADC value to voltage
Serial.print("Battery Voltage: ");
Serial.println(batteryVoltage);
// Configure analog pin as input with no pull-up or pull-down -- will this do it to essentially disconnect the battery from ESP32?
pinMode(analogPin, INPUT);
}
void loop() {
// Additional code here...
delay(30000); // Just for demonstration, adjust as needed
}
Any thoughts?