0% found this document useful (0 votes)
11 views4 pages

Gas and Sound Detection System Code

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Gas and Sound Detection System Code

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include<LiquidCrystal.

h>
LiquidCrystal lcd(8,9,4,5,6,7);
#include <SoftwareSerial.h>
SoftwareSerial ESP11 = SoftwareSerial(2,3); // RX, TX

#define DEBUG true


int f=0;

String ssid = "\"wifi001\"";


String pass = "\"12345678\"";
String tcp = "\"TCP\"";
String remoteip = "\"[Link]\"";
String portnum = "80";

int gas=A0;
int sounds=A1;
int irs=A2;
int ir=0;
int sound=0;
float tp=0;
float mv=0;
int cel=0;
int gs=0;

int h=0;

void setup() {

[Link](16,2);
[Link](115200);
[Link](115200);
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
pinMode(11,OUTPUT);
digitalWrite(11,LOW);

[Link]();
[Link](0,0);
[Link](" Loading!....");
sendData("AT+CWMODE=3\r\n",2000,DEBUG); // configure as access point and Client
[Link](0,1);
[Link](" 20% ");
sendData("AT+RST\r\n",2000,DEBUG); // reset module

[Link](0,1);
[Link](" 40% ");

sendData("AT+CWLAP\r\n",3000,DEBUG); // List all available AP's*/


[Link](0,1);
[Link](" 60% ");

sendData("AT+CWJAP=" + ssid + "," + pass + "\r\n",3000,DEBUG); // Connect to AP

sendData("AT+CIPMUX=0\r\n",2000,DEBUG); //Single TCP Connections

[Link](0,1);
[Link](" 90% ");
sent();
[Link]();
[Link](0,0);
[Link]("SM: I:");
[Link](0,1);
[Link]("SD: ");

void loop() {
gaslvl();

sound=analogRead(sounds);
if(sound>999)
sound=999;

[Link](3,1);
[Link](" ");
[Link](3,1);
[Link](sound);

if(sound>600)
{

delay(3000);
[Link]();
[Link](0,0);
[Link]("High Sound");
[Link](0,1);
[Link]("Detected");
delay(2000);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
delay(4000);
digitalWrite(11,LOW);
sent();

}
if(digitalRead(irs))
{
ir=1;

[Link](11,0);
[Link](" ");
[Link](11,0);
[Link]("HG");
}
else
{
ir=0;

[Link](11,0);
[Link](" ");
[Link](11,0);
[Link]("LW");
}
sent();
}

void gaslvl()
{

gs=analogRead(gas);
gs/=10;
if(gs>100)
gs=100;

[Link](3,0);
[Link](" ");
[Link](3,0);
[Link](gs);

if(gas>60)
{

[Link](0,0);
[Link]("High Smoke");
[Link](0,1);
[Link]("Detected");
delay(2000);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
delay(4000);
digitalWrite(11,LOW);
sent();

}
}

String sendData(String command, const int timeout, boolean debug)


{

String response = ""; // ESP8266 sendData String


[Link](command); // send the read character to the esp8266

while( (time+timeout) > millis())


{
{
while([Link]())
{

char c = [Link](); // read the next character.


[Link](c);

}
}
}
if(debug)
{

}
return response;
}

void sent()
{

String getStr = "GET [Link]


smoke="; // Getting info from my online database through my online website

getStr+=gs;
getStr+="&sound=";
getStr+=sound;
getStr+="&ir=";
getStr+=ir;

sendData(cmd + "\r\n",1000,DEBUG);
sendData(getStr,1000,DEBUG);//200
String closeCommand = "AT+CIPCLOSE";

You might also like