LED control using ESP8266 | blog.hackshade.com
Well said by someone, “Go with the flow…”
Hackshade brings the basic IoT tutorial for all electronics geeks. This is clean, cheap in cost & best for beginners in IoT. Here will use “HTTP Headers” to establish connection between ESP8266 Module & Web Server.
The basic requirements for this project is listed as follows:-
- Arduino IDE
- Jumper Wires & LED
- ESP8266 WiFi Module
- USB-TTL Converter (5v-3.3v)
- Power Source (3.3v DC)
- Web Server (If not, you can use ours..!)
- Wireless Internet Connection (WiFi)
What is ESP8266?
ESP8266 is a low-cost WiFi module with full TCP/IP stack and Microcontroller Unit capability manufactured by Espressif Systems of China. ESP series have 4 versions such as ESP-01, ESP-05, ESP-12 & ESP-201, they all differ only in the sense of I/O pin features & dimensions.
In this project, we will work with ESP-01, which is the basic WiFi module & cheap in cost with two GPIO pins.
What is Arduino IDE?
Arduino is a development platform for beginners in electronics. It is compact, easy-to-code & widely used across world for basic prototyping & embedded systems projects.
IoT can be worked out with Raspberry Pi, NODEMCU & other platform too. But, ESP8266 is best for this project because it is small, least complex, Arduino compatible & the only disadvantage is that ‘It is not breadboard friendly’ So, if you are using with breadboard, you need to make a PCB for that. While using with NODEMCU, ESP8266 is needed to be flashed & one needs to learn LUA language to code it. LUA is a programming language which is use in web development & it is similar to Arduino in case of syntax.
Let us get familiar with Arduino Setup for this project :-
- Visit this link ( https://goo.gl/GFtnQc ) & download Arduino IDE
- Install Arduino IDE on your Windows/LINUX system
- Open Arduino IDE & Click on tab File>Preferences
- Now add the following URL in the Additional Board Manager URLs field & click OK.
- URL :- http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Open the tab Tools>Boards>Board Manager
- Search for esp8266 & install the esp8266 community packages
- Now go to Tools>Boards & select Generic ESP8266 Module
- Open Sketch>Library>Manage Libraries
- search for arduinojson & install arduinojson library by Benoît Blanchon
We have done with setting up Arduino IDE for our first Internet of Things project 🙂
Lets prepare ESP8266 for our circuit:-
- Connect USB-TTL 3.3V to ESP8266 VCC & CH_PD
- Connect ESP8266 RX to USB-TTL TX & ESP8266 TX to USB-TTL RX
- Connect ESP8266 GND to USB-TTL GND
- Connect LED to GPIO 2 & GND
- Connect GPIO 0 to GND (ONLY DURING SKETCH UPLOADING)
Now our circuit is also ready 🙂
Plug the USB-TTL to your laptop/PC & select the port at Tools>Ports>COM1/2/3/4/5..
Finally now we are all setup for uploading our sketch to Arduino IDE !!
Here is the Sketch :- https://drive.google.com/open?id=0Byaw-XET9kbDVW0tRUFqYUpRNWc
Now, just copy the above code completely to Arduino IDE & edit the stuffs: WIFI NAME, WIFI PASSWORD, DOMAIN NAME & PATH TO LIGHT.JSON.
Compile the sketch & upload to ESP8266 Generic Module.
Now our prototype is ready..!
- Just download & copy this files to your web server
- Link:- https://drive.google.com/open?id=0Byaw-XET9kbDbi1pQnhJRHI0TDg
- If you do not have a web server, Visit: http://www.hackshade.com/IoT
- And don’t forget to change the code with :-
- DOMAIN NAME: www.hackshade.com & Path to light.json: /IoT/light.json
- Now visit your webpage or visit: http://www.hackshade.com/IoT/
- & Press the buttons to light up the LED 🙂
- You can also see Serial Monitor for the back-end reports…
NOTE :- ESP8266 is quite unstable & one need to have patience.
DIY to make this excellent trick working. We hope you like or blog & will support us in moving forward because “Every View Counts…”