Home Automation Using Arduino Wifi Module Esp8266
Home Automation Using Arduino Wifi Module Esp8266
Objectives:
The automation system will have the ability to be controlled from a central
host PC, the Internet, and also remotely accessed via a Pocket PC with a
Windows Mobile based application.
The System will also sense the Accidental Gas leakage , water level and
will notify the user by SMS.
Hardware:
1. Arduino UNO
Arduino Code:
#include "SoftwareSerial.h"
#define DEBUG true
pinMode(4,OUTPUT);
digitalWrite(4,LOW);
pinMode(5,OUTPUT);
digitalWrite(5,LOW);
pinMode(6,OUTPUT);
digitalWrite(6,LOW);
pinMode(7,OUTPUT);
digitalWrite(7,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
switch (pinNumber)
{
case 1://switch 1 on
digitalWrite(4,HIGH);
break;
case 2://switch 2 on
digitalWrite(5,HIGH);
break;
case 3://switch 3 on
digitalWrite(6,HIGH);
break;
case 4://switch 4 on
digitalWrite(7,HIGH);
break;
case 5://led on
digitalWrite(13,HIGH);
break;
case 6://switch 1 off
digitalWrite(4,LOW);
break;
case 7://switch 2 off
digitalWrite(5,LOW);
break;
case 8://switch 3 off
digitalWrite(6,LOW);
break;
case 9://switch 4 off
digitalWrite(7,LOW);
break;
case 10://led off
digitalWrite(13,LOW);
break;
default:
break;
}
//digitalWrite(pinNumber, !digitalRead(pinNumber)); //
toggle pin
// make close command
String closeCommand = "AT+CIPCLOSE=";
closeCommand+=connectionId; // append connection id
closeCommand+="\r\n";
2. ESP 8266:-
3. Relayboard:-
HTML CODE:
<html>
<head>
</head>
<p> </p>
<br><br><br><br>
<p>
<br><br>
<p>Project Guide:</p>
</font>
<script src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".switch").click(function(){
boot_v1.1.bin >0x00000
2. Start XTCOM_UTIL.exe
3. Hit Tools -> Config Device in the menu
4. Configure the settings to whatever COM port you are using, and 9600 baud rate
5. Click on "Open". You should receive a notification saying "Operation Succeeded!"
6. Click on "Connect". The "Try to connect times: " message should increment a few
times as the utility tries to contact the module.
7. You should receive a notification about success before hitting 20 times.If you don't,
then make sure your connections are correct, and perhaps try swapping the RX and
TX pins around.
8. Close the "Config Device" window.
9. Hit API TEST -> (4) Flash Image Download in the menu
10. Select the .bin file to flash, and configure the correct destination address as
in the readme.txt file (For Example: boot_v1.1.bin @ 0x00000)