ADC
ESP8266 with ADC Interface
This the simple example of ADC with ESP8266. ESP8266 have a in-build ACD unit with 10 bit resolution(10bits-0 to 1024 steps), so no need to add a external ADC converter ICs. if your beginner try this below codes and understand the ADC with ESP8266. I used Ai-thinger’s ESP-12F module(not used NodeMCU Dev Board) wit USB to UART Programmer and NodeMCU firmware. but you can also use any other firmware like Arduino code, Man-goose OS to do this. In this experiment used 3 NodeMCU module libraries are UART (for printing), Timer(for looping), and ADC Module. So your NodeMCU firmware should have this modules. NodeMCU only support only one ACD pin. ADC bin converts voltage from 0 to 3.3 according to 0- 1024 values(10bit resolution)
- Required Hardware Components : 2x USB to UART converter programmer, 1x ESP8266 Module(Used Ai-Thinker’s ESP-12F module), 1x Variable resistor (Pot-10k)
- Required software tools : ESPlorer IDE Tool,
Note : if you use NodeMCU Dev board don’t need ESP8266 Ai-Thinkers Module and UART Programmer. Because NodeMCU Dev Board have already Programmer.
Circuit Diagram
Code
- EX :tmr.alarm(0,500,1, function printf(adc.read(0)) end)
tmr.alarm
function is like a loop for 500microseconds, So every microseconds once that ESP read the ADC value from that pinprint
function is the same asuart.write(0, adc.read(0).."\n")
the value to terminal windowadc.read
read the ADC value.
Results