0% found this document useful (0 votes)
48 views

Accident Coding

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)
48 views

Accident Coding

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
You are on page 1/ 4

#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 = "\"webapp2022-23.000webhostapp.com\"";
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() {

lcd.begin(16,2);
Serial.begin(115200);
ESP11.begin(115200);
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
pinMode(11,OUTPUT);
digitalWrite(11,LOW);

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

lcd.setCursor(0,1);
lcd.print(" 40% ");

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


lcd.setCursor(0,1);
lcd.print(" 60% ");

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

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

lcd.setCursor(0,1);
lcd.print(" 90% ");
sent();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("SM: I:");
lcd.setCursor(0,1);
lcd.print("SD: ");

void loop() {
gaslvl();

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

lcd.setCursor(3,1);
lcd.print(" ");
lcd.setCursor(3,1);
lcd.print(sound);

if(sound>600)
{

delay(3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("High Sound");
lcd.setCursor(0,1);
lcd.print("Detected");
delay(2000);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
delay(4000);
digitalWrite(11,LOW);
sent();

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

lcd.setCursor(11,0);
lcd.print(" ");
lcd.setCursor(11,0);
lcd.print("HG");
}
else
{
ir=0;

lcd.setCursor(11,0);
lcd.print(" ");
lcd.setCursor(11,0);
lcd.print("LW");
}
sent();
}

void gaslvl()
{

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

lcd.setCursor(3,0);
lcd.print(" ");
lcd.setCursor(3,0);
lcd.print(gs);

if(gas>60)
{

lcd.setCursor(0,0);
lcd.print("High Smoke");
lcd.setCursor(0,1);
lcd.print("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


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

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


{
{
while(Serial.available())
{

char c = Serial.read(); // read the next character.


ESP11.write(c);

}
}
}
if(debug)
{

}
return response;
}

void sent()
{

String getStr = "GET http://webapp2022-23.000webhostapp.com/vehicle/update.php?


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