#define BLYNK_TEMPLATE_ID "TMPL6VPAlwoe-" //template id
#define BLYNK_DEVICE_NAME "Quickstart Template" //template device name
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include "SoftwareSerial.h"
#include <dht.h>
#include <TinyGPS++.h>
dht DHT;
#define Threshold 400 //untuk gas sensor
//Segala pin
const int GasSensor = 10; // show the gas detected
const int GPSRX = 11;
const int GPSTX = 12;
const int Buzzer = 5;
const int LedWhite = 6;
const int LedRed = 7;
const int Button = 8;
const int Humidity = 9;
const int MQ2 = A0; // Detect the gas type
const int LDR = A1;
#define ESP8266_BAUD 9600
SoftwareSerial EspSerial(0, 1); // RX, TX
//Blynk auth token
char auth[ ] = "6lGHfU0V8uy0la3nkJzWwSkQ51QlTRQy";
//WIFI ssid and password
char ssid[ ] = "southville pipol-TIME_2.4Ghz";
char pass[ ] = "miatboyz";
ESP8266 wifi(&EspSerial);
//TinyGPS++ object
TinyGPSPlus gps;
SoftwareSerial gpsSerial(GPSTX, GPSRX); //Rx Tx
//Segala state
int buttonState = 0;
int oldButtonState = LOW;
int sensorValue = 0; // Value LDR
bool systemOn = false; // Indicate system ni on atau off
float GasValue; //value gas sensor
float Lat,Lon;
void setup()
{
//pinMode(WifiRX, INPUT);
//pinMode(WifiTX, OUTPUT);
pinMode(GasSensor, INPUT);
pinMode(GPSRX, INPUT);
pinMode(GPSTX, OUTPUT);
pinMode(Buzzer, OUTPUT);
pinMode(LedWhite, OUTPUT);
pinMode(LedRed, OUTPUT);
pinMode(Humidity, INPUT);
pinMode(MQ2, INPUT);
pinMode(LDR, INPUT);
Serial.begin(9600);
//GPS.begin(9600);
EspSerial.begin(ESP8266_BAUD);
gpsSerial.begin(9600);
Blynk.begin(auth, wifi, ssid, pass);
}
void loop()
{
Blynk.run();
if (gpsSerial.available() > 0){
gps.encode(gpsSerial.read());
if (gps.location.isValid()){
Lat = gps.location.lat();
Lon = gps.location.lng();
Serial.print("Latitude= ");
Serial.print(Lat);
Serial.print(" Longitude= ");
Serial.println(Lon);
}
}
buttonState = digitalRead(Button);
if (buttonState != oldButtonState && buttonState == HIGH)
{
// Toggle system state
systemOn = !systemOn;
if (systemOn)
{
Serial.println("System turned ON");
}
else
{
Serial.println("System turned OFF");
}
}
if (systemOn)
{
// Humidity
int chk = DHT.read11(Humidity);
Serial.print("Temperature = ");
Serial.println(DHT.temperature);
Serial.print("Humidity = ");
Serial.println(DHT.humidity);
//Humidity
if (DHT.humidity > 80 || DHT.temperature > 45){
digitalWrite(LedRed, HIGH);
digitalWrite(Buzzer, HIGH);
} else {
digitalWrite(LedRed, LOW);
digitalWrite(Buzzer, LOW);
}
// LDR
sensorValue = analogRead(LDR);
Serial.print("LDR Value: ");
Serial.println(sensorValue);
if (sensorValue < 300)
{
digitalWrite(LedWhite, HIGH);
}
else
{
digitalWrite(LedWhite, LOW);
}
//Gas Sensor
GasValue = analogRead(MQ2); //baca gas sensor
Serial.print("Gas Sensor Value: ");
Serial.print(GasValue);
if(GasValue > Threshold)
{
Serial.println(" | Smoke detected!");
digitalWrite(LedRed, HIGH);
digitalWrite(Buzzer, HIGH);
Blynk.virtualWrite(V0,Lat);
Blynk.virtualWrite(V1,Lon);
} else {
Serial.println("");
digitalWrite(LedRed, LOW);
digitalWrite(Buzzer, LOW);
}
delay(1000);
}
oldButtonState = buttonState;
}
I NEED HELPPPP!!!
I try to upload the code but it keep on telling me that the ESP is not responding and I’m so stress about it
I really need this project to done on 6th July for my final assessment or I might failed
I really need the community help