ESP 01 Programming Made easy | Arduino IDE | USB to UART CH340 Tutorial | IOT first step
ESP 01 First Step
ESP 01 Module arguably the cheapest and easiest module out there for all IOT beginners. Since its inception in 2014 it has gained popularity in electronic enthusiasts for the wifi capability. Its perhaps the smallest micro controller i have used for all my hobby projects.
I have seen various tutorials on how to program ESP 01 using bread board, multiple adapters. The one described below is what helped me over years which i feel is worth the extra cost.
Things needed
Hardware requirements
1. Two USB to UART CH340 adapters (Will discuss why i need two in a while)
2. ESP 01 chip
Software requirements
1. Preinstalled Arduino IDE (Download from here) and complete ESP8266 setup. (Refer to section ESP8266 setup at the bottom)
Hardware setup
ESP 01 needs GPIO0/IO0 pin to be GND for flashing code. I would suggest have a dedicated adapter for flashing code and another for debugging. Alternatively you can work with a single adapter having a push button between IO0 and GND. Having used two adapters for 2 years with ease i feel the extra cost is worth it.
We will use the Blink example already provided in Arduino IDE and make few changes which will help us see messages in serial monitor
Steps
1. Go to File -> Examples -> ESP8266 -> Blink
2. Add following lines to the example to help us see messages in serial monitor
Serial.begin(115200); // inside setup
Serial.println("ESP LED turned ON. Waiting for a sec......"); // after setting LED on
Serial.println("ESP LED turned OFF. Waiting for 2 secs......");// after setting LED off
Post modifications your code will look similar like below
4. In Arduino IDE,
Select Tools -> Board -> ESP 8266 Boards -> Generic ESP 8266 Module
Select Tools -> Port -> /dev/ttyCH341USB0 (port on my device, yours can vary)
5. Now compile and upload
6. Take out the ESP 01 from USB UART and insert it in other adapter for which IO0 and GND are not connected.
7. Insert this adapter in USB port of your device
8. In Arduino IDE, select Tools -> Serial monitor. Ensure that you have 115200 as baud rate selected in serial monitor same as that configured in code.
In later tutorials we will learn on using Wifi capability of ESP 01 to turn on a Led strip using 5V relay switch.
Troubleshooting
1. If your device is not able to detect USB to UART CH340 Adapter. Please install drivers from here.
ESP 8266 Setup in Arduino IDE
1. In Arduino IDE, Go to File -> Preferences. In "Additional Boards Manager Urls" add http://arduino.esp8266.com/stable/package_esp8266com_index.json.
2. Go to Tools -> Board -> Board Manager, search for esp8266 and install it.
Comments
Post a Comment