NODEMCU LUA ESP8266 How to Use ADC / TOUT Pin
by JohnL142 in Circuits > Wireless
7748 Views, 17 Favorites, 0 Comments
NODEMCU LUA ESP8266 How to Use ADC / TOUT Pin
The Analogue pin on the ESP8266 can easily be accessed especially on the larger ones where the pin is broken out. The ESP7, ESP12E and ESP201 are good examples of this. On some boards it is identified as ADC or TOUT, it is also known as pin 6 or A0. It has 10 bit precision and its voltage range is between 0 and 1 volt. The 2 resistors (220 and 100 ohm) make a voltage divider in roughly this range. A variable resistor of 1K is used to vary the input voltage. The output from this pin is in the range of 0 to 1024.
Connecting Things Together
To read the ADC / TOUT pin you need to connect things together as in the circuit above.
I am using Esplorer as I find it is about the best of the IDEs that are available at present.
I am assuming you know how to connect your UART and power supply to the ESP8266 board.
Coding
The LUA code is simple for this one. All you have to do is read and print the pin value.
You don't even need to load the program as you can type it straight into Esplorer (as above)
It is even possible to access ADC on an ESP01 See this instructable for more.
Downloads
Conclusion
I have written this instructable for all those who are new to the ESP8266 and LUA programming. I have tried using the Arduino IDE to load programs into the ESP8266, but find that it is very clumsy to use, even when you are used to programming the Arduino.
I am fairly new to this myself and I have spent many hours and days getting nowhere. There is code out there and some of it does work. At times it is very frustrating that nothing seems to work, no matter how hard you try.
It is also a very steep learning curve, even to do the simple stuff until you understand what is going on. Perseverance is the best plan of action and eventually things will start to click into place.
I wish you good luck with what you are doing in the future.