-->
Page 1 of 1

NodeMCU and analogRead(A0)

PostPosted: Sun Jul 16, 2017 5:17 am
by lesept
OK, I'm a noob. This is said. And also not native english speaker.
I have a NodeMCU 0.9 that I program using the Arduino IDE. I try to read a voltage using the ADC, but it doesn't work.

I connect a potentiometer between 3V3, GND and the A0 pin, and use this program:

Code: Select allADC_MODE(ADC_VCC);
int val = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  val = analogRead(A0);
  Serial.println(val);
}


All I get on the console is 65536, whatever the value of the resistor. What's going wrong?
Thanks for your help. :mrgreen:

Re: NodeMCU and analogRead(A0)

PostPosted: Tue Jul 18, 2017 6:23 pm
by gbafamily1

Re: NodeMCU and analogRead(A0)

PostPosted: Wed Jul 19, 2017 1:53 am
by lesept
Thanks. I tried this already. The value was always around 4 to 7, very low compared to the range, even for voltage near 0.5V or 1V