Login Timeout

Looks a bit like “flooding”?

Try changing the frequency from 5 seconds to 70 seconds…

Obvious question but have you set up email widget on the app fully?

Hi Dave!

I made it work correctly!
Next challenge (but I don’t know how to code): if temperature stays above X degrees for more than Y minutes…

Thanks!

that’s great, but how did you do it?!

that is hard, it is easier to see if temp is above X every Y minutes.

otherwise you have to start using an average or median to know if the temperature STAYS above X

in my HVAC code, i use runningMedian to smooth out my temps and know that when i look at the temps every X minutes, i know that the temps is not an aberration, so it is reliable enough to use to make decisions…

or more simply you can check temp every X/5 minutes and keep a count of how many times during X the temp is higher than Y - if it is higher than Y 5 times, then trigger your warnings…???

My code (didn’t change too much according to the last code):

#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[] = "Papa-Rica Wi-Fi";
char pass[] = "password";

//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(10000L, 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 >= -7 && !sentNotice1) 
        {
        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 < -7)
          {
          sentNotice1= 0;
          }
     
     if (tempResf >= 11 && !sentNotice2) 
        {
        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;
           }
      
}

About your suggestion:

or more simply you can check temp every X/5 minutes and keep a count of how many times during X the temp is higher than Y - if it is higher than Y 5 times, then trigger your warnings

This is exactly what I want.
I’m working on it. If you have any advice, please share it!
Thank you!

If the temperature is over X, trigger the temperature timer.
|20°c 10secs|
|TRIGGERED| <=Not like this.
The temperature timer should check every D secs till It exceeds Y. (Where D is a constant integer lower than Y, 2 is recommended)
If it falls before Y, stop.
If it exceeds Y, send the e-mail.

3 posts were merged into an existing topic: Does Auth Token or Account Login have expiry