ESP 8266 Wifi Controlled Home Automation
by geekrex in Circuits > Arduino
161215 Views, 697 Favorites, 0 Comments
ESP 8266 Wifi Controlled Home Automation
![IMG_2646e.jpg](/proxy/?url=https://content.instructables.com/F0X/MXFD/INOW2YQW/F0XMXFDINOW2YQW.jpg&filename=IMG_2646e.jpg)
![IMG_2666.JPG](/proxy/?url=https://content.instructables.com/FTF/3WKD/INNGNQXK/FTF3WKDINNGNQXK.jpg&filename=IMG_2666.JPG)
![IMG_2671.JPG](/proxy/?url=https://content.instructables.com/F6X/AZJG/INNGNR2Y/F6XAZJGINNGNR2Y.jpg&filename=IMG_2671.JPG)
![IMG_2674.JPG](/proxy/?url=https://content.instructables.com/FYQ/Y0LC/INNGNUHO/FYQY0LCINNGNUHO.jpg&filename=IMG_2674.JPG)
![IMG_2675.JPG](/proxy/?url=https://content.instructables.com/FM8/RY4A/INNGNUI7/FM8RY4AINNGNUI7.jpg&filename=IMG_2675.JPG)
ESP8266 is a great thing for starting to Wifi And IOT
It is also cheap and be used for making cool projects connected to the Internet .Learn how to make a simple IOT Project with it .The ESP8266 WiFi Module is a self contained SOC with integrated TCP/IP protocol stack that can give any microcontroller access to your WiFi network. The ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor. Each ESP8266 module comes pre-programmed with an AT command set firmware, meaning, you can simply hook this up to your Arduino device and get about as much WiFi-ability as a WiFi Shield offers (and that’s just out of the box)! The ESP8266 module is an extremely cost effective board with a huge, and ever growing, community.
Update : I made a iot home control box to control home appliances
Components and Connection
![IMG_2663.JPG](/proxy/?url=https://content.instructables.com/FCJ/BC14/INNGNQV7/FCJBC14INNGNQV7.jpg&filename=IMG_2663.JPG)
![IMG_2669.JPG](/proxy/?url=https://content.instructables.com/FRF/8F8N/INNGNR0P/FRF8F8NINNGNR0P.jpg&filename=IMG_2669.JPG)
![IMG_2670.JPG](/proxy/?url=https://content.instructables.com/F7Y/UARN/INNGNR1K/F7YUARNINNGNR1K.jpg&filename=IMG_2670.JPG)
![IMG_2682.JPG](/proxy/?url=https://content.instructables.com/F6S/KOY1/INNGNUIG/F6SKOY1INNGNUIG.jpg&filename=IMG_2682.JPG)
![IMG_2661.JPG](/proxy/?url=https://content.instructables.com/FQA/6805/INM7PEAL/FQA6805INM7PEAL.jpg&filename=IMG_2661.JPG)
![IMG_2660.JPG](/proxy/?url=https://content.instructables.com/FLV/JQHL/INM7PECS/FLVJQHLINM7PECS.jpg&filename=IMG_2660.JPG)
![images (1).jpg](/proxy/?url=https://content.instructables.com/F7J/Q7MS/INM7P9FD/F7JQ7MSINM7P9FD.jpg&filename=images (1).jpg)
Making the Esp 8266 Bread Board Friendly
![IMG_2648.JPG](/proxy/?url=https://content.instructables.com/FO0/0L0Q/INM7P9H8/FO00L0QINM7P9H8.jpg&filename=IMG_2648.JPG)
![IMG_2647.JPG](/proxy/?url=https://content.instructables.com/FXD/Y1PL/INM7P9GB/FXDY1PLINM7P9GB.jpg&filename=IMG_2647.JPG)
![IMG_2664.JPG](/proxy/?url=https://content.instructables.com/F29/TXQ0/INNGNQVH/F29TXQ0INNGNQVH.jpg&filename=IMG_2664.JPG)
![ESP8266_bb.jpg](/proxy/?url=https://content.instructables.com/FMG/B70Y/INM7PA4M/FMGB70YINM7PA4M.jpg&filename=ESP8266_bb.jpg)
![IMG_2667.JPG](/proxy/?url=https://content.instructables.com/FKH/SP3W/INNGNQYJ/FKHSP3WINNGNQYJ.jpg&filename=IMG_2667.JPG)
![IMG_2681.JPG](/proxy/?url=https://content.instructables.com/FMS/0QMF/INNGNUIB/FMS0QMFINNGNUIB.jpg&filename=IMG_2681.JPG)
Esp 8266 esp 1 is badly famous for being rude to the Bread board .
Here is a small hack to make it convert into a DIP pack.
You only want a 4x 4holes perf section with 4 rows of copper track of length four holes.
see the photos and you'd understand what I mean by that.
Cut two Strips of 4 Male Header pins each.
Cut two Strips of 4 Female Header pins each.
Push the 4-Pin Female header pins
Solder the Female Header (4-Pins each)
Push the 4 pin male all the way down until they are invisible in one side of the plastic frame.
Solder the male Header (4-Pins each) and join female together with it
Connections
Vcc and ch_pd to vcc
Gnd to gnd
Rst to button 1
GPIO0 to button 2
Note While uploading Program press reset once while holding GPIO Button as long as the program uploads
Setting Up the Arduino Environment
![Fritzing 01-May-16 23133 AM.bmp](/proxy/?url=https://content.instructables.com/FGL/2HP7/INM7P7D3/FGL2HP7INM7P7D3.bmp&filename=Fritzing 01-May-16 23133 AM.bmp)
![Fritzing 01-May-16 23213 AM.bmp](/proxy/?url=https://content.instructables.com/FOS/0FA8/INM7P7DM/FOS0FA8INM7P7DM.bmp&filename=Fritzing 01-May-16 23213 AM.bmp)
![Fritzing 01-May-16 23235 AM.bmp](/proxy/?url=https://content.instructables.com/F5X/E481/INM7P7E5/F5XE481INM7P7E5.bmp&filename=Fritzing 01-May-16 23235 AM.bmp)
![Fritzing 01-May-16 24459 AM.bmp](/proxy/?url=https://content.instructables.com/FHC/XEGA/INM7P7IU/FHCXEGAINM7P7IU.bmp&filename=Fritzing 01-May-16 24459 AM.bmp)
You need to download the core if your Arduino is below 1.6
https://github.com/esp8266/Arduino
Installing with Boards Manager for Arduino
Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32 and 64 bit).
- Install Arduino 1.6.8 from the Arduino website.Start Arduino and open Preferences window.
- Enter http://arduino.esp8266.com/stable/package_esp8266... into Additional Board Manager URLs field.
- You can add multiple URLs, separating them with commas.
- Open Boards Manager from Tools > Board menu and install esp8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).
Boards manager link: http://arduino.esp8266.com/stable/package_esp8266...
Trying the Blink Sketch
![ESP8266_bb.jpg](/proxy/?url=https://content.instructables.com/F21/9ZGG/INM7PBFC/F219ZGGINM7PBFC.jpg&filename=ESP8266_bb.jpg)
![Fritzing 01-May-16 40308 AM.bmp](/proxy/?url=https://content.instructables.com/FFQ/3S2K/INM7PCBG/FFQ3S2KINM7PCBG.bmp&filename=Fritzing 01-May-16 40308 AM.bmp)
![GM_20160501_40535.gif](/proxy/?url=https://content.instructables.com/FNH/MJBO/INM7PB3B/FNHMJBOINM7PB3B.gif&filename=GM_20160501_40535.gif)
![IMG_2670.JPG](/proxy/?url=https://content.instructables.com/FZZ/BHFM/INNGNUFG/FZZBHFMINNGNUFG.jpg&filename=IMG_2670.JPG)
![IMG_20160501_045748.jpg](/proxy/?url=https://content.instructables.com/F8S/LCMK/INM7PND9/F8SLCMKINM7PND9.jpg&filename=IMG_20160501_045748.jpg)
Connections
The led is connected to the GPIO 2
Tx is connected to Rx
Rx is connected to Tx
Vcc to 3.3v
gnd to gnd
Ch_pd to 3.3v
GPIO 0 to gnd while programing
int ledPin=2; void setup() { pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
Making a Web Controlled Home Automation
![Fritzing 01-May-16 42704 AM.bmp](/proxy/?url=https://content.instructables.com/F0Y/CDX1/INM7PGNW/F0YCDX1INM7PGNW.bmp&filename=Fritzing 01-May-16 42704 AM.bmp)
![Fritzing 01-May-16 42306 AM.bmp](/proxy/?url=https://content.instructables.com/F2H/5HWR/INM7PGWT/F2H5HWRINM7PGWT.bmp&filename=Fritzing 01-May-16 42306 AM.bmp)
![IMG_2672.JPG](/proxy/?url=https://content.instructables.com/FHW/5MLA/INNGNUGS/FHW5MLAINNGNUGS.jpg&filename=IMG_2672.JPG)
![IMG_2673.JPG](/proxy/?url=https://content.instructables.com/FD0/A0SR/INNGNUH7/FD0A0SRINNGNUH7.jpg&filename=IMG_2673.JPG)
Connections
The led is connected to the GPIO 2
Tx is connected to Rx
Rx is connected to Tx
Vcc to 3.3v gnd to gnd
Ch_pd to 3.3v
GPIO 0 to gnd while programing
<p>#include <ESP8266WiFi.h><br></p><p>const char* ssid = "dlink"; const char* password = "ilovechips";</p><p>int ledPin = 2; // GPIO2 WiFiServer server(80);</p><p>void setup() { Serial.begin(115200); delay(10);</p><p>pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW);</p><p>// Connect to WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid);</p><p>WiFi.begin(ssid, password);</p><p>while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected");</p><p>// Start the server server.begin(); Serial.println("Server started");</p><p>// Print the IP address Serial.print("Use this URL to connect: "); Serial.print("http://"); Serial.print(WiFi.localIP()); Serial.println("/");</p><p>}</p><p>void loop() { // Check if a client has connected WiFiClient client = server.available(); if (!client) { return; }</p><p>// Wait until the client sends some data Serial.println("new client"); while(!client.available()){ delay(1); }</p><p>// Read the first line of the request String request = client.readStringUntil('\r'); Serial.println(request); client.flush();</p><p>// Match the request</p><p>int value = LOW; if (request.indexOf("/LED=ON") != -1) { digitalWrite(ledPin, HIGH); value = HIGH; } if (request.indexOf("/LED=OFF") != -1) { digitalWrite(ledPin, LOW); value = LOW; }</p><p>// Set ledPin according to the request //digitalWrite(ledPin, value);</p><p>// Return the response client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(""); // do not forget this one client.println(""); client.println(" ");</p><p>client.print("Led pin is now: ");</p><p>if(value == HIGH) { client.print("On"); } else { client.print("Off"); } client.println("<br><br>"); client.println("Click <a>here</a> turn the LED on pin 2 ON<br>"); client.println("Click <a>here</a> turn the LED on pin 2 OFF<br>"); client.println("</p><p>");</p><p>delay(1); Serial.println("Client disonnected"); Serial.println("");</p><p>}</p>