Photon starts breathing Green aprox 20 second after connecting to cloud

Hi all,
I have four Photons that are all showing this behaviour:
after powering up everything seems to go normal: blinking green, then blinking cyan and finally breathing cyan.
However after some 20 seconds, the device starts breathing Green and it does not execute de user program.
Within this period of 20 second (when everything seems to go OK), it is not possible to flash new software to the device, although the cyan breathing seems to indicate that the device is connecteed to the cloud.

I have tried to flash tinker to the device and hoped that I would then be able to flash other software after that.
Here is what I did:
-a new setup of the device using the iOS app, and then
-running particle flash <my_device> tinker from Particle CLI
After that, tinker is available on the iOS device, and -more significant-: it stays available. Tinker is the only software that doesnot stops after 20 seconds, and the device remains blinking cyan!
When -after this- I flash my application to the device it first lookt to go allright, but after 20s again the system breaks down, breathing green.

Does anyone have any suggestions what to do???

Note: I did not experience this behaviour before; actually I have tried four Photons today, two being old ones and two being brandnew.

That would suggest your code is blocking for that long.
Try adding SYSTEM_THREAD(ENABLED) at the top of your project.

If you show your code we might be able to tell you where the blocking most likely happens.

Great ScruffR,
That solved the problem!
Thank you very much.

Only hides the issue, you should rather try to find where the blocking happens and solve that issue.

Ok ScruffR. I very much appreciate it if you would take a look at my code.
Actually it is the code for controlling the DFPlayer Mini that I modified a little bit so that you can select the MP3 files that are on that player with an old-fashioned phonedialer.There are some libraries included and there is a lot of Serial communication that I will not use and that I will delete in the final version, just as alot of comments.
I’ll welcome your analyses.
Thank you!

DFPlayer - A Mini MP3 Player For Arduino

 This example shows the basic function of library for DFPlayer.

 Created 2016-12-07
 By [Angelo qiao](

 GNU Lesser General Public License.
 See <> for details.
 All above must be included in any redistribution

/***********Notice and Trouble shooting***************
 1.Connection and Diagram can be found here
 2.This code is tested on Arduino Uno, Leonardo, Mega boards.

#include "Arduino.h"
//#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
//SoftwareSerial mySoftwareSerial(0, 1); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
//void printDetail(uint8_t type, int value);
int DialPULS = 0;
int DialACT = 0;
unsigned long pulsduur;
int nummer = 0;
int NR = 0;
int start = 0;

void setup()
  Particle.subscribe("Payload", myHandler, MY_DEVICES);

  Serial.println(("DFRobot DFPlayer Mini Demo"));
  Serial.println(("Initializing DFPlayer ... (May take 3~5 seconds)"));

  if (!myDFPlayer.begin(Serial1))
    {  //Use softwareSerial to communicate with mp3.
    Serial.println(("Unable to begin:"));
    Serial.println(("1.Please recheck the connection!"));
    Serial.println(("2.Please insert the SD card!"));
  Serial.println(("DFPlayer Mini online."));
  pinMode(D0, INPUT_PULLUP);
  pinMode(D1, INPUT_PULLUP);
  myDFPlayer.volume(20);  //Set volume value. From 0 to 30
  Particle.variable("Nummer",&NR, INT);
  pinMode(D2, INPUT_PULLUP);//declaratie van pinMode TX
  attachInterrupt(D2, harder, RISING);//definitie van Interrupt op TX
  pinMode(D3, INPUT_PULLUP);//declaratie van pinMode TX
  attachInterrupt(D3, zachter, RISING);//definitie van Interrupt op TX
  pinMode(D4, OUTPUT);

void loop()
if (myDFPlayer.available())
    digitalWrite(D4, HIGH);
    digitalWrite(D4, LOW);

DialACT = digitalRead(D1);
DialPULS = digitalRead(D0);
if (DialACT == LOW)
    if (NR == 1 && start == 1) {; start = 0; nummer =0; delay(1000);}
    if (NR == 2 && start == 1) {; start = 0; nummer =0; delay(1000);}
    if (NR == 3 && start == 1) {; start = 0; nummer =0; delay(1000);}
    if (NR == 4 && start == 1) {; start = 0; nummer =0; delay(1000);}
    if (NR == 5 && start == 1) {; start = 0; nummer =0; delay(1000);}
    if (NR == 6 && start == 1) {; start = 0; nummer =0; delay(1000);}
    if (NR == 7 && start == 1) {; start = 0; nummer =0; delay(1000);}
    if (NR == 8 && start == 1) {; start = 0; nummer =0; delay(1000);}
    if (NR == 9 && start == 1) {; start = 0; nummer =0; delay(1000);}
    if (NR == 10 && start == 1) {; start = 0; nummer =0; delay(1000);}


  /*static unsigned long timer = millis();

 // if (millis() - timer > 30000) {
    timer = millis();;  //Play next mp3 every 3 second.

 // delay(20000);
 // delay(20000);


 //   printDetail(myDFPlayer.readType(),; //Print the detail message from DFPlayer to handle different errors and states.

void myHandler(const char *event, const char *data){
    int a =atoi(data);


  Serial.print(", data: ");
  if (data){


void Puls()
    pulsduur = pulseIn(D0, HIGH);
    if (pulsduur >= 10000)
        nummer ++;
        NR = nummer;
        start = 1;

void harder()

void zachter()

Hard blocking loops like this will break the cloud connection (without SYSTEM_THREAD(ENABLED)) as they will prevent the “background tasks” that deal with the cloud stuff from running.
If you do stuff like that, you should make sure to call Particle.process() regularly (at least every 10 seconds).