-->
Page 1 of 1

ADC value not changing

PostPosted: Thu Feb 14, 2019 11:30 am
by james.willetts
Hi All can you help? when I read the ADC pin on all of my ESP8266 8 pin boards I get a reading of 36 to 40 regardless of the input voltage on gpio 0
I have re uploaded the firmware numerous times including using modeMCU custom build by frightanic.com and still get the same results I've tried a different batch of chips in case the ones I have are bum. I'm at ripping my hair out point! I have tried the following code.

-- in you init.lua:
if adc.force_init_mode(adc.INIT_ADC)
then
node.restart()
return -- don't bother continuing, the restart is scheduled
end


print("System voltage (mV):", adc.read(0))
print("System voltage (mV):", adc.read(0))
print("System voltage (mV):", adc.read(0))
print("System voltage (mV):", adc.read(0))
print("System voltage (mV):", adc.read(0))
print("System voltage (mV):", adc.read(0))
print("System voltage (mV):", adc.read(0))

Answer:
System voltage (mV): 36
System voltage (mV): 36
System voltage (mV): 36
System voltage (mV): 36
System voltage (mV): 36

If I change to
-- in you init.lua:
if adc.force_init_mode(adc.INIT_vdd33)
then
node.restart()
return -- don't bother continuing, the restart is scheduled
end
print("System voltage (mV):", adc.readvdd33(0))
print("System voltage (mV):", adc.readvdd33(0))
print("System voltage (mV):", adc.readvdd33(0))

Answer:
System voltage (mV): 3423
System voltage (mV): 3420
System voltage (mV): 3418

I've tried;
Rebooting then trying a read adc
new chips
adding a 2 amp 3.3 volt psu
all joints are soldered so no bread board faults
Has anyone had this before?

Any help much appreciated

Re: ADC value not changing

PostPosted: Sat Feb 16, 2019 5:55 am
by schufti
there is only one analog input on nodemcu and it is definitely not D0 or gpio0.
It is the pin marked A0 (see bottom right corner on attached picture)

Re: ADC value not changing

PostPosted: Mon Feb 18, 2019 8:16 am
by james.willetts
schufti wrote:there is only one analog input on nodemcu and it is definitely not D0 or gpio0.
It is the pin marked A0 (see bottom right corner on attached picture)


Thank you, It was a bit confusing in the mode MCU documentation it was saying read 0 which i had confused gpio0 with ADC 0. I am using the 8 pin board with only gpio 0 and gpio 1 available hence why i didn't see the ADC pin. I have a pin out of the IC and have added a wire to the ADC pin and all is well

Many thanks
James