-->
Page 1 of 1

ESP8266: Handling analog signals without an analog input

PostPosted: Mon Apr 20, 2015 12:04 pm
by hbouzas
Experimenting with the ESP8266 at one point I came across the need of dealing with analog signals. There are a lot of versions of the module and most of them have GPIO accessibility but not ADC access. Some of the lates versions of the module have ADC though, but I have a few modules in stock that do not have it. And I need ADC handling.

Well, it is totally possible and here is how to do it.

There are 4 basic things that need to be done:

    convert the analog signal into pulse width modulation (PWM)
    read the PWM on any GPIO
    read the PWM duty cycle on the ESP8266
    calibrate the PWM to analog level response

I am using NodeMCU Lua API. For more details and a description of the project visit http://www.horaciobouzas.com

Re: ESP8266: Handling analog signals without an analog input

PostPosted: Tue Apr 21, 2015 1:03 pm
by mikewen
Are you sure it can works reliably ?

The timing of NodeMCU Lua is not very accurate.

Re: ESP8266: Handling analog signals without an analog input

PostPosted: Tue Apr 21, 2015 8:48 pm
by martinayotte
Yes, Mikewen is right : If your PWM is not done my hardware, it is useless ...
Even if done in hardware, you will end up to produce PWM output to get analog output, then compare it with a voltage comparator to be read back in software to evaluate your input measurement. Quite tedious process for a simple ADC measurement. Better stick with hardware, such as suggested answers provided in your other thread viewtopic.php?f=6&t=2639.