Connectivity Issue with multiple photon 2s

All,
I hope you can help me with a connectivity issue that is driving me crazy.
I'm a long time Argon device user. I have a device 100ft from my house monitoring temperature of a green house. It's been rock solid with no connectivity issues. I literally set it and forget it.
I purchased 4 new Photon 2 devices and I've had nothing but connectivity issues. My house has 30 or more wifi devices, and I don't have any wifi issues. My motorola wifi router connects to two tplink access points, so plenty of signal strength.

My issue: Using the simplest of code (LED blink), I see disconnects from the cloud, after 5-10min, and then it will either recover wifi, or halt at a solid green.

I've tried:
Particle.keepAlive(25);
SYSTEM_MODE(AUTOMATIC);
STARTUP(WiFi.selectAntenna(ANT_EXTERNAL));

wifi signal is a -34 located 10 feet from access point.
I have a single "delay 5000", but even removing the delay does not help.

Thoughts? or next steps?

Just to be sure: Your external antenna is dual-band 2.4GHz/5 GHz, correct? Since the Argon uses 2.4 GHz if you use an Argon antenna it will have very poor connectivity because the Argon antenna doesn't support 5 GHz since the Argon doesn't, but the Photon 2 will use 5 GHz if available.

A solid green should never occur in normal operation, but an investigating is ongoing to that occurring on the M-SoM when using Wi-Fi with poor connectivity. It's possible that it could also occur on the P2/Photon 2 as they share a nearly identical MCU and Wi-Fi code.

Yes, I purchased the external antenna for the photon 2, just to help rule out wifi strength issues. Note, even with the embedded antenna, I saw great wifi strength.

I may try the pre-release 6.2 as it looks like it has photon 2 supported, and there is a "system thread (enabled)" by default, better "delay behavior", and "Adds detailed WiFi access point disconnect reason logging"

Hey, you can also try connecting it to 2.4 GHz, instead of 5Ghz (or viceversa).

I’m on 2.4 ghz, and I have two photon 2s with the exact same failure, solid green lockup after trying to stay online. I’ll try 5ghz

What device os are they currently on?
I know you are aiming now at 6.2.0 , but what do they run today?
Thanks

5.9 is what I have installed.

I have a third Photon 2 running on 5ghz with this code:

// Include Particle Device OS APIs
#include "Particle.h"

// Let Device OS manage the connection to the Particle Cloud
SYSTEM_MODE(AUTOMATIC);

// Show system, cloud connectivity, and application logs over USB
// View logs with CLI using 'particle serial monitor --follow'
SerialLogHandler logHandler(LOG_LEVEL_INFO);

unsigned long wifiConnectedTime = 0;
unsigned long lastCheckTime = 0;

// setup() runs once, when the device is first turned on
void setup() {
  // Put initialization like pinMode and begin functions here

// Start serial communication at 9600 baud
Serial.begin(9600);

}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
  // The core of your code will likely live here.
 
  // Measure Uptime
   if (WiFi.ready()) {
        if (wifiConnectedTime == 0) {
            wifiConnectedTime = millis();
        }
    } else {
        wifiConnectedTime = 0;
    }

    if (millis() - lastCheckTime >= 30000) {  //check every 30 seconds
        lastCheckTime = millis();
        if (wifiConnectedTime > 0) {
            unsigned long uptimeMillis = millis() - wifiConnectedTime;
            unsigned long uptimeSeconds = uptimeMillis / 1000;
            unsigned long uptimeMinutes = uptimeSeconds / 60;
            unsigned long uptimeHours = uptimeMinutes / 60; 
            int rssi = WiFi.RSSI();
    
            Serial.print("Wi-Fi Uptime: ");
            Serial.print(uptimeHours);
            Serial.print(" hours, ");
            Serial.print(uptimeMinutes);
            Serial.print(" minutes, ");
            Serial.print(uptimeSeconds);
            Serial.println(" seconds");

            String uptimeString = String(uptimeHours) + "h " + String(uptimeMinutes) + "m " + String(uptimeSeconds) + "s";
            Particle.publish("wifiUptime", uptimeString, PRIVATE);
            Particle.publish("wifiSignalStrength", String(rssi), PRIVATE);
        } else {
            Serial.println("Wi-Fi not connected");
        }
    }

}

You should not mix Serial.print and logging, as it can cause the device to crash because Serial.print is not thread-safe and the system logs to SerialLogHandler from the system thread.

