Not able to send email alert or use debugging in serial monitor

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();
}

I also tried to add debugging in the serial monitor, but it only prints the first initiating lines for blynk. No lines when entering the if loop to debug email sending…

Have you tried with a simpler example?

Did you add in DEBUG mode?

Well, as you can see in my code i added #define Blynk_debug and as I understand it should automatically choose the com port the esp is connected to and print to serial monitor. Am I correct?

#define BLYNK_DEBUG
To enable debug prints on the default Serial, add on the top of your sketch (should be the first line):

I just now also tried the simple blynk example you sent with just the setup() to tell me by mail that my esp is online… but no email. For testing I am using my cell hotspot, could that be an issue for sending emails via blynk? I would find that weird because it does get online and sends sensor values and notifications… Could there be a timing issue?

Yes, I did that. Read the code.

I read your code and would suggest you reading my humble suggestion with attention.

Sorry, didn’t mean to be blunt. But yes, I even tried to move the line to the very top of the code but nothing in serial monitor…

Then you have more issues than just email… with DEBUG enabled you should be getting all sorts of data… not necessarily immediately legible data… but lots of it :stuck_out_tongue_winking_eye:

Confirm you App & Library versions… and it looks like you are using the Cloud Server, correct?

You don’t get anything at all at the serial monitor?

If you Serial.print does nothing?

Which serial monitor are you using? Double check COM port and baud rate.

This would be the normal result without #define BLYNK_DEBUG… and as it was originally not placed where it should be, I wasn’t aware it was used.

I would recommend you use a basic Blynk Blink sketch and test the serial monitor and debug output first… after confirming all the up to date versions, etc.

With DEBUG properly running you should see something along this line… constantly scrolling along…

Here is when I send my email and notification test…

Thx for the help. I tried the simple examples too, but no luck, and I ended up with doing a simple smtp code to send e-mail alerts instead. Anyhow, I and not sure that I’ve for the updateted libs. Do you have the git link?