Hello! I have a problem sending email alerts with ESP8266 Nodemcu 1.0 via the blynk app. I have a ds18b20 temp sensor and when the temp is above 27C I would like to receive email alerts. The if loops works, because I get the notifications in the app, but not the email. Also, for testing I added blynk.email in the setup() to see if it’s able to send at all, but does not. I checked my spam filter in my gmail, but nothing there either. I also included the email widget in the blynk app. Does anyone have any input on this? All help would be much appreciated!
Here’s my code:
#include <ESP8266WiFi.h>
//#include <BlynkSimpleEsp8266.h>
#include <BlynkSimpleEsp8266_SSL.h> //Should i use this or #include <BlynkSimpleEsp8266.h>??
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TimeLib.h>
#include <SimpleTimer.h>
#define ONE_WIRE_BUS 5
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#define BLYNK_DEBUG// Optional, this enables lots of prints
#define AUTH "******" //
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
WidgetTerminal terminal(V1);
unsigned int temp_flagg = 0; //trenger et flagg for å bare sende en email om gangen
SimpleTimer timer;
void setup()
{
Serial.begin(9600);
Blynk.begin(AUTH, "*******", "******");
while (Blynk.connect() == false) {
// Wait until connected
}
sensors.begin();
Blynk.email("ALARM", "TEMP TEST");
terminal.clear();
terminal.println("test");
terminal.flush(); // Ensure everything is sent
timer.setInterval(5000L, sendTemps); // Temperature sensor polling interval (5000L = 5 seconds)
}
void sendTemps()
{
sensors.requestTemperatures(); // Polls the sensors
float temp = sensors.getTempCByIndex(0);
Serial.println("Temperature is: ");
Serial.println(temp);
Blynk.virtualWrite(10, temp); //virtual pin V10
if (temp >= 27 && temp_flagg == 0) //tester på temp og flagg for å unngå mange mailer/notifications
{
temp_flagg = 1;
Blynk.notify("Temperature over 27C°");
Blynk.email("*****@gmail.com", "ALARM", "TEMP TEST");
} else if(temp < 26.5)
{
temp_flagg = 0;
}
}
void loop()
{
Blynk.run();
timer.run();
}