Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADC receiving 1024 #2864

Closed
beckmx opened this issue Jul 29, 2019 · 4 comments
Closed

ADC receiving 1024 #2864

beckmx opened this issue Jul 29, 2019 · 4 comments

Comments

@beckmx
Copy link

beckmx commented Jul 29, 2019

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: 68c425c
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
Copy link

KT819GM commented Aug 12, 2019

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

@ildar
Copy link

ildar commented Aug 12, 2019 via email

@jmd13391
Copy link

jmd13391 commented Aug 12, 2019

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

  • Many / Most ESP8266 development boards come equipped with an on-board 1% tolerance voltage divider connected between the ESP8266 module and the board's ADC input pin (A0). This built-in voltage divider increases the 1.0 volt max of the ESP8266 module's ADC to 3.3 volts... i.e. an adc.read(0) with 3.3 volts connected to the board's pin A0 will return a value of 1023.

  • An adc.read(0) value of 1024 indicates a voltage out-of-range condition (i.e. > 3.3v). Remember: there is a +/-1% tolerance with the built-in dev board A0 pin voltage divider (if that's what you're using).

  • Use of the ESP8266's built-in ADC should be limited to applications that do not require accurate or stable readings... this is because the ESP8266's ADC is neither (IMO, it sucks). This accuracy / stability issue is the result of an internal design flaw in the ESP8266 chip (it is most noticeable during times of WiFi activity). The accuracy / stability issue can be somewhat mitigated with exponential moving window and medians algorithms but it cannot be complete eliminated. Consider using an external ADC like the ADS1115 or ADS1015.

@beckmx
Copy link
Author

beckmx commented Aug 12, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants