NodeMCU ADC (A0) correct operation
Posted: Thu Oct 19, 2017 10:58 am
I'm using a NodeMCU in the Arduino IDE.
After a lot of research on google, I came up with the following code to measure the power supply through the ADC (A0 pin).
The result is extremely stable, however, the presenting value should be close to 3.3v
Below is the sequence of some values read:
Voltage: 2.881V
Voltage: 2.883V
Voltage: 2.881V
Voltage: 2.883V
Voltage: 2.883V
Voltage: 2.883V
Voltage: 2.881V
Voltage: 2.882V
Voltage: 2.882V
Voltage: 2.883V
Voltage: 2.882V
Voltage: 2.882V
Once I saw this result, I immediately checked the 3.3v power supply of the kit and to my surprise, it was correct with the exact 3.3v
Dear friends of bench, what is missing or is wrong, and it's causing this wrong value?!?
After a lot of research on google, I came up with the following code to measure the power supply through the ADC (A0 pin).
Code: Select all
ADC_MODE(ADC_VCC); // 3.3v voltage sensor
int vcc;
void setup() {
Serial.begin(115200);
}
void loop() {
vcc = ESP.getVcc();
double dvcc = (float)vcc / 1024;
Serial.println("Voltage: " + String(dvcc, 3) + "V");
delay(500);
}
The result is extremely stable, however, the presenting value should be close to 3.3v
Below is the sequence of some values read:
Voltage: 2.881V
Voltage: 2.883V
Voltage: 2.881V
Voltage: 2.883V
Voltage: 2.883V
Voltage: 2.883V
Voltage: 2.881V
Voltage: 2.882V
Voltage: 2.882V
Voltage: 2.883V
Voltage: 2.882V
Voltage: 2.882V
Once I saw this result, I immediately checked the 3.3v power supply of the kit and to my surprise, it was correct with the exact 3.3v
Dear friends of bench, what is missing or is wrong, and it's causing this wrong value?!?