Same problem here [19] Blynk v0.3.9 on Arduino Uno [520] Connecting to RingOfFire [3812] 0018000902-AI03 [6947] 192.168.1.3 [6976] Connected to WiFi [114638] Login timeout [125346] Login timeout [134193] Ready (ping: 124ms). [150294] Login timeout [159056] Ready (ping: 125ms).
Code:
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#define ONE_WIRE_BUS 10
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>
#include <SimpleTimer.h>
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "03123be3ecbf4ab4b275528b15a36b2e";
SimpleTimer timer;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxx";
char pass[] = "xxxxx";
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
void setup()
{
// Set console baud rate
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
DS18B20.begin();
timer.setInterval(1000L, sendTemps); // Temperature sensor polling interval (5000L = 5 seconds)
}
float tempCong;
void sendTemps()
{
DS18B20.requestTemperatures(); // Polls the sensors
tempCong = DS18B20.getTempCByIndex(0); // Gets first probe on wire in lieu of by address
Blynk.virtualWrite(4, tempCong);
}
void loop()
{
if (tempCong >= -8)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Alerta de temperatura", "Câmara de congelados acima de -8C!");
delay(100000);
}
Blynk.run();
timer.run();
}
`
The issue you ask yourself? Well when if (tempCong >= -8) is TRUE, then it will loop the Blynk.email function hundreds of times and you will be disconnected from the cloud server due to flooding.
Also put Blynk.run() first in the loop and remove the silly delay(100000); because that will also cause a disconnect.
Avoid using delays completely.
yup put it behind a timer at 500ms, then make sure you set a boolean after you send the email so that it only sends once.
void loop()
{
Blynk.run();
timer.run();
}
void monitorFridge(){
if (tempCong >= -8 && !sentNotice)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Alerta de temperatura", "Câmara de congelados acima de -8C!");
sentNotice= 1; // mark it sent so it doesnt loop and flood
} else if(tempCong != -8) {
sentNotice= 0;
}
}
I can read the temperatures in the app but I don’t receive the emails.
Please notice that there are 2 temp sensors.
Both boolean variables were declared correctly.
My code:
void setup()
{
// Set console baud rate
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
DS18B20.begin();
DS18B20B.begin();
timer.setInterval(5000L, sendTemps); // Temperature sensor polling interval (5000L = 5 seconds)
}
void sendTemps()
{
DS18B20.requestTemperatures(); // Polls the sensors
DS18B20B.requestTemperatures();
tempCong = DS18B20.getTempCByIndex(0); // Gets first probe on wire in lieu of by address
tempResf = DS18B20B.getTempCByIndex(0);
Blynk.virtualWrite(4, tempCong);
Blynk.virtualWrite(5, tempResf);
}
void loop()
{
Blynk.run();
timer.run();
}
void monitorFridge(){
if (tempCong >= -8 && !sentNotice1)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Alerta de temperatura", "Câmara de congelados acima de -8C!");
sentNotice1= 1; // mark it sent so it doesnt loop and flood
} else if(tempCong < -8) {
sentNotice1= 0;
}
if (tempResf >= 11 && !sentNotice2)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Alerta de temperatura", "Câmara de congelados acima de 11C!");
sentNotice2= 1; // mark it sent so it doesnt loop and flood
} else if(tempResf < 11 ) {
sentNotice2= 0;
}
}
void loop()
{
Blynk.run();
timer.run();
timerFridge.run();
}
void monitorFridge(){
if (tempCong >= -8 && !sentNotice1)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Congelados > Alerta de temperatura", "Câmara de congelados acima de -8C!");
sentNotice1= 1; // mark it sent so it doesnt loop and flood
} else if(tempCong < -8) {
sentNotice1= 0;
}
if (tempResf >= 11 && !sentNotice2)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Refrigerados > Alerta de temperatura", "Câmara de refrigerados acima de 11C!");
sentNotice2= 1; // mark it sent so it doesnt loop and flood
} else if(tempResf < 11 ) {
sentNotice2= 0;
}
}
Also, I put a timerFridge.setInterval(5000L, monitorFridge); in void setup()
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#define ONE_WIRE_BUS 10
#define TWO_WIRE_BUS 11
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>
#include <SimpleTimer.h>
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
OneWire twoWire(TWO_WIRE_BUS);
DallasTemperature DS18B20B(&twoWire);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "token";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "RingOfFire";
char pass[] = "xxxxxxx";
//variables
float tempCong;
float tempResf;
boolean sentNotice1;
boolean sentNotice2;
SimpleTimer timer;
SimpleTimer timerFridge;
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
void setup()
{
// Set console baud rate
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
DS18B20.begin();
DS18B20B.begin();
timer.setInterval(5000L, sendTemps); // Temperature sensor polling interval (5000L = 5 seconds)
timerFridge.setInterval(5000L, monitorFridge);
}
void sendTemps()
{
DS18B20.requestTemperatures(); // Polls the sensors
DS18B20B.requestTemperatures();
tempCong = DS18B20.getTempCByIndex(0); // Gets first probe on wire in lieu of by address
tempResf = DS18B20B.getTempCByIndex(0);
Blynk.virtualWrite(4, tempCong);
Blynk.virtualWrite(5, tempResf);
}
void loop()
{
Blynk.run();
timer.run();
timerFridge.run();
}
void monitorFridge(){
if (tempCong >= -8 && !sentNotice1)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Congelados > Alerta de temperatura", "Câmara de congelados acima de -8C!");
sentNotice1= 1; // mark it sent so it doesnt loop and flood
} else if(tempCong < -8) {
sentNotice1= 0;
}
if (tempResf >= 11 && !sentNotice2)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Refrigerados > Alerta de temperatura", "Câmara de refrigerados acima de 11C!");
sentNotice2= 1; // mark it sent so it doesnt loop and flood
} else if(tempResf < 11 ) {
sentNotice2= 0;
}
}
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#define ONE_WIRE_BUS 10
#define TWO_WIRE_BUS 11
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>
#include <SimpleTimer.h>
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
OneWire twoWire(TWO_WIRE_BUS);
DallasTemperature DS18B20B(&twoWire);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "token";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "RingOfFire";
char pass[] = "xxxxxxx";
//variables
float tempCong;
float tempResf;
boolean sentNotice1;
boolean sentNotice2;
SimpleTimer timer;
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
void setup()
{
// Set console baud rate
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
DS18B20.begin();
DS18B20B.begin();
timer.setInterval(5000L, sendTemps); // Temperature sensor polling interval (5000L = 5 seconds)
timer.setInterval(5000L, monitorFridge);
}
void sendTemps()
{
DS18B20.requestTemperatures(); // Polls the sensors
DS18B20B.requestTemperatures();
tempCong = DS18B20.getTempCByIndex(0); // Gets first probe on wire in lieu of by address
tempResf = DS18B20B.getTempCByIndex(0);
Blynk.virtualWrite(4, tempCong);
Blynk.virtualWrite(5, tempResf);
}
void loop()
{
Blynk.run();
timer.run();
}
void monitorFridge() {
if (tempCong >= -8 && !sentNotice1)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Congelados > Alerta de temperatura", "Câmara de congelados acima de -8C!");
sentNotice1 = 1; // mark it sent so it doesnt loop and flood
}
else if (tempCong < -8)
{
sentNotice1 = 0;
}
if (tempResf >= 11 && !sentNotice2)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Refrigerados > Alerta de temperatura", "Câmara de refrigerados acima de 11C!");
sentNotice2 = 1; // mark it sent so it doesnt loop and flood
}
else if (tempResf < 11 )
{
sentNotice2 = 0;
}
}
you should add in some serial prints to see if/where the code is not working…
void monitorFridge() {
if (tempCong >= -8 && !sentNotice1)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Congelados > Alerta de temperatura", "Câmara de congelados acima de -8C!");
serial.Print(F("temp is high! just tried to send email"));
sentNotice1 = 1; // mark it sent so it doesnt loop and flood
}
else if (tempCong < -8)
{
serial.Print(F("temp is OK! no need to send email"));
sentNotice1 = 0;
}
if (tempResf >= 11 && !sentNotice2)
{
//Blynk.notify("Temperatura alta!");
Blynk.email("rodrigo.cavalheiro@gmail.com", "Refrigerados > Alerta de temperatura", "Câmara de refrigerados acima de 11C!");
sentNotice2 = 1; // mark it sent so it doesnt loop and flood
}
else if (tempResf < 11 )
{
sentNotice2 = 0;
}
}
I changed the code to include serial prints, tried to change the email but email still not working.
Serial monitor:
[19] Blynk v0.3.10 on Arduino Uno
[520] Connecting to Papa-Rica Wi-Fi
[3585]
OK
[6727] 192.168.1.100
[6757] Connected to WiFi
temp is high! just tried to send email[14504] Login timeout
[26024] Login timeout
[36716] Login timeout
[46937] Ready (ping: 1589ms).
Even when I try to send a “Success login” notification or email on void setup() it completely ignores the command.
Do I have to call any library for notifications or email?
Output from last code:
[19] Blynk v0.3.10 on Arduino Uno
[525] Connecting to Papa-Rica Wi-Fi
[3592] 0018000902-AI03
[6731] 192.168.1.100
[6761] Connected to WiFi
temp is high! just tried to send email
[14529] Login timeout
[25542] Ready (ping: 1588ms).
[43947] Heartbeat timeout
[53080] Ready (ping: 1589ms).
temp is OK! no need to send email
temp is OK! no need to send email
temp is OK! no need to send email
temp is OK! no need to send email
temp is OK! no need to send email
temp is OK! no need to send email
temp is high! just tried to send email
[138557] Login timeout