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.
Jan

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!
Jan

/***************************************************
DFPlayer - A Mini MP3 Player For Arduino
 <https://www.dfrobot.com/index.php?route=product/product&product_id=1121>

 ***************************************************
 This example shows the basic function of library for DFPlayer.

 Created 2016-12-07
 By [Angelo qiao](Angelo.qiao@dfrobot.com)

 GNU Lesser General Public License.
 See <http://www.gnu.org/licenses/> for details.
 All above must be included in any redistribution
 ****************************************************/

/***********Notice and Trouble shooting***************
 1.Connection and Diagram can be found here
 <https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299#Connection_Diagram>
 2.This code is tested on Arduino Uno, Leonardo, Mega boards.
 ****************************************************/

#include "Arduino.h"
//#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
SYSTEM_THREAD(ENABLED);
//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()
{
  Serial1.begin(9600);
  Serial.begin(9600);
  Particle.subscribe("Payload", myHandler, MY_DEVICES);
  delay(10000);

  Serial.println();
  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!"));
    while(true);
    }
  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);
    }
  else
    {
    digitalWrite(D4, LOW);
    }

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



        //PLAY();


  /*static unsigned long timer = millis();

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


 //delay(20000);
 // myDFPlayer.play(8);
 // delay(20000);
  //myDFPlayer.play(9);
 // delay(20000);
  //myDFPlayer.play(10);
  //delay(20000);
  //myDFPlayer.previous();


  //myHandler;



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



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

  // myDFPlayer.play(data);
   myDFPlayer.play(a);


  Serial.println(event);
  Serial.print(", data: ");
  if (data){
    Serial.println(data);}
  else{
    Serial.println("NULL");
    }

}

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

void harder()
    {
    myDFPlayer.volumeUp();
    }

void zachter()
    {
    myDFPlayer.volumeDown();
    }

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