I am using Blynk 2.0 with a dh11 sensor which reports the temp/humdity fine but the notification isn’t getting pushed to my phone though I have “You will no longer get new events today.” on the console timeline.
I had a quick browse on the previous discussions but have not spotted something that can help.
Any pointers would be much appreciated.
Code:
#define BLYNK_TEMPLATE_ID "id"
#define BLYNK_DEVICE_NAME "Temperature and humidity monitoring"
#define BLYNK_AUTH_TOKEN "token"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "ssid";
char pass[] = "pwd";
#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, t);
Blynk.virtualWrite(V6, h);
Serial.print("Temperature : ");
Serial.print(t);
Serial.print(" Humidity : ");
Serial.println(h);
if(t > 30){
// Blynk.email("my email", "Alert", "Temperature over 30C!");
Blynk.logEvent("temp_alert","Temp above 30 degree");
}
}
void setup(){
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(2500L, sendSensor);
}
void loop(){
Blynk.run();
timer.run();
}
Thanks John. Done the editing part. Yes, I am mindful that the limit is 100 per 24 window. Any reason why I don’t get the notification on my phone though?
As John has said, you are using the wrong event code. Also, you don’t have any code to prevent multiple notifications being sent for the same over temperature situation.
Thanks gents. I’ve commented out that part of the code to avoid max’ing out the limit. I will correct it tomorrow. Will indeed read the faq Pete. Cheers for the pointer. As I am just starting this setup, would deleting the device and re-creating it allow me to send the notification again without waiting the time limit to lapse?