Hello everybody. I want to use the ESP822 OLED Display to read a voltage from the A0 pin and then show it on the built-in display. According to ChatGPT this pin supports voltages from 0 to 3.3 V so in the lab with a power supply I have been introducing voltages to that pin within that range, but no measurement matches. I have made sure by checking the voltage coming out of the power supply with a multimeter and it is correct, only the A0 pin is reading incorrectly. For example, I'm applying 1.2 V and in the serial window of the Arduino IDE it is showing 2.032 V. I wonder if anyone has had the same problem and managed to solve it. Thank you very much, I look forward to your reply.
No. The ADC in ESP8266 is not the best, but good enough for, for example, monitoring battery voltage.
The ADC does not measure voltage directly. It gives a result which is a number between 0 and 1023. It's up to your code to calculate a voltage from that. So the problem may be in your code, which you didn't share.
Always double-check anything ChatGPT tells you against some other, more authoritative source.
You think using ChatGPT saves you time? It does if you don't double-check what it tells you.
Most NodeMCU boards will measure up to 3.2V, not 3.3V, so there's one possible source of error in the voltage you are reading.
The ESP chip's ADC measures voltages up to 1.0V. NodeMCU board has a built-in voltage divider consisting of 100K and 220K between the external ADC pin and the chip's ADC pin. 1.0V / 100K * (100K+220K) = 3.2V
Sorry about that, the purpose is to show the consumption of the system coming from an instrumentation amplifier on the display. I didn't mention it, but in the code I adapted the 3.2 V which I did check. About the integrated resistive divider ChatGPT also mentioned it. Here is the code:
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("=== Comienza la lectura del ADC ===");
}
void loop() {
// put your main code here, to run repeatedly:
int adcVal = analogRead(A0);
float voltage = adcVal * (3.2 / 1023.0);
Serial.print("ADC: ");
Serial.print(adcVal);
Serial.print(" | Real voltage: ");
Serial.print(voltage, 3);
Serial.println(" V");
delay(1000);
}
The code looks ok.
Have you measured the voltage at the ADC0 pin of the ESP module itself?
Take care not to short anything with your multimeter probes while doing this.
With 1.2V input, the voltage divider should reduce this to 1.2V / (100K+220K) * 100K = 0.375V at the ADC0 pin.
If not, disconnect everything and use your multimeter to measure the resistance between the NodeMCU's A0 pin and the ESP chip's ADC0 pin. Then measure resistance from ADC0 pin to ground.
Use these measurements to calculate the actual upper limit for the voltages that can be measured. Replace the 3.2 value in your code with that value and re-test.
If you can now measure voltages reasonably accurately but you need a higher limit, you can add an extra resistor in series with the A0 pin.
If none of these suggestions give you voltages that are accurate enough for your project, I would suggest an ADS1115 external ADC module.
Thank you in advance. I will try all the points you have told me and I will update you over time. Again, thanks for your time.
Your topic was moved to its current location as it is more suitable.
Could you also take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Thank you
Did anyone try to read VCC of the ESP8266 internally.
With ESP.getVcc()
Leo..
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.

