ARDUINO IOT
This instructable describes how to create an Internet of things with Arduino uno.
Project: HTML WEB PAGE to control LED VIA WIFI MODULE (IOT) .
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.
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 :
WEB PAGE(HTML,JAVA SCRIPT)
- ESP8266 LED ControlIOT WORLD BY ALOK
LED PUSH BUTTONS
Toggle Pin 11 Toggle Pin 12 Toggle Pin 13
- 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:
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
To know when request is in progress, the Arduino looks for the string “+IPD,” in the Serial buffer using Serial.find
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).
Next we get the pin number by looking for the string “?pin=” in the serial buffer, once again using Serial.find
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;
}
FINAL STEPS:
- Connect the wires according to the fig1.1
- Connect your wi fi module with the internet as shown in fig 1.2
- Now reset your Arduino uno and open the serial monitor (fig 1.3)
- Open your HTML WEBPAGE(fig 1.4)
- 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
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 :)