Do you want to connect your Arduino Board to the internet? Well you can,and even in a cheap and reliable way.You just have to use ESP8266 WiFi module with your Arduino. It is available for just 5$ or less than that. You can have your own ESP8266 module from the websites like Amazon and Ebay.

To buy ESP8266 from amazon, click here..
.

ESP8266 is a 3V device.It is just of 5$ but the power consumption is high.So we need to use 1 A current over here.For having the current of 1 A,we are using 1117 Voltage Regulator. In this tutorial,we will learn to send  AT commands to ESP8266 . Connect the circuit as shown in figure. Untitled-1

Paste the code in the Arduino Software.

 #include <SoftwareSerial.h>  
 SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.  
                // This means that you need to connect the TX line from the esp to the Arduino's pin 2  
                // and the RX line from the esp to the Arduino's pin 3  
 void setup()  
 {  
  Serial.begin(9600);  
  esp8266.begin(9600); // your esp's baud rate might be different  
 }  
 void loop()  
 {  
  if(esp8266.available()) // check if the esp is sending a message   
  {  
   while(esp8266.available())  
   {  
    // The esp has data so display its output to the serial window   
    char c = esp8266.read(); // read the next character.  
    Serial.write(c);  
   }   
  }  
  if(Serial.available())  
  {  
   // the following delay is required because otherwise the arduino will read the first letter of the command but not the rest  
   // In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it  
   // but we want to send everything at the same time.  
   delay(1000);   
   String command="";  
   while(Serial.available()) // read the command character by character  
   {  
     // read one character  
    command+=(char)Serial.read();  
   }  
   esp8266.println(command); // send the read character to the esp8266  
  }  
 }  

Now upload the code and open Serial Monitor. Send the AT command “AT+RST”,the response will be OK. Send “AT+CWLAP” to show the available networks around ESP8266. SEND “AT+CWJAP=”SSID”,”PASSWORD”” to connect to any particular network. then “AT+CIFSR” to see the i.p address. This way we can test our WiFi module and use it to connect it to the network. Thank You 🙂

Advertisements