loading
Nowadays a new emerging technology is Internet of Things (IoT): this post describes how to create Internet of things with Android and Arduino. In IoT project, all the physical objects (things) are connected together using internet infrastructure. Arduino borard is one of the most important object in this ecosystem.
This instructable describes how to create an Internet of things with Arduino uno.

Project: HTML WEB PAGE to control LED VIA WIFI MODULE (IOT) .

Step 1: What We Need Is:



1. Arduino uno
2. Esp8266-01
3. 3.3v voltage regulator
4. 10k resistances (3x)
5. connectors,wires,button,leds and bread board,general purpose pcb.


Step 2: Make a Breakout Board for ESP 8266-01:

it's my own design
note: 1. rx pin is connected with Arduino or ttl tx pin. 2.tx pin is connected with Arduino or ttl rx pin. In the schematic.The ESP's VCC pin is powered by the 3.3V output pin of the voltage regulator (AMS1117). The . The CH_PD and RST pin must also be connected to 3.3V. The GND pin is obviously connected to ground. The ESP's TXD pin can be connected directly to the RX pin of Arduino The ESP's RXD pin is connected to the TX pin through the level shifter.This allows to have a more fast and reliable communication link between the Arduino board and the ESP-01 module.

For complete design click on my another instructable :

click here for breakout board

Step 3: WEB PAGE(HTML,JAVA SCRIPT)

ESP8266 LED Control
  • ESP8266 LED Control

    IOT WORLD BY ALOK

    LED PUSH BUTTONS


  • HTML Code Used to Send Data to The ESP8266-Arduino Circuit
    DOWNLOAD HTML FILE . To save the file as an HTML file using Notepad, go to File->Save As then in “Save as Type” select “All Files”, the file name can be anything you wish but make sure you put “.html” at the end. For example if you would like to name your file myesp8266control, then your file name will have to be myesp8266control.html
  • The HTML code above uses the Javascript library JQuery, so we need to DOWNLOAD JQUERY FILE. Now right click and “Save As” in the same directory where your HTML from the code above was created. The name for the jquery library file should be jquery.min since that is how we link to it from the HTML code above:


Step 4: CODE(ARDUINO UNO)

Arduino Code Explanation
For those interested, here is how the Arduino Sketch works: Whenever you click on a button in the HTML page a GET request is sent to the ESP8266

+IPD,0,345:GET /?pin=13 HTTP/1.1

Host: 192.168.4.1

Connection: keep-alive

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

User-Agent:Moila/.0(inow N 61;WO64 AplWeKi/57.6(KTM, ik Gco)Chom/3.0211.5 afri53.3

Acep-Ecoin: zp,delae,sdh

Acep-Lngag: nUSenq=.8

  1. To know when request is in progress, the Arduino looks for the string “+IPD,” in the Serial buffer using Serial.find

  2. The code then reads the next character (the connection id, 0 in the example request above). The connection ID is needed to know which connection to close (different simultaneous requests have a different ID).

  3. Next we get the pin number by looking for the string “?pin=” in the serial buffer, once again using Serial.find

  4. Now that we have the pin number we know which pin to toggle

CODE:

#include <Software.Serial.h>

#define DEBUG true

SoftwareSerial esp8266(6,7);
{
Serial.begin(9600);
esp8266.begin(9600); // your esp's baud rate might be different

pinMode(11,OUTPUT);
digitalWrite(11,LOW);

pinMode(12,OUTPUT);
digitalWrite(12,LOW);

pinMode(13,OUTPUT);
digitalWrite(13,LOW);

sendData("AT+RST\r\n",2000,DEBUG); // reset module
sendData("AT+CWMODE=2\r\n",1000,DEBUG); // configure as access point
sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address
sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections
sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // turn on server on port 80
}

void loop()
{
if(esp8266.available()) // check if the esp is sending a message
{


if(esp8266.find("+IPD,"))
{
delay(1000); // wait for the serial buffer to fill up (read all the serial data)
// get the connection id so that we can then disconnect
int connectionId = esp8266.read()-48; // subtract 48 because the read()
// the ASCII decimal value and 0

esp8266.find("pin="); // advance cursor to "pin="

int pinNumber = (esp8266.read()-48)*10;

pinNumber += (esp8266.read()-48);
digitalWrite(pinNumber, !digitalRead(pinNumber)); // toggle pin

// make close command
String closeCommand = "AT+CIPCLOSE=";
closeCommand+=connectionId; // append connection id
closeCommand+="\r\n";

sendData(closeCommand,1000,DEBUG); // close connection
}}}

String sendData(String command, const int timeout, boolean debug)
{
String response = "";

esp8266.print(command); // send the read character to the esp8266

long int time = millis();

while( (time+timeout) > millis())
{
while(esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
response+=c;
}
}

if(debug)
{ Serial.print(response);
}

return response;
}

Step 5: FINAL STEPS:

  1. Connect the wires according to the fig1.1
  2. Connect your wi fi module with the internet as shown in fig 1.2
  3. Now reset your Arduino uno and open the serial monitor (fig 1.3)
  4. Open your HTML WEBPAGE(fig 1.4)
  5. All sets congratulation now u r able to control your led via IOT (fig 1.5)

NOTE: Another application of this instructable is HOME AUTOMATION VIA IOT

Step 6: VIDEO

project is ready to work thank u everyone for watching my instructable. If u like my work then follow me and hit the favorite button :)

<p>i got this error plz help</p>
code is perfect i think u will first go through the commands then u will be able to understand the whole steps. Recently m busy in my exam but i will help u after that this is my watsapp number 8447668896
<p>can i use esp 8266 12</p>
no becz both of them have different datasheet
sir can you send the code again
give me ur email id
<p>sir plz send code again to ssoumyasa@gmail.com</p>
ssoumyasa@gmail.com
how to get this header file<br>
and this is used for serial communication between arduino uno and other modules like Bluetooth,WI fi module etc..
pre-installed in arduino library folder
software.serial.h <br>what does it means<br>
thanks a lot!!i had made it already but my code was not working without pc , i would plug the usb cable to pc open that terminal and then kt would work but if i unplug the usb and plug it again it wouldnt work.<br><br>your code solved it!.
my pleasure

About This Instructable

6,019views

68favorites

Bio: can't say about my self it's totally depends on ur behavior
More by alok014:Face Detection+recognition MotorCycle Gear Indicator ARDUINO IOT 
Add instructable to: