Photon with Blynk often go offline

Dear all
I’m trying to build a set using photon particle to activate 6 relays and measure ambient temperature and humidity. I’m using Blynk to control via iPhone. The system worked very well for a few days. However, after a few days it started to go offline frequently and the photon LED flashes green.
I would like to know if there is something wrong in my sketch that could cause this, or possibly a firmware problem. Thank you in advance.

// This #include statement was automatically added by the Particle IDE.
#include <PietteTech_DHT.h>

SYSTEM_THREAD (ENABLED);

// This #include statement was automatically added by the Particle IDE.
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_TEMPLATE_NAME ""
#define BLYNK_AUTH_TOKEN ""

// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG

  char auth[] = BLYNK_AUTH_TOKEN;
  
#define DHTTYPE  DHT11
//#define DHTTYPE  DHT22
#define DHTPIN   D6

PietteTech_DHT DHT(DHTPIN, DHTTYPE);

double serverTempMax = 81;
double serverHumidityMax = 60;
double serverTemp;
double serverHumidity;
bool overheatDetected = false;
bool tooHumid = false;


const int relay_0 = 0; 
const int relay_1 = 1; 
const int relay_2 = 2;
const int relay_3 = 3;
const int relay_4 = 4;
const int relay_5 = 5;

BLYNK_WRITE(V0)
{
  int value = param.asInt();
  digitalWrite(0,value);
  Serial.println(value);
}

BLYNK_WRITE(V1)
{
  int value = param.asInt();
  digitalWrite(1,value);
}

BLYNK_WRITE(V2)
{
  int value = param.asInt();
  digitalWrite(2,value);
}

BLYNK_WRITE(V3)
{
  int value = param.asInt();
  digitalWrite(3,value);
}

BLYNK_WRITE(V4)
{
  int value = param.asInt();
  digitalWrite(4,value);
}

BLYNK_WRITE(V5)
{
   
  int value = param.asInt();
  digitalWrite(5,value);
}


BlynkTimer timer;


void sendSensor()
{
 //int result = DHT.acquireAndWait(2000);
 int result = DHT.acquireAndWait(500);
  
  serverHumidity = DHT.getHumidity();
  serverTemp =DHT.getCelsius();
  
  Serial.println(serverHumidity);
  Serial.println(serverTemp);
  
  Blynk.virtualWrite(V6, serverTemp); 
  Blynk.virtualWrite(V7, serverHumidity);
}


void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
 

pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);

digitalWrite (0,HIGH);
digitalWrite (1,HIGH);
digitalWrite (2,HIGH);
digitalWrite (3,HIGH);
digitalWrite (4,HIGH);
digitalWrite (5,HIGH);

  Particle.variable("serverTemp", &serverTemp, DOUBLE);
  Particle.variable("serverHumidity", &serverHumidity, DOUBLE);

 timer.setInterval(1000L, sendSensor);
}

void loop()
{
Blynk.run();
timer.run(); 
}

Have you tried disabling this:

#define BLYNK_DEBUG

Pete.

Hi Pete,
I will try for 24 hours.
Thanks for now

Looks good now after 24 hours working.
Please say me: When is a good idea to use and When is not a good idea to use: BLYNK_DEBUG

Use it when you’re trying to debug communication issues between the device and the server, but it’s not a good idea to use it at other times as it adds an additional overhead that can cause issues.

Pete.

But this was not just a case of bad communication between the photon and server?

Yes, caused by having Blynk Debug running, and using-up resources.

Pete.

Ok, thank you for now

Hi Pete, the problem came back. Do you have another suggestion?

I’m not familiar with the Particle hardware, and I don’t really understand the Particle service, so I can’t really help any further with this hardware.

Pete.