Don't show Offline status when ESP8266 in deep sleep

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

Have you tried changing the Offline Ignore Period in the Template > Info > Edit screen ?

Pete.

Hi Pete,

i’ve tried with this but it show me “Offline” anyway after some minutes

image

And what happens if you uncomment this line?

Pete.

The same.

“Hearthbeat” and “offline ignore period” already tried and doesnt work in my case.

you can use this option to set LED “online / offline” and control it with an automation timer for 11-15 minutes

Hi Nikolai

What option are you referring? Hearthbeat or offline ignore period? I’ve used both but offline icon is always shown.

I’ll give them a try and write here for a feedback.

I’ve never used automation. I’ll take a look to documentation to understand how it can works on online/offline status.

Thank you

I did a further test with another ESP8266 module cloning the previous template and I get the same problem

Basically I find that even setting an offline ignore period of more than 10 minutes, both on the blynk console and the app I get the notification that the device is offline after a few minutes the ESP goes in deep sleep mode.

I’ve set an offline ignore period of 15 minutes

Sketch used:

#define BLYNK_PRINT Serial



#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN D2

#define BLYNK_TEMPLATE_ID "xxxx"
#define BLYNK_DEVICE_NAME "ESP8266 DHT11"
#define BLYNK_AUTH_TOKEN "xxxxxxxx"
char auth[] = BLYNK_AUTH_TOKEN;

#undef BLYNK_HEARTBEAT
#define BLYNK_HEARTBEAT      610 // seconds

char ssid[] = "xxxx";
char pass[] = "xxxxxx";


#define DHTTYPE    DHT11     // DHT 11

DHT_Unified dht(DHTPIN, DHTTYPE);


// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xFA, 0xBB, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress device_ip  (192, 168,   1,  82);
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);

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

  }

  dht.humidity().getEvent(&event);
  if (isnan(event.relative_humidity))
  {
	  Serial.println(F("Error reading humidity!"));

  }
  else
  {
	  Blynk.virtualWrite(V1, event.relative_humidity);

  }
  ESP.deepSleep(6e8); //600s = 10minutes
}

This is what i get from my console

Please note that there is some discordance between the various status indications in the console.
I think it’s strange or not? Is there something I’m doing wrong?

Thank you