void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
//set the resolution to 12 bits (0-4096)
analogReadResolution(10);
}
void loop() {
// read the analog / millivolts value for pin 2:
int analogValue = analogRead(2);
int analogVolts = analogReadMilliVolts(2);
// print out the values you read:
Serial.printf("ADC analog value = %d\n",analogValue);
Serial.printf("ADC millivolts value = %d\n",analogVolts);
delay(1000); // delay in between reads for clear read from serial
}
I had that simple code, i wat to sense the Volts of a solar panel. In and Out.
I let you a log to see my problem
ADC millivolts value = 2269
ADC analog value = 1023
ADC millivolts value = 2295
ADC analog value = 647
ADC millivolts value = 2233
ADC analog value = 635
ADC millivolts value = 2009
ADC analog value = 645
ADC millivolts value = 2226
ADC analog value = 635
ADC millivolts value = 2262
ADC analog value = 650
ADC millivolts value = 2305
ADC analog value = 652
ADC millivolts value = 2249
ADC analog value = 652
I nedd to sense form 24V to 19V aprox.
I make a this circuit (voltage divider)
And the problem is the precision of analog Input of ESP32. It var from 600 to 652, it's imposible make a measure with this numbers.
I check the input and it's constant, I use a regulated power supply, and a battery, then a put a filter. It's look like the problem is the input of ESP32. All of them are equals? May be this is a bad quality ESP32?