When using the internal 1.1V reference voltage, I powered an ESP32 with 5V USB and measured a 1.5V source using one of the ADC inputs, this got me 4095 as the ADC measurement which was expected as 1.5>1.1. However, when powering the ESP32 with a 3.3V battery directly with the 3.3V port, I got an ADC value of ~1600 which is completely wrong. This is the code I used (using Arduino IDE) and the ADC port was GPIO36.
Code: Select all
#include "esp_adc_cal.h"
void setup() {
adc1_config_width(ADC_WIDTH_12Bit);
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_0db); //set reference voltage to internal
}
void loop() {
int adcValue = adc1_get_raw(ADC1_CHANNEL_0);
}