Intermittent cloud connection & mystery green rgb light

Hello,

I just got two issues happening to me which I don’t really know the reason why.
First issue
I have using several photons in my application.
When I flashed old program (only one change is adding particle.publish(); ) to one of my old photons, it was fine after a while…
A few moment later, green RGB is constantly breathing until I reset it.


Second issue
Moreover, today, I just claimed two brand new photons (say Photon_A,Photon_B) but set up process for both photons didn’t go really well.
Photon_A could not connect to wifi during set up process via iPhone app.
I thought the problem with the firmware version, then I repeated firmware downgrade/upgrade process to Photon_A.
Managed to set up through cli.
Now it is acting weird and whenever I connect to Macbook usb port, it gets really hot.

No idea why I am having mysterious issues today. :sweat:

Hello phyo_tz,

Let me see if I can get one of my technical support team members to help you. @rickkas7 are you able to help with this?

Kyle

1 Like

Breathing green means your code is preventing the cloud from being processed. That will also affect the ability to flash it remotely, and also to run phone setup again.

Here are the most common causes for breathing green:

Particle Breathing Green Tips

Breathing green mode can be confusing to new Particle programmers but fortunately it’s usually easy to recover from.

I can’t flash my Photon anymore

Breathing green means that Wi-Fi is on, but you’re not connected to the Particle cloud. Because of this, you cannot flash your Photon from the cloud. That includes Particle Build (Web IDE), Particle Dev (Atom IDE) and Particle CLI cloud-based flashing commands.

Fortunately, you can usually get around this by entering safe mode, breathing magenta.

Hold down RESET and SETUP (or MODE), release RESET and continue to hold down SETUP/MODE until the Photon/Electron blinks magenta, then release SETUP/MODE. The device will then go through the normal sequence of colors: blinking green, blinking cyan, fast blinking cyan, then breathing magenta. Once breathing magenta, you should be able to OTA flash again.

But to get rid of the breathing green, you’ll probably need to make some changes to your code.

Do not unclaim your device

This rarely if ever fixes anything, and it sometimes can make things much worse. Resist the urge to do this. It never fixes a blinking green problem.

Cause 1: Blocking the loop

In this simple program, you’ll breathe cyan, then about 10 seconds later, you’ll go to breathing green. Why? You’ve blocked the loop from returning, and in the default threading and system mode, that stops the cloud from being processed, which causes breathing green.

Don’t do this:

void setup() {
}

void loop() {

	// Don't do this: preventing loop from returning will cause breathing green
	while(true) {

	}
}

Of course your code probably has a more subtle bug than that. For example, if you have a function that’s called from setup or loop that never returns, that can cause problems.

Some libraries that deal with sensor hardware might behave strangely when the hardware is not available, which could cause a call to block forever as well.

Solution 1: Add some Particle.process() calls

One way to solve this is to sprinkle Particle.process() calls in code that blocks. You might do something like this:

void waitForSwitch() {
	while(digitalRead(D7) == HIGH) {
		// Without the following line, you'd go into breathing green
		Particle.process();
	}
}

In general it’s better to structure your code so it always returns from loop(), but if that’s not a viable solution, you can sprinkle some Particle.process() calls in your code.

Solution 2: Enable SYSTEM_THREAD

The other solution is to use SYSTEM_THREAD mode.

SYSTEM_THREAD(ENABLED);

You insert this at the top of your source file. What it does is run the cloud processing in a separate system thread, so if you block your loop, the cloud will still be serviced and you will stay in breathing cyan instead of going to breathing green.

The only thing to be careful is that when you do this, your loop code will run before connected to the cloud. One solution is to add this in your setup() code, before you do any Particle.publish calls:

waitUntil(Particle.connected);

You might also do something like this in loop():

if (Particle.connected()) {
	Particle.publish("myEvent", PRIVATE);
}

Side note: Wi-Fi only mode

While all of the causes above were unintentionally causing breathing green, you can also do it on purpose. Using the SEMI_AUTOMATIC or MANUAL system mode and only bringing up Wi-Fi and not the cloud will cause intentional breathing green. You would do this if you’re sending data to a local server and not using the cloud at all, for example.

6 Likes

Thank you so much. I will report back in a few days after trying all the suggestions…

Meanwhile, thanks for all the suggestions.

From what I can tell now, the RGB sequence are a bit weird on 6.0.1.