See this note for more information. Also, it will make your logging much simpler if you use Log.info because you can combine all of that into a single line using printf formatting.

1 Like

Ok, I updated code: no serial, and system thread enabled, and semi automatic:

// Include Particle Device OS APIs
#include "Particle.h"

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

SerialLogHandler logHandler;

// Select the external antenna
STARTUP(WiFi.selectAntenna(ANT_EXTERNAL));


unsigned long wifiConnectedTime = 0;
unsigned long lastCheckTime = 0;

// setup() runs once, when the device is first turned on
void setup() {
  // Put initialization like pinMode and begin functions here

Particle.connect();
}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
  // The core of your code will likely live here.

  // Measure Uptime
   if (WiFi.ready()) {
        if (wifiConnectedTime == 0) {
            wifiConnectedTime = millis();
        }
    } else {
        wifiConnectedTime = 0;
    }

    if (millis() - lastCheckTime >= 30000) {  //check every 30 seconds
        lastCheckTime = millis();
        if (wifiConnectedTime > 0) {
            unsigned long uptimeMillis = millis() - wifiConnectedTime;
            unsigned long uptimeSeconds = uptimeMillis / 1000;
            unsigned long uptimeMinutes = uptimeSeconds / 60;
            unsigned long uptimeHours = uptimeMinutes / 60; 
            int rssi = WiFi.RSSI();

            String uptimeString = String(uptimeHours) + "h " + String(uptimeMinutes) + "m " + String(uptimeSeconds) + "s";
            Particle.publish("wifiUptime", uptimeString, PRIVATE);
            Particle.publish("wifiSignalStrength", String(rssi), PRIVATE);
        } 
    }

}

4 devices uploaded with this code.
1 with 5ghz, no antenna
2 at 2.4ghz, with ext antenna
1 with 2.4ghz, no antenna

All running 5.9

I'll see if I can get these to remain online with no lock up with solid green LED.
Meanwhile, Argon just keeps on running 100ft away from house (with Particle IO 2.4ghz ext antenna).

I'm pretty sure you are aware, but please be mindful of this line on those devices without antenna:

STARTUP(WiFi.selectAntenna(ANT_EXTERNAL));

I've seen similar-ish wifi connectivity issues on 5.8.0-6.2.0. Though it seems as if it may be a little better on 6.2.0, I still see frequent disconnects. In the past 6 days I've seen 233 cloud re connections (at least going off of spark/status: online).

Result
count                   233
mean     		00:30:00.09
std      		01:09:54.17
min         	00:00:00.07
25%         	00:02:48.39
50%         	00:07:46.06
75%         	00:21:33.81
max         	08:24:43.12

For the cloud of spark/device/diagnostics/update

"connection":{
"status":"connected"
"error":-220
"attempts":5
"disconnects":5
"disconnect_reason":"error"
}

Do you see the same disconnect error in the console/log? I don't mean to hijack the thread but think your issue is similar to mine.

correct - I have two sketches... one with the antenna ext, and one without. I'm getting these failures with great wifi strength and obviously all the wifi devices in my house are rock solid (thermostat, garage door opener, argon device, rokus, etc... )

Jettonj, Yes, I've seen your posts here about connectivity issues. I do think it's similar. I'm still learning about logs. How do I get this log output? Also, I can deal with some disconnects, but it's the lock up with SOLID GREEN that makes this a no go. I can't deploy these and have them lock up.

Using the simple code above, I had a failure due to lockup with GREEN LED in about 1.5 hours, the other 3 are still functioning, but disconnect easily every 10min, but manage to reconnect.

that might create some trouble, because the antenna setting is kind of permanent, so if you ran firmware that set the antenna to external and now remove that statement, the external antenna setting is still there.
I suggest you avoid potential trouble by setting the proper antenna (internal and then external) on BOTH sketches.

Best,

oh I just remembered about this:

I think you must use either of these two statements:

// Select the internal antenna
BLE.selectAntenna(BleAntennaType::INTERNAL);
// Select the external antenna
BLE.selectAntenna(BleAntennaType::EXTERNAL);

1 Like

For the devices that have connected, you just need to press the Last vitals button in the console for that device, then view the event data that comes in (if it's currently online)

For logging over USB you need to add a log handler to your code.

SerialLogHandler logHandler(115200, LOG_LEVEL_ALL);

Then you open a serial connection through the command line using the particle cli with,
particle serial monitor --follow

Then it should print a lot of systems events