Connectivity Issue with multiple photon 2s

ok, I'll try that new antenna code...

1 Like

@rickkas7 what is the situation of BLE vs WiFi selectAntenna on Photon2's?

We have this on the docs:

and this too:

Thanks

STARTUP(WiFi.selectAntenna(ANT_INTERNAL));
I'm now using this on those devices with no external antenna to ensure I have it set.

WiFi.selectAntenna() is fine in Device OS 5.3.2 and later. It did not work in older versions but you could use the BLE version because BLE and Wi-Fi share the same radio and antenna switch.

Docs updated to remove the statement that BLE.selectAntenna() is required, which is no longer true.

1 Like

I have had one solid green lockup today which is much better than previous, so I feel I'm on the right track, but I'm still getting a bunch of wifi drops.

Hey, are you already using deviceOS 6.2.0?
If not, that would be my next step.

I’ll try that tomorrow.

3 of photon 2s went offline overnight with solid green lock up. I'll try 6.2 today

three devices on 6.2 started at 10AM... Hoping for better results

One unit dropped to solid green lock up at 10:18 on 6.2

My network consists of a motorola router with built in wifi at one end of the house, and two tplink access points in my upstairs (at either end). I unplugged one access point to see if that helps in any way.

removing 1 Access point did not help, but I turned off the 2nd access point and now am just on the motorola router wifi, and the performance appears to be better. I had some devices connect for greater than 40min at a time which has never happened. I'm now digging on how best to setup the network.

changed router to channel 1, access point 1 to channel 6, and access point 2 to channel 11, running 6.2, let's see if any of this helps, also the tplink routers were in "access point" mode, but the DHCP button showed enabled, so I removed that

Ok, I think this will help, added some wifi stability, and particle cloud checks:

// 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;

// Watchdog timer to reset the device if it becomes unresponsive
ApplicationWatchdog wd(60000, System.reset); // 60 seconds timeout

// Function to check Wi-Fi connection and attempt reconnection
void checkWiFiConnection() {
    if (!WiFi.ready()) {
        WiFi.disconnect();
        delay(1000);
        WiFi.connect();
        waitFor(WiFi.ready, 10000); // Wait for up to 10 seconds for Wi-Fi to connect
        if (!WiFi.ready()) {
            System.reset(); // Reset the device if still not connected
        }
    }
}

// Timer to check Wi-Fi connection every 30 seconds
Timer wifiCheckTimer(30000, checkWiFiConnection);

// setup() runs once, when the device is first turned on
void setup() {
    // Start the Wi-Fi check timer
    wifiCheckTimer.start();

    // Attempt to connect to Wi-Fi
    Particle.connect();
    waitFor(Particle.connected, 20000); // Wait for up to 20 seconds for Particle cloud connection
    if (!Particle.connected()) {
        System.reset(); // Reset the device if it fails to connect initially
    }

}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
    // Measure Uptime
    if (WiFi.ready()) {
        if (wifiConnectedTime == 0) {
            wifiConnectedTime = millis();
        }
    } else {
        wifiConnectedTime = 0;
    }

    if (millis() - lastCheckTime >= 15000) {  // Check every 15 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 % 60) + "m " + String(uptimeSeconds % 60) + "s";
            // Create a JSON string with both uptime and signal strength
            String data = String::format("{\"wifiUptime\":\"%s\",\"wifiSignalStrength\":%d}", uptimeString.c_str(), rssi);
            Particle.publish("wifiStatus", data, PRIVATE);
        } 
    }
}
1 Like

Ok, I'm going to call this resolved. I'm now able to use the devices, as the code above is recovering them, if they go into a solid green failure mode.

Good to know - thank you.

If you want an extra layer of protection, you can also use the onboard hardware watchdog, in case few resets don't provide the stability you need.

@zac6298 what would you say solved the issues for you, the last code you posted or the changes to the router and access points' channels and configuration?

I would say the code has helped the most, but I still have drop offs and hang with solid blue light only with the photon 2s even with 6.2. The argon’s don’t have connection issues so I just started buying the argon’s until hopefully the issue is addressed in firmware updates