# Connectivity Issue with multiple photon 2s

**URL:** <https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518>\
**Category:** Hardware\
**Tags:** photon\
**Created:** [October 22, 2024, 5:09pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518 "2024-10-22T17:09:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 22, 2024, 5:09pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/1 "2024-10-22T17:09:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [October 22, 2024, 5:42pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/2 "2024-10-22T17:42:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 22, 2024, 6:52pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/3 "2024-10-22T18:52:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 22, 2024, 7:06pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/4 "2024-10-22T19:06:05Z")

</div>

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"

---

<div class="post-metadata">

**Author:** ![gusgonnet](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/gusgonnet/32/27491_2.png) [@gusgonnet](https://community.particle.io/u/gusgonnet)\
**Post date:** [October 22, 2024, 10:29pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/5 "2024-10-22T22:29:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 22, 2024, 11:12pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/6 "2024-10-22T23:12:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gusgonnet](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/gusgonnet/32/27491_2.png) [@gusgonnet](https://community.particle.io/u/gusgonnet)\
**Post date:** [October 23, 2024, 12:54am UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/7 "2024-10-23T00:54:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 23, 2024, 2:24am UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/8 "2024-10-23T02:24:29Z")

</div>

5.9 is what I have installed.

---

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 23, 2024, 2:13pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/9 "2024-10-23T14:13:15Z")

</div>

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

```cpp
// 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");
        }
    }

}

```

---

<div class="post-metadata">

**Author:** ![rickkas7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rickkas7/32/8681_2.png) [@rickkas7](https://community.particle.io/u/rickkas7)\
**Post date:** [October 23, 2024, 2:33pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/10 "2024-10-23T14:33:16Z")

</div>

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](https://docs.particle.io/firmware/best-practices/firmware-introduction/#use-log-calls-instead-of-serial-print) 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.

---

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 23, 2024, 3:58pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/11 "2024-10-23T15:58:51Z")

</div>

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

```cpp
// 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);
        } 
    }

}

```

---

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 23, 2024, 4:06pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/12 "2024-10-23T16:06:13Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![gusgonnet](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/gusgonnet/32/27491_2.png) [@gusgonnet](https://community.particle.io/u/gusgonnet)\
**Post date:** [October 23, 2024, 4:38pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/13 "2024-10-23T16:38:52Z")

</div>

> [@zac6298](#):
>
> 1 with 5ghz, no 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));

---

<div class="post-metadata">

**Author:** ![jettonj](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jettonj/32/29510_2.png) [@jettonj](https://community.particle.io/u/jettonj)\
**Post date:** [October 23, 2024, 5:39pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/14 "2024-10-23T17:39:53Z")

</div>

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`).

 ![2769f37f-9f47-4c4e-9c65-d0824907ee87](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/6/3/632442db1762aebfc0bccac5c336647c35fbe8bc.png)

```auto
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`

```auto
"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.

---

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 23, 2024, 5:59pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/15 "2024-10-23T17:59:21Z")

</div>

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... )

---

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 23, 2024, 6:02pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/16 "2024-10-23T18:02:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zac6298](https://avatars.discourse-cdn.com/v4/letter/z/f05b48/32.png) [@zac6298](https://community.particle.io/u/zac6298)\
**Post date:** [October 23, 2024, 6:07pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/17 "2024-10-23T18:07:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gusgonnet](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/gusgonnet/32/27491_2.png) [@gusgonnet](https://community.particle.io/u/gusgonnet)\
**Post date:** [October 23, 2024, 6:14pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/18 "2024-10-23T18:14:17Z")

</div>

> [@zac6298](#):
>
> one with the antenna ext, and one without

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,

---

<div class="post-metadata">

**Author:** ![gusgonnet](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/gusgonnet/32/27491_2.png) [@gusgonnet](https://community.particle.io/u/gusgonnet)\
**Post date:** [October 23, 2024, 6:15pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/19 "2024-10-23T18:15:44Z")

</div>

oh I just remembered about this:

> **[BLE Class - Bluetooth LE (BLE) | Reference](https://docs.particle.io/reference/device-os/api/bluetooth-le-ble/ble-class/#ble-selectantenna-)**
>
> Reference manual for the C++ API used by user firmware running on Particle IoT devices

 ![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/2/f/2f5d611a1cca080c4508ece1438acb7d950fcf32.png)

I think you must use either of these two statements:

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

```

---

<div class="post-metadata">

**Author:** ![jettonj](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jettonj/32/29510_2.png) [@jettonj](https://community.particle.io/u/jettonj)\
**Post date:** [October 23, 2024, 6:16pm UTC](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518/20 "2024-10-23T18:16:28Z")

</div>

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)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/0/d/0d519d8fc6ecc871f52938dd805512cff6cbdb5f.png)

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

```auto
SerialLogHandler logHandler(115200, LOG_LEVEL_ALL);

```

Then you open a serial connection through the command line using the [particle cli](https://docs.particle.io/getting-started/developer-tools/cli/) with,  
`particle serial monitor --follow`

Then it should print a lot of systems events

[Next page](https://community.particle.io/t/connectivity-issue-with-multiple-photon-2s/68518.md?page=2)
