Blinking cyan after a couple days

I am having intermittent issues with a Photon when I am publishing data to the cloud. Intermittently the Photon will begin to flash cyan. The time frame varys from once a day to 5-6 days.

Background…
I have created a controller using a Photon to transmit data on a 433 mhz link. (legacy) The controller was formally a Arduino but have ported the software to the Photon. This works fine. In the software, I have created a web based switch to turn on/off “Publishing to the Cloud”. When “Publishing to the Cloud” is disabled (off) the receivers on the 433 mhz work fine. (Has run weeks in this mode with no flashing cyan led).

When I enable the “Publishing to the Cloud” everything works well and the “NEW” style Photon receivers, (receiving the data via the cloud instead of 433 mhz) operate as expected. However the Controller Photon (transmitter) will partially “crash” intermittently. (Sometimes it will operate fine for 5-6 days) The 433 mhz code still operates as it should but the controller stops publishing to the cloud. (LED is flashing cyan).

Resetting the Photon controller corrects the issue.

The point…
I wrote the code below which is in the “void loop” to determine if a connection is lost, and to reboot the Photon automatically. It does function because I see the disconnectCounter increment, but appears not to catch all situations. The Signal according to RSSI() runs in the mid -50s, not great I know.

Question…
Is there a better way to determine when the Photon is disconnected from the network/cloud?

// -- Watchdog routine for loss of Internet --
    if (WiFi.RSSI() > -1) {
        disconnectCounter ++;
        delay(10000); // give it some time for the internet issue to correct itself
        EEPROM.write(2,disconnectCounter); // store counter to view it after the fact
        System.reset();
    }
   
   if (! Particle.connected()) { 
        disconnectCounter ++;
        delay(10000); 
        EEPROM.write(2,disconnectCounter);
        System.reset();
    }

Hello,

Let me ping someone that might be able to help, @ScruffR are you able to assist?

Kyle

What system firmware version are you targeting?
What SYSTEM_MODE are you running?
Are you using SYSTEM_THREAD(ENABLED)?
Does your code use String objects or other dynamic memory allocation?

Sporadic reconnect issues and/or SOS panic can be caused by heap fragmentation.

I don’t see need for the RSSI check, if (!Particle.connected()) should be enough. I’d also rather use retained variables instead of EEPROM - unless you also expect powerloss.

Seeing the rest of your code might reveal other possible causes.

1 Like

The Controller (Publisher) is 0.6.2, the receiver (Subscriber) is 0.5.3.

As for System Mode, I do not specify, so default on both (Automatic)

SYSTEM_THREAD(ENABLED), No, not using it.

Does your code use String objects, Yes, one String “update[6]” and it is 6 characters long.

I’d also rather use retained variables instead of EEPROM - unless you also expect powerloss. Ok, I can change that. The Photon is connected to a Particle Power Shield with a battery connected.

As for the code, do you want me to post it or email and if so to who? Its not super long but it is 611 lines and 9 libraries.

Is this a char update[6];? In that case it’s not a String object, which would be String update;. But the former is the prefered form anyway.
On the other hand, if this should take a 6 character string, you may need update[7] to allow space for the zero-terminator byte too.

When not connected in default AUTOMATIC mode without SYSTEM_THREAD(ENABLED), your code will be “stalled” while the auto-reconnect happens. That’s probably the reason why you won’t catch all such conditions.
So I’d suggest using SEMI_AUTOMATIC and SYSTEM_THREAD(ENABLED).

How are you building?
With Web IDE the snapshot share might be an option.

Sorry new at coding.

I did change update[6] to update[7]

I must read up on using the SEMI_AUTOMATIC and SYSTEM_THREAD(ENABLED) features before I implement those changes. (never used them before)

I will be offline for about 2 weeks, so I am going to put this on hold and turn off “Publishing”.

I am using the web IDE but not familiar with snapshot share feature unless you are talking about a Mac screen capture.

Albert

This is what I mean

You can have a snapshot of your current project on the Particle build environment and can share a link to that snapshot with others.

The only thing you need to consider with SYSTEM_MODE(SEMI_AUTOMATIC) is that the device will start off without cloud connection. It’s the responsibility of your code to start the connection.

1 Like