Device gone offline, then back. Logs?

hey there.
so im using esp8266 with blynk iot and connected relays to it. it controlling couple devices. so i was sitting nearby, when noticed that device gone off then turned on back (which wasted work it was doing). i got message on phone, that my device gone offline. that really strange behavior and it happened already second time in last week. is there any logs i check? like button to turn off was pressed or other info that can help me to understand? thanks!

We can’t help you without seeing your code

2 Likes

Sure, but thats not code related issue. Anyway here is code:

#define BLYNK_TEMPLATE_ID "*****"
#define BLYNK_DEVICE_NAME "*****"
#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

#include "BlynkEdgent.h"
#include <DHT.h>
#include <SPI.h>

#define DHTPIN 1
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

BLYNK_CONNECTED() {
   Blynk.syncAll(); 
   
   }

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(V1, h);  //V1 is for Humidity
  Blynk.virtualWrite(V2, t);  //V2 is for Temperature
}

void setup()
{
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
   dht.begin();
   timer.setInterval(10000L, sendSensor);
   
   digitalWrite(12, LOW); //default state is off
   digitalWrite(5, LOW);
   digitalWrite(3, LOW);
   digitalWrite(13, LOW);
   
   pinMode(3, OUTPUT); //laser
   pinMode(5, OUTPUT); //power
   pinMode(12, OUTPUT); //filter
   pinMode(13, OUTPUT); //LEDs
}
   BLYNK_WRITE(V3) // Executes when the value of virtual pin 1 changes
{
  if(param.asInt() == 1)
  {    // execute this code if the switch widget is now ON
    digitalWrite(12,HIGH);  // Set digital pin 2 HIGH
  }   else  {
    // execute this code if the switch widget is now OFF
    digitalWrite(12,LOW);  // Set digital pin 2 LOW    
  } }
  BLYNK_WRITE(V4) // Executes when the value of virtual pin 1 changes
{
  if(param.asInt() == 1)
  {    // execute this code if the switch widget is now ON
    digitalWrite(5,HIGH);  // Set digital pin 2 HIGH
  }   else  {
    // execute this code if the switch widget is now OFF
    digitalWrite(5,LOW);  // Set digital pin 2 LOW    
  } }
BLYNK_WRITE(V5) // Executes when the value of virtual pin 1 changes
{
  if(param.asInt() == 1)
  {    // execute this code if the switch widget is now ON
    digitalWrite(3,HIGH);  // Set digital pin 2 HIGH
  }   else  {
    // execute this code if the switch widget is now OFF
    digitalWrite(3,LOW);  // Set digital pin 2 LOW    
  } }
BLYNK_WRITE(V6) // Executes when the value of virtual pin 1 changes
 {
  if(param.asInt() == 1)
  {    // execute this code if the switch widget is now ON
    digitalWrite(13,HIGH);  // Set digital pin 2 HIGH
  }   else  {
    // execute this code if the switch widget is now OFF
    digitalWrite(13,LOW);  // Set digital pin 2 LOW    
  } 
}
void loop() 
{
  BlynkEdgent.run();
   timer.run();
}

Your DHT sensor is connected to your Tx pin, not a good plan, especially when you’re using serial print and sending Blynk debug messages to that pin.

Also, you don’t have a board type specified, so you’ll be using the custom board configuration in Settings.h and it depends what that contains as to whether there are any other pin conflicts.

This doesn’t work unless your datastreams have the “Sync with latest server value every time device connects to the cloud” option enabled in Advanced settings. It’s usually best to use Blynk.syncVirtual(vPin) for the datastreams you wish to synchronise, especially as you only have a handful to synchronise.

Pete.

1 Like

I got you, but I’m not sure it’s related to my issue. Or always wiring fine with that and all relays synched with my app buttons. I just want to know why it’s randomly go offline with power off and then back in 2 seconds.