Hello everyone
I am using the following sketch on ESP8266 which after reading from a sensor the abiental temperature and humidity sends them and then goes into deep sleep for 10 minutes.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN D8
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "xxxxxxxxx"
#define BLYNK_DEVICE_NAME "xxxxxxxxx"
#define BLYNK_AUTH_TOKEN "xxxxxxxxx"
//#define BLYNK_HEARTBEAT 605
//#define BLYNK_TIMEOUT_MS 600000UL
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "xxxxxxxxx";
char pass[] = "xxxxxxxxx";
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT_Unified dht(DHTPIN, DHTTYPE);
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress device_ip (192, 168, 1, 81);
IPAddress dns_ip ( 192, 168, 1, 1);
IPAddress gateway_ip (192, 168, 1, 1);
IPAddress subnet_mask(255, 255, 255, 0);
void setup()
{
Serial.begin(9600);
Serial.println("wakeup");
dht.begin();
sensor_t sensor;
dht.temperature().getSensor(&sensor);
dht.humidity().getSensor(&sensor);
WiFi.config(device_ip, gateway_ip, subnet_mask);
WiFi.begin(ssid, pass);
Blynk.config(auth, IPAddress(46,101,217,214), 80); // blynk.cloud (invece di blynk-cloud.com)
while (Blynk.connect() == false)
{
Serial.println("not connected");
}
}
void loop()
{
Blynk.run();
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature))
{
Serial.println(F("Error reading temperature!"));
}
else
{
Blynk.virtualWrite(V0, event.temperature);
Serial.println("sending temperature on V0");
}
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity))
{
Serial.println(F("Error reading humidity!"));
}
else
{
Blynk.virtualWrite(V1, event.relative_humidity);
Serial.println("sending humidity on V1");
}
Serial.println("deep sleep");
ESP.deepSleep(600e6);
}
Everything works correctly, however, I was asking if it was possible to notify the “Offline” status on the app only after 10-15 minutes ESP8266 is offline since last values updates.
Thank you