nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32
https://nodemcu.readthedocs.io
MIT License
7.64k stars 3.12k forks source link

ADC receiving 1024 #2864

Closed beckmx closed 5 years ago

beckmx commented 5 years ago

Make sure you read and understand http://nodemcu.readthedocs.io/en/dev/en/support/. Use one of the two templates below and DELETE THE REST.

8<------------------------ BUG REPORT -----------------------------------------

Expected behavior

Get readings of a voltage devider with GND and 3.3

Actual behavior

ADC reading shows only 1024

Test code

Provide a Minimal, Complete, and Verifiable example which will reproduce the problem.

if adc.force_init_mode(adc.INIT_ADC)
then
  node.restart()
  return -- don't bother continuing, the restart is scheduled
end
print(adc.read(0))

NodeMCU version

Which branch are you on? If you know the Git revision then add it here as well. branch: master commit: 68c425c0451f72fcabb1b2d6d31a8555f087371b SSL: false modules: adc,bit,cron,file,gpio,mdns,net,node,pwm,sjson,spi,tmr,uart,wifi

Hardware

Describe which ESP8266 device you use and document any special hardware setup required to reproduce the problem. ESP12E single module

KT819GM commented 5 years ago

As your example is working with at least latest master branch (as of 2019 08 12), you should consider checking hardware part.

ildar commented 5 years ago

BTW note that max voltage shown by ADC is 1.0 V

jmd13391 commented 5 years ago

IMO, this is not a firmware issue nor is it an application developer issue...

beckmx commented 5 years ago

Actually, after a carefull read, I realized that the nodemcu and wemos board uses internal voltage dividers (resistors), and I created my own module without including those, so, my mistake, after creating my own voltage divider I could see the values