#define BLYNK_TEMPLATE_ID "TMPL6D-GgvLNc"
#define BLYNK_TEMPLATE_NAME "DO AN VI DIEU KHIEN"
#define BLYNK_AUTH_TOKEN "iFeIkQ5cgLAbH47LcwVtXmCaKIUvWxbM"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Thao Tram 2.4G"; // tên wifi
char pass[] = "0939117738"; // mật khẩu wifi
int smokeA0 = A0;
int data = 0;
int sensorThres = 100;
BlynkTimer timer;
void sendSensor(){
int data = analogRead(smokeA0);
Blynk.virtualWrite(V0, data);
Serial.print("Pin A0: ");
Serial.println(data);
if(data > 999) // Change the Trashold value
{
Blynk.email("tanphan09999@gmai.com", "Alert", "Gas Leakage Detected!");
Blynk.logEvent("gas_alert","Gas Leakage Detected");
}
}
void setup(){
pinMode(smokeA0, INPUT);
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
//dht.begin();
timer.setInterval(2500L, sendSensor);
}
void loop(){
Blynk.run();
timer.run();
}
Blynk.email isn’t supported in Blynk IoT. Emails are part of the notification settings in the Event settings.
Pete.