I want to pause since I send an alert x the email I want 10 min to pass for the next email and I don’t know how … there I pass my code to see if someone can help me
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "dwRN53LZ53EhCY59wk9O6EstwM1Ws0zL";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Pablo y Maca 2.4";
char pass[] = "laputaclave";
#define DHTPIN 14 // What digital pin we're connected to
#define relay1 12
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
#define DHTTYPE DHT21 // DHT 21, AM2301
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
WidgetLED led2(V3);
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(relay1, OUTPUT);
digitalWrite(relay1, LOW);
lcd.setCursor (0,0);
lcd.begin(16,2);
lcd.init();
lcd.backlight();
lcd.print ("Conectando ... ");
lcd.setCursor (0,1);
lcd.print (" Red Wifi ... ");
delay(2000);
Blynk.begin(auth, ssid, pass);
delay(200);
lcd.clear ();
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
dht.begin();
lcd.setCursor (0,0);
lcd.backlight();
lcd.print ("Conectado con.. ");
lcd.setCursor (0,1);
lcd.print("IP:");
lcd.print( WiFi.localIP() );
delay(5000);
lcd.clear();
lcd.setCursor (0,0);
lcd.print ("Bienvenido .. ");
lcd.setCursor (3,1);
lcd.print("Iniciando ...");
delay(5000);
lcd.clear();
// Setup a function to be called every second
timer.setInterval(2000, sendSensor);
timer.setInterval(61000, sendTemps); // Temperature sensor read interval. 2000 (ms) = 2 seconds.
}
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;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
lcd.setCursor(0,1);
lcd.print("Temp: ");
lcd.print(t);
lcd.print("c");
lcd.setCursor(0,0);
lcd.print("Humedad: ");
lcd.print(h);
lcd.print("%");
if (digitalRead(relay1) == HIGH){ // Si se activa interruptor
led2.on(); // Pause de 1 segundo
}
else if (digitalRead(relay1) == LOW) {
led2.off(); // Pausa de 1 segundo
}
}
void sendTemps()
{
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (t > 28) {
digitalWrite(relay1, HIGH);
led2.on();
}
else if (t <= 28) {
digitalWrite(relay1, LOW);
led2.off();
}
if (t >= 30) {
Blynk.email("maugerijuan@gmail.com", "Temperatura Blynk ALERTA !! ", "Temperatura superior a 31º ATENCION !!");
}
}
void loop()
{
Blynk.run();
timer.run();
}