Thanks, Mike, but yeah, even when I change my ADC_BATTERY #define to 35, I get the same result. The below code prints:
rawADC value (from pin 35): 2427.00, Current battery voltage : 4.85
Code: Select all
#define ADC_BATTERY 35
//=================================================
// getBatteryLevelAsPct()
// Gets the current battery charge level as a percentage.
//
uint8_t REBatteryHuzzahFeather32V2::getBatteryLevelAsPct()
{
uint8_t retVal = 0;
float rawADC = analogReadMilliVolts(ADC_BATTERY); //the value obtained directly at the battery pin (which half of a voltage divider circuit, and in mV)
float currentVoltage = (rawADC * 2.0)/1000.0; // Since our reading is half the voltage, and in mV, double the value and divide by 1000 to get voltage.
String batteryStatus = "rawADC value (from pin " + String(ADC_BATTERY) + "): " + String(rawADC) + ", Current battery voltage : " + String(currentVoltage);
Serial.println(batteryStatus);
[code to determine battery charge as pct]
return(retVal);
}
Correct me if I'm wrong (very possible), but even if the divider circuit is different, with no battery connected, I expect my rawADC value to be ~0. Or, is the 2427 (+/-) value I'm receiving from analogReadMilliVolts([battery pin]) supposed to translate to ~0 somehow?
Btw, the Feather V2 example code under
Measuring Battery is what I saw prior to posting that made me wonder if the pin changed for Feather ESP32 V2 but Adafruit forgot to update in some places.
Thanks again Mike for your thoughts and time. I still must be either doing something wrong, or interpreting something incorrectly.
-BoulderFish
mikeysklar wrote: Sun Jan 19, 2025 2:19 pm
Try the Feather V2 example code under
Measuring Battery. It is using A13 still. Maybe the resistor divider circuit is different?
Code: Select all
// Arduino Example Code snippet
#define VBATPIN A13
float measuredvbat = analogReadMilliVolts(VBATPIN);
measuredvbat *= 2; // we divided by 2, so multiply back
measuredvbat /= 1000; // convert to volts!
Serial.print("VBat: " ); Serial.println(measuredvbat);
The Voltage Monitor pin GPI35 is mapped to A13 in the pins_arduino.h file.
Code: Select all
sklarm@grazie adafruit_feather_esp32_v2 % pwd
/Users/sklarm/Library/Arduino15/packages/esp32/hardware/esp32/3.1.1/variants/adafruit_feather_esp32_v2
sklarm@grazie adafruit_feather_esp32_v2 % grep "A13\|35" pins_arduino.h
static const uint8_t A13 = 35;
#define BATT_MONITOR 35
Screenshot 2025-01-19 at 10.18.00 AM.png