-->
Page 1 of 2

how to read VCC with internal ADC (with NodeMCU v.0.9)

PostPosted: Sun Oct 04, 2015 11:51 am
by pppp33
Hi there,
i found a strange behavior of the internal ADC of my NodeMCU v.0.9 (the yellow one):
after setting:

ADC_MODE(ADC_VCC);

I tried to read VCC:

Serial.printf("Vcc: %d \n",analogRead(A0));

but get always 65535 !

Has anybody got same results ?
Any idea on how to solve/work around this problem ?

Regards

Paolo

Re: how to read VCC with internal ADC (with NodeMCU v.0.9)

PostPosted: Sun Oct 04, 2015 1:29 pm
by bbx10node
pppp33 wrote:
Serial.printf("Vcc: %d \n",analogRead(A0));



Try ESP.getVcc() (no parameter) instead of analogRead().

More details here

https://github.com/esp8266/Arduino/blob ... cific-apis

Re: how to read VCC with internal ADC (with NodeMCU v.0.9)

PostPosted: Sun Oct 04, 2015 2:03 pm
by xtal
Here's a working snip from my Nodemcu LUA , maybe this will help ?

adc_id = 0
adc_val = 512


adc_value = adc.read(adc_id)
if adc_value > 1023 then
adc_value = 1023
elseif adc_value < 0 then
adc_value = 0
end

Re: how to read VCC with internal ADC (with NodeMCU v.0.9)

PostPosted: Thu May 19, 2016 11:46 am
by Eze Z
I would like to do the following:

First read Internal VCC (get_vcc) and then continue reading an Analog Input with ReadAnalog. This would require me to have a pin connected to A0.

How can i achieve this?