I have a few photons and an electron that sends data to the cloud. Both use the same code, but the photons hang frequently (once a day). Usually the light is breathing green which means no cloud connection, but sometimes they are breathing cyan but there is no data being transmitted. I have added a couple of techniques from the community to prevent just thing thing but it does not work. Would appreciate any help!
Since your loop() has no considerable delay (which is a good thing normally) the above code block will cause you trouble.
Due to the fact that the cloud connection process will take several seconds but your loop() will execute thousands of times meanwhile, you will constantly knock the connection back in the process.
Make this a one shot process or add a waitFor(Particle.connected, sampletime_ms); after the Particle.connect() statement.
Also I noticed that when I reenable the blocked IP address, then while the Photon is reconnecting to the cloud, Particle.connect() returns very quickly giving lots of loops (100’s ?) in a 30 seconds interval.
Still does not explain why the Photon itself disconnects periodically from the cloud and this loop and the watchdog does not allow it to reconnect.
Also unlike when I blocked the IP address and then removed the block, it recovered as expected with the Particle.connect() command. But when it looses cloud connectivity on its own, it NEVER reconnects, even though I have that check in the loop AND the Application Watchdog.
Unfortunately I’ve tried just about everything including a different physical location and therefore different AP and internet connection, still the same symptom. Also saw elsewhere in the forum
“Alas, it is not enough to use non-blocking delays with millis(). I use it everywhere, but despite that I was always loosing cloud connectivity after a while with several such non-blocking functions. After loosing cloud connectivity the Photon did not reconnect by itself and I had to reset it.”
Seems like others have this issue as well even of the code in loop does not have a delay ?
Has something to do with coding because I have a Photon here that has ALWAYS reconnected automatically after letting it run for about at least 6 months. The Photon has been rock solid for me in all respects.
I have a similar problem with my photon locking up every few days. I have enabled the HW watchdog and have a simple logger using the static RAM that records what the photon was doing before it locked up. Once locked up, the watchdog will expire and the photon will reboot. When it comes back up, I can query the static RAM and learn what it was doing just prior to locking up.
I would like someone to inspect CloudClass::publish() in spark_wiring_cloud.cpp (line 52 in my version). The line in question is:
Oops, I hit enter too soon! Note that the wait() function is called w/o any parameters. Digging through spark_wiring_async.h and you’ll find FutureImpleBase::wait( ). With no parameters, the timeout will be set to 0 which means “never timeout”.
My logging indicates that the photon had just called a function that sometimes issues Particle.publish( ) when an error occurs. So far the evidence points to Particle.publish() never returning… That wait() could be the problem.