Hi All,
I am trying to get the notification on email and mobile, if the temperature is above 28 degree. Below is my program. But I am not getting any notification. Can anyone please help me ?
#define BLYNK_TEMPLATE_ID "TemplateID"
#define BLYNK_DEVICE_NAME "DeviceName"
#define BLYNK_AUTH_TOKEN "AuthToken"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wifi Username"; // type your wifi name
char pass[] = "Wifi Password"; // type your wifi password
#define DHTPIN 2 // Mention the digital pin where you connected
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
void sendSensor(){
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.println(t);
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
Serial.print("Temperature : ");
Serial.print(t);
Serial.print(" Humidity : ");
Serial.println(h);
if(t > 28){
Blynk.email("techtrendsshameer@gmail.com", "Alert", "Temperature over 28C!");
Blynk.logEvent("temp_alert");
}
}
void setup(){
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(2500L, sendSensor);
}
void loop(){
Blynk.run();
timer.run();
}
Thanks
Shameer