-->
Page 1 of 2

ESP8266: Handling analog signals without an analog input

PostPosted: Mon Apr 20, 2015 12:05 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: Mon Apr 20, 2015 12:50 pm
by martinayotte
Why using PWM to accomplish an ADC measurement ?
It is simplier to add an ADC using I2C connection such as AD7998, you will get 8 channels analog inputs !

Re: ESP8266: Handling analog signals without an analog input

PostPosted: Mon Apr 20, 2015 1:11 pm
by trackerj
When playing with analog I will suggest you to use a proper ADC/DAC for a decent accuracy.

MCP3421 I2C ADC : http://www.esp8266-projects.com/2015/04/18-bit-adc-mcp3421-i2c-driver-esp8266.html
MCP4726 I2C DAC : http://www.esp8266-projects.com/2015/03/mcp4726-12-bit-i2c-dac-driver-for.html
Pretty accurate DAC, as you can see also from this test: http://www.esp8266-projects.com/2015/03/mcp4726-12-bit-i2c-dac-driver-for_7.html

Re: ESP8266: Handling analog signals without an analog input

PostPosted: Mon Apr 20, 2015 1:39 pm
by martinayotte
Yes ! those MCP* that TrackerJ mentionned are neet since they are in SOT23-6 package.
For ADC, if you don't need much resolution, there is the little 10bits brother, the MCP3021, also an SOT23-6, but much faster, specs says "22.3 ksps in I2C Fast mode" (I just wish that I2C becomes hardware instead of bitbanged)
For multi-channels, Microchip has also in the same family, MCP3008, a 10bits 8 channels, in DIP16, SO16 or TSSOP16.
In other words, it is all depending of your needs ! ;)