In this Tutorial we will learn how to control Led Over internet(Locally) using ESP8266.

The ESP8266 is a Great tool for connecting your project to internet. You can easily plug it into arduino and have a network connection and control your project through internet. Even more exciting controlling from anywhere in the world!

Its Cost is very low and Very easy to make the connection just follow the tutorial step by step.  It costs around 250(Including Shipping Charge) all over this project budget is 330-350 and you get to connect your project to internet!

In this tutorial we will see how to configure ESP8266 and remove errors which we will get and verify the connection Establishment without FTDI chips


Requirements-:



1. ESP8266 WiFi module


2. Veroboard 2x3


3. Jumper wires


4. 3.3 volt power source

5. Female Headers


6. Small Breadboard

7.  Arduino
8.  2 Button Switch

HOW DOES IT WORK?

The Project can be used now over Local WiFi or through internet(After Port Forwarding). This Module can be Programmed using Arduino/USB to TLL using Serial pins RX|TX


                   


Procedure:-

1. Perform the soldering as Shown in Video See carefully the pin number denoted to the 8 pins in this image and the Position/Orentation of module its very imp


2. Add 2 Switches Flash Button and Reset Button(uses of this you will know in future)


3. Now Do the connection with arduino here Rx to Rx and Tx to Tx 

4. Vcc for WiFi module is 3.3 volt 


5. Uploading Code(Change ssid="Keshav" and Password="Keshav12" of your Hotspot)
#include 





const char* ssid = "Keshav";//type your ssid


const char* password = "keshav12";//type your password





int ledPin = 2; // GPIO2 of ESP8266


WiFiServer server(80);//Service Port





void setup() {


Serial.begin(115200);


delay(10);





pinMode(ledPin, OUTPUT);


digitalWrite(ledPin, LOW);





// Connect to WiFi network


Serial.println();


Serial.println();


Serial.print("Connecting to ");


Serial.println(ssid);





WiFi.begin(ssid, password);





while (WiFi.status() != WL_CONNECTED) {


delay(500);


Serial.print(".");


}


Serial.println("");


Serial.println("WiFi connected");





// Start the server


server.begin();


Serial.println("Server started");





// Print the IP address


Serial.print("Use this URL to connect: ");


Serial.print("http://");


Serial.print(WiFi.localIP());


Serial.println("/");


}





void loop() {


// Check if a client has connected


WiFiClient client = server.available();


if (!client) {


return;


}





// Wait until the client sends some data


Serial.println("new client");


while(!client.available()){


delay(1);


}





// Read the first line of the request


String request = client.readStringUntil('\r');


Serial.println(request);


client.flush();





// Match the request





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;


}





//Set ledPin according to the request


//digitalWrite(ledPin, value);





// 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("");





client.print("Led pin is now: ");





if(value == HIGH) {


client.print("On");


} else {


client.print("Off");


}


client.println("

");


client.println("Click here turn the LED on pin 2 ON
");


client.println("Click here turn the LED on pin 2 OFF
");


client.println("");





delay(1);


Serial.println("Client disconnected");


Serial.println("");


}

5. Error Comes while uploading the Code
  error: 

espcomm_sync failed error

espcomm_open failed

Solution-:We are using the Arduino UNO to flash the code to ESP8266. While uploading the code, follow the procedure to keep  the Flash button pressed while you once click on reset button(Blue led in Module and Rx in Arduino will Glow once Simultaneously with reset button) and release the flash button.


6. There are other ways to upload the Code

USB TTL
Follow the Diagram Below For it

USB TTL ———-> ESP8266 ESP-01 
GND—————->GND 
TX——————->RX 
RX——————->TX 
Reset Button——–>RST
Flash Button——–>GPIO0
While uploading the code, press the flash button. Keep the flash button pressed while you click once on reset. You may now release the flash button. The ESP8266 is now in flash mode! You will be able to upload the sketch now.

7. Connection of Led for controlling


     
8. Goto the Hotspot Setting of Mobile/Lappi and Get the IP-address through which ESP8266 is Connected.






9. Open any Search Engine and type the IP-Address To Control The LED.




10. Now Controlling The LED as Shown in Vedio this is Done Locally for Internet You need to understand Port Forwarding.

Please 
Like
Share n Subscribe