Photon with Blynk often go offline and blinking green

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>


// This #include statement was automatically added by the Particle IDE.

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

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


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;

  int value = param.asInt();

  int value = param.asInt();

  int value = param.asInt();

  int value = param.asInt();

  int value = param.asInt();

  int value = param.asInt();

BlynkTimer timer;

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

void setup()


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

The previous version of Blynk the Blynk timer would crash with particle devices. You might try using millis.

Ok, I can try. However Why the set worked for a long time?

The Blynk library is blocking so you need to make sure you test for Particle connected before If particle tests not connected do blynk.disconnect otherwise it blocks the code running. This may not be the issue but I always test this condition. I had problems with the DHT11 library and stopped using that device years ago and use the SHT31. I suspect that to be your problem but others may have more advice having used it more recently. Maybe increase your timer from 1 second to 5 and see if it works better.

Yes, everything seems to really point in the direction of what you said.

HI @Langoni -

I am a little late to the discussion, so please ignore my comment if you have already solved the problem.

You can of course use webhooks (API) instead, negating the need for the library. It is more challenging to get going but it seems to be quite robust. I used it in this tutorial with a Photon 2 to establish bi-directional communication between Particle and Blynk.

There is on caveat though - Blynk will show your device as OFFLINE and there seems to be no solution this problem at present. To make matters worse, it will also prompt you that your device is offline each time you hit a button on Blynk dashboard to send data to the Photon.

I stand to be corrected, but at the time of the tutorial, this was still the case. Hoping someone can prove otherwise as I also have some Blynk projects pending :slight_smile:


I have more than ten Particle devices (two are Photon2) that are connected to Blynk with no issues using the Blynk library. They run 24/7 in critical roles and can't have any downtime. I run my network on a cellular hotspot so I will occasionally have my devices go offline but they come back up immediately. I have found with Blynk you need the code to be clean using their examples.

1 Like

Hi @jstobaugh / @Langoni -

HHmm... from what I remember, the Blynk documents state that with cellular devices the Blynk API should be used and not the library. I am not sure whether this came into play since Blynk 2.0 though or whether this is a must, but I opted to follow the recommendation. What I can say is that I have been running multiple B524 devices with Blynk using the API for months now posting data every two minutes and have not missed a post yet :thinking:

I am by no means a expert in anything Blynk so please consider my comments as advices/findings, not law :smile:

Regards, Friedl.

@Langoni had been talking about a Photon so I missed your post talking about cellular so you are correct the Blynk API can't be used with cellular.

1 Like

This whole analysis seems reasonable enough, but I recently noticed that something interesting happens. Whenever I use a complete sketch with the DHT22, the range of the photon for the internet link decreases. By removing DHT22 the range increases. Next to the server seems to work very well with the Blynk libraries. However, I intend to do more testing before concluding anything.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.