Photon is not connecting to the cloud - breathing green after cyan breathing for 2 second

After flashing the code to the photon, Everything is regular breathing cyan. But after 2 to 3 sec again photon started breathing Green. I did Device doctor, Updated the device and CLI - everything. But, I could not resolve the problem.
Please help me to solve this.

Your topic description suggests blocking code.
Especially since you also observed

How does the device behave in Safe Mode?

If you show your code we may be able to spot the reason.

It was good as usual.

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

 
 Servo myServo;
int l1 = D6;
int led = D7;
int l2 = D2;
int r1 = D3;
int r2 = D4;
Adafruit_BMP085 bmp;

void setup()
{
    myServo.attach(A4);
   pinMode(l1, OUTPUT);
   pinMode(l2, OUTPUT);
   pinMode(r1, OUTPUT);
   pinMode(r2, OUTPUT);
   pinMode(led, OUTPUT);

   Particle.function("led",BotControl);
   
   myServo.write(120);
   digitalWrite(led,HIGH);
   // Nothing to do here
   Serial.begin(9600);
  if (!bmp.begin()) {
	Serial.println("Could not find a valid BMP085 sensor, check wiring!");
	while (1) {}
  }
}


void loop()
{
   
  
  Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *C");
    
    Serial.print("Pressure = ");
    Serial.print(bmp.readPressure());
    Serial.println(" Pa");
    
    Serial.println();
    delay(500);
     char sensorInfo[64];
    sprintf(sensorInfo, "Temperature=%.2f °C, Pressure=%.2f hPa", bmp.readTemperature(), bmp.readPressure());
    Particle.publish("PhotonTemp", sensorInfo);
   
}



int BotControl(String command) {
   
    if (command=="WaterPumpInletOn") {
        digitalWrite(l1,HIGH);
        return 1;
    }
    else if (command=="WaterPumpInletOff") {
        digitalWrite(l1,LOW);
        return 1;
    }
    else if (command=="WaterPumpOutletOn") {
        digitalWrite(l2,HIGH);
        return 1;
    }
    else if (command=="WaterPumpOutletOff") {
        digitalWrite(l2,LOW);
        return 1;
    }
    else if (command=="FreshWaterPump") {
                
        digitalWrite(l1,HIGH);
        digitalWrite(l2,HIGH);
        digitalWrite(led,HIGH);

        return 1;
    }
    else if (command=="STOP"){
        digitalWrite(l1,LOW);
        digitalWrite(l2,LOW);
        digitalWrite(led,LOW);
        return 0;
    }
    else if (command=="FeederON"){
        digitalWrite(led,HIGH);
        myServo.write(180);
        delay(20);
        return 1;
    }
    else if (command=="FeederOFF"){
        digitalWrite(led,LOW);
        myServo.write(0);
        delay(20);
        return 1;
    }
    else {
       return -1;
    }
}

This is most likely your culprit. This prevents the background cloud process to from doing its job hence dropping connection.

Change that to

  while(1) Particle.process();

and see.

okay, I will try this.

thanks. now photon is continuously breathing cyan. But I am not getting the output. In console it's showing only "30ECCF6E3100F3CFCBA1957564142A6943D0A0C30E552CF44DA182A9FB42AE5A"

Another issue in the code?

What device OS version are you running?
With the most recent version(s) this should not be allowed

    Particle.publish("PhotonTemp", sensorInfo);

It should be

    Particle.publish("PhotonTemp", sensorInfo, PRIVATE);

So I’d first suggest you run particle update on your Photon, then add

  Serial.println(sensorInfo);

before your Particle.publish() call to check what you are sending out.
It’s also advisable to use this instead

    snprintf(sensorInfo, sizeof(sensorInfo)
    , "Temperature=%.2f °C, Pressure=%.2f hPa"
    , bmp.readTemperature(), bmp.readPressure());

You can also shorten your other print statements this way

    Serial.printlnf("Temperature = %.2f *C", bmp.readTemperature());  
    Serial.printlnf("Pressure = %.2f Pa", bmp.readPressure());

Or just drop them entirely since you are now printing sensorInfo locally anyway.

Brother right now, I photon RBG is not blinking. Only D7 led is on - mildly. What happened ?. is my photon Dead?

What did lead up to that?
How about Safe Mode?

It’s not going to safe mode

I tried to refresh the photon by clearing everything using Particle Doctor mode. While the process is happening. Suddenly RBG stop and D7 is on - mildly.

That would indicate that the bootloader got wiped and recovering from that requires extra hardware.
Have you got anonther Photon or a JTAG/SWD programmer?

With another Photon you could try this

If that is no option you could file a support ticket at support.particle.io and explain how your device got into that state.

Yes, I have 2 photon. I will try this.