The problem is that despite the supply into the top of the voltage divider being 3.7V, the multimeter shows 2.85V at GPIO 2. The code below returns a saturated value of 4095. I was expecting to see 1.85V at GPIO2 and an ADC reading of around 3000.
I'm using the latest platformio core for the build.
- const uint8_t BATTERY_ADC_PIN = GPIO_NUM_2;
- pinMode(GPIO_NUM_2, INPUT); // disable pullup/down resistors
- analogReadResolution(12); // 12 bit sample width (default)
- analogSetPinAttenuation(BATTERY_ADC_PIN, ADC_11db); // 0-2.45V range for ESP32-C3 (default)
- uint16_t adcVal = analogRead(BATTERY_ADC_PIN);