Issues with a BRN404X not reconnecting

Hi everyone. I have a Boron transmitting data for a weather station at a remote paragliding site. The Boron operated continuously from May 25th 2024 to August 9th 2024, when it went offline. I went to the site and inspected it - it was still on and running. I swapped the Boron for a new one because I assumed that something was wrong with it. The new Boron transmitted data for 3.5 hours before going offline as well.

I am unsure of how to troubleshoot this issue. I don't think my Boron is banned from the network because it is only transmitting data every 8 minutes. What I want to get feedback on first is whether there's a problem in the code I wrote for handling reconnections. Here it is:

#include "Particle.h"
#include <algorithm>

SYSTEM_MODE(SEMI_AUTOMATIC);

SYSTEM_THREAD(ENABLED);

const int ULP_SLEEP_TIME_MS = 8 * 60 * 1000;

void ulpSleep(int durationInMs) {
    systemSleepConfig.mode(SystemSleepMode::ULTRA_LOW_POWER)
            .duration(durationInMs)
            .network(NETWORK_INTERFACE_CELLULAR, SystemSleepNetworkFlag::INACTIVE_STANDBY);
        
    System.sleep(systemSleepConfig);
}

void sleepIfBatteryChargeIsLow() {
    while (true) {
        batteryStateOfCharge = System.batteryCharge();

        Log.info("Battery: %2f", batteryStateOfCharge);

        if (batteryStateOfCharge > 10 || batteryStateOfCharge < 0) {
            // We have enough battery to operate.
            // System.batteryCharge() returns -1 when battery state cannot be determined.
            return;
        } else {
            Log.info("Battery low. Going to sleep.");

            ulpSleep(ULP_SLEEP_TIME_MS);
        }
    }
}

void setup()
{
    sleepIfBatteryChargeIsLow();

    // ... Setup things for sampling the weather sensors.

    // Connect to the Particle cloud so the Boron's clock is accurate.
    if (Particle.connected() == false) {
        Log.info("Connecting to Particle Cloud.");
        Particle.connect();
        if (waitFor(Particle.connected, 100000)) {
            Log.info("Connected to Particle Cloud.");
        } else {
            Log.info("Failed to connect to the Particle Cloud.");
        }
    }
}

void loop()
{
    sleepIfBatteryChargeIsLow();

    // Sample weather sensors for 8 minutes.
    // Then we transmit the data:
    
    if (Particle.connected() == false) {
        Log.info("Connecting to Particle Cloud.");
        Particle.connect();
        if (waitFor(Particle.connected, 100000)) {
            Log.info("Connected to Particle Cloud.");
        } else {
            Log.info("Failed to connect to the Particle Cloud.");
            // We don't try to send the data since the connect failed.
            return;
        }
    }
    
    // kd = Kaaikop Data
    bool success = Particle.publish("kd", jsonArrayOfWeatherReadings, PRIVATE, WITH_ACK);
    Log.info("Publish result: %d", success);
}

The code basically does the following:

  • During setup, connects to the particle network. It's ok if we fail to connect.
  • During the loop, we sample the weather sensors for 8 minutes, then we try to transmit the data. It's ok if we fail to transmit the data, we just move on to the next 8 minute block of sampling and try again.

Am I making a mistake that could cause my Boron to end up stuck and not try to reconnect?

Thank you all for your time.

Since you are using SYSTEM_MODE(AUTOMATIC), the connection will be managed automatically and you don't need to do anything to connect. Even if SEMI_AUTOMATIC, once you start the connection process once, you don't need to do anything else.

The check for Particle.connected() should be before the Particle.publish so it will only attempt to publish when connected, and at the rate you desire.

Your wait for connection is 100 seconds, and that's insufficient. We recommend 11 minutes, because if connection failure occurs for more than 10 minutes, the cellular modem hardware will be reset by completely powering it down, which can sometimes allow a reconnection to occur. You aren't disconnecting from cellular on connection failure, so the modem reset will eventually occur with your code, but it's something to be aware of if you do.

You're using ULP with cellular active, which still uses a significant amount of power. However your sampling interval of 8 minutes is higher than recommended for reconnecting with cellular off. The recommendation in your case is to use SEMI_AUTOMATIC mode and disconnect from cellular when the battery is low. Keep track of the last time you woke and reconnect only when there is sufficient battery power and a minimum of 10 minutes has elapsed. If the battery is high, could continue to use cellular on while sleeping.

Thanks for the reply, rickkas7. Just a minor correction, I am using SYSTEM_MODE(SEMI_AUTOMATIC), not SYSTEM_MODE(AUTOMATIC) (see line 4 of the code snippet I attached). I chose SEMI_AUTOMATIC to implement the idea suggested here:

One common use case for this is checking the battery charge before connecting to cellular on the Boron, B-Series SoM, Electron, and E-Series.

In setup I initiate a sleep if the battery charge is low before attempting to connect.

Thanks for pointing out the missing Particle.connected() check that should be wrapping my publish. I will tweak the code as follows:

if (Particle.connected()) {
    bool success = Particle.publish("kd", jsonArrayOfWeatherReadings, PRIVATE, WITH_ACK);
    Log.info("Publish result: %d", success);
}

What I want to understand better is the behaviour of Particle.publish() when not connected, since that's something my code currently allows. Can calling publish while not connected make the device end up stuck in the publish and fail to reconnect?

Regarding the 100 second wait period - as you mention, the modem reset should eventually be happening. For my use-case, I don't want to wait 11 minutes, I'd rather have the device move on to sample the next window of data and simply discard the window that it could not send.

Regarding ULP sleep with cellular active - I have a large battery and solar panel powering the device, so power consumption is not a concern. Before my device went offline, it was reporting that the battery charge was at 100%.

Thanks for the help.

In SEMI_AUTOMATIC you should do the battery check in setup() then call Particle.connect() once, then it will automatically reconnect if necessary. This is how Tracker Edge and Monitor Edge firmware works.

If you are still in the process of connecting when you call Particle.publish, the publish call will block for up to 10 minutes until the modem is reset, or until cloud connected.

Hey Rickkas7. I updated my code with the improvements you mentioned, and I also added a mechanism so after 3 failed publishes (which takes around 30 minutes with my current sample - publish loop) the Boron reboots.

I installed a Boron with that new firmware on the mountain location 2 days ago. What I've observed is an improvement over the previous firmware - the Boron reconnects to the network sporadically, whereas previously it would stay offline and never reconnect. However, out of 36 hours the Boron has only managed to be online for about 4 hours.

I wanted to share the connection diagnostics for the Boron from the vitals dashboard so that maybe you or someone else can see if they spot anything problematic. I can share the ID of the Boron as well if that would help. Thanks for your time and help.

timestamp                  device.network.cellular.radio_access_technology  device.network.cellular.operator  device.network.cellular.cell_global_identity.mobile_country_code  device.network.cellular.cell_global_identity.mobile_network_code  device.network.cellular.cell_global_identity.location_area_code  device.network.cellular.cell_global_identity.cell_id  device.network.signal.at  device.network.signal.strength  device.network.signal.strength_units  device.network.signal.strengthv  device.network.signal.strengthv_units  device.network.signal.strengthv_type  device.network.signal.quality  device.network.signal.quality_units  device.network.signal.qualityv  device.network.signal.qualityv_units  device.network.signal.qualityv_type  device.network.connection.status  device.network.connection.error  device.network.connection.disconnects  device.network.connection.attempts  device.network.connection.disconnect_reason  device.cloud.connection.status  device.cloud.connection.error  device.cloud.connection.attempts  device.cloud.connection.disconnects  device.cloud.connection.disconnect_reason  device.cloud.coap.transmit  device.cloud.coap.retransmit  device.cloud.coap.unack  device.cloud.coap.round_trip  device.cloud.publish.rate_limited  device.power.battery.charge  device.power.battery.state  device.power.source  device.system.uptime  device.system.memory.used  device.system.memory.total  device.system.protected_mode  service.device.status  service.cloud.uptime  service.cloud.publish.sent  service.coap.round_trip
2024-09-14T12:04:39.133Z  LTE                                                     Rogers AT&T Wireless                      302                                                         720                                                25030                                                    25753365                                         LTE Cat-M1                45                            %                               -97                                  dBm                                     RSRP                                18.75                             %                                   -17                                     dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connecting                       0                               1                                 0                               none                                9                           8                             0                               314                           0                               100                         discharging                 battery                 285                           71272                          168256                             Open                              ok                          8                          2                              1937
2024-09-14T07:07:46.059Z  LTE                                                     Rogers AT&T Wireless                      302                                                         720                                                25030                                                    25752854                                         LTE Cat-M1                42.5                           %                               -98                                  dBm                                     RSRP                                18.75                             %                                   -17                                     dB                                     RSRQ                               connected                       0                              2                                 1                               unknown                            connected                        0                               41                                3                               error                               26                           4                             1                               1348                           0                               99.89                        discharging                 battery                 3251                          70672                          168256                             Open                              ok                          2                          2                              293
2024-09-14T03:59:24.691Z  LTE                                                     Bell Mobility                             302                                                         610                                                56004                                                    142308876                                        LTE Cat-M1                50                            %                               -95                                  dBm                                     RSRP                                18.75                             %                                   -17                                     dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               2                                 0                               none                                9                           0                             0                               1171                           0                               100                         discharging                 battery                 139                           70632                          168256                             Open                              ok                          2                          2                              637
2024-09-14T01:31:33.824Z  LTE                                                     Bell Mobility                             302                                                         610                                                56004                                                    142308876                                        LTE Cat-M1                50                            %                               -95                                  dBm                                     RSRP                                12.5                             %                                   -18                                     dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               1                                 0                               none                                9                           0                             0                               1228                           0                               100                         discharging                 battery                 586                           70632                          168256                             Open                              ok                          2                          2                              630
2024-09-13T22:12:33.105Z  LTE                                                     Bell Mobility                             302                                                         610                                                56004                                                    142308876                                        LTE Cat-M1                52.5                           %                               -94                                  dBm                                     RSRP                                12.5                             %                                   -18                                     dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               1                                 0                               none                                9                           0                             0                               1191                           0                               100                         discharging                 battery                 557                           70632                          168256                             Open                              ok                          2                          2                              704
2024-09-13T21:38:52.323Z  LTE                                                     Telus Mobility                           302                                                         220                                                56004                                                    142308876                                        LTE Cat-M1                50                            %                               -95                                  dBm                                     RSRP                                12.5                             %                                   -18                                     dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               1                                 0                               none                                9                           0                             0                               1260                           0                               100                         discharging                 battery                 332                           70688                          168256                             Open                              ok                          2                          2                              701
2024-09-13T21:18:16.531Z  LTE                                                     Bell Mobility                             302                                                         610                                                56004                                                    142308876                                        LTE Cat-M1                50                            %                               -95                                  dBm                                     RSRP                                18.75                             %                                   -17.5                                   dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               1                                 1                               error                               14                           4                             1                               970                            0                               100                         discharging                 battery                 881                           70656                          168256                             Open                              ok                          2                          2                              761
2024-09-13T19:55:28.384Z  LTE                                                     Bell Mobility                             302                                                         610                                                56004                                                    142308876                                        LTE Cat-M1                50                            %                               -95                                  dBm                                     RSRP                                12.5                             %                                   -18                                     dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               1                                 0                               none                                9                           0                             0                               1251                           0                               100                         discharging                 battery                 246                           70632                          168256                             Open                              ok                          2                          2                              706
2024-09-13T16:52:48.404Z  LTE                                                     Telus Mobility                           302                                                         220                                                56004                                                    142251788                                        LTE Cat-M1                45                            %                               -97                                  dBm                                     RSRP                                6.25                             %                                   -19.5                                   dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               1                                 0                               none                                9                           0                             0                               1169                           0                               100                         discharging                 battery                 602                           70704                          168256                             Open                              ok                          2                          2                              368
2024-09-13T13:33:11.514Z  LTE                                                     Bell Mobility                             302                                                         610                                                56004                                                    142308876                                        LTE Cat-M1                52.5                           %                               -94                                  dBm                                     RSRP                                18.75                             %                                   -17.5                                   dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               1                                 0                               none                                9                           0                             0                               1220                           0                               100                         discharging                 battery                 121                           70632                          168256                             Open                              ok                          2                          2                              173
2024-09-13T10:57:29.098Z  LTE                                                     Telus Mobility                           302                                                         220                                                56004                                                    142308876                                        LTE Cat-M1                52.5                           %                               -94                                  dBm                                     RSRP                                18.75                             %                                   -17                                     dB                                     RSRQ                               connected                       0                              2                                 1                               unknown                            connected                        0                               21                                3                               error                               62                           22                            3                               904                            0                               100                         discharging                 battery                 14368                         70656                          168256                             Open                              ok                          2                          1                              708
2024-09-13T10:18:55.814Z  LTE                                                     Rogers AT&T Wireless                      302                                                         720                                                25030                                                    25752854                                         LTE Cat-M1                42.5                           %                               -98                                  dBm                                     RSRP                                25                               %                                   -16                                     dB                                     RSRQ                               connected                       0                              1                                 1                               unknown                            connected                        0                               21                                1                               error                               45                           17                            2                               927                            0                               100                         discharging                 battery                 12055                         70656                          168256                             Open                              ok                          2                          1                              204
2024-09-13T07:01:55.566Z  LTE                                                     Bell Mobility                             302                                                         610                                                56004                                                    142308876                                        LTE Cat-M1                47.5                           %                               -96                                  dBm                                     RSRP                                18.75                             %                                   -17                                     dB                                     RSRQ                               connected                       0                              0                                 2                               unknown                            connected                        0                               7                                 0                               none                                13                          13                            1                               1074                           0                               100                         discharging                 battery                 234                           70640                          168256                             Open                              ok                          2                          2                              671
2024-09-13T05:53:04.756Z  LTE                                                     Bell Mobility                             302                                                         610                                                56004                                                    142251788                                        LTE Cat-M1                42.5                           %                               -98                                  dBm                                     RSRP                                25                               %                                   -16.5                                   dB                                     RSRQ                               connected                       0                              0                                 7                               unknown                            connected                        -220                             23                                3                               error                               34                           9                             1                               891                            0                               100                         discharging                 battery                 4957                          70624                          168256                             Open                              ok                          2                          1                              689
2024-09-13T04:32:06.450Z  LTE                                                     Rogers AT&T Wireless                      302                                                         720                                                25030                                                    25752854                                         LTE Cat-M1                40                            %                               -99                                  dBm                                     RSRP                                25                               %                                   -16                                     dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               2                                 0                               none                                9                           0                             0                               1247                           0                               100                         discharging                 battery                 99                            70704                          168256                             Open                              ok                          2                          2                              782
2024-09-12T21:38:40.528Z  LTE                                                     Rogers AT&T Wireless                      302                                                         720                                                25030                                                    16872967                                         LTE Cat-M1                47.5                           %                               -96                                  dBm                                     RSRP                                33.33                             %                                   -14.5                                   dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               1                                 0                               none                                9                           0                             0                               1116                           0                               100                         discharging                 battery                 18                            70704                          168256                             Open                              ok                          2                          2                              688
2024-09-12T18:47:21.325Z  LTE                                                     Bell Mobility                             302                                                         610                                                56004                                                    141045005                                        LTE Cat-M1                35                            %                               -101                                 dBm                                     RSRP                                33.33                             %                                   -14.5                                   dB                                     RSRQ                               connected                       0                              0                                 1                               unknown                            connected                        0                               1                                 0                               none                                9                           0                             0                               1225                           0                               disconnected                 USB host                 14                           70388                          168260                             Open                              ok                          3                          2                              1179

I eventually found a solution to the problem. I bought an external antenna from Amazon and a u.fl adapter. I installed it at the mountain and the connection problems are now gone - I'm getting my steady stream of data as before. In case it helps others, this is what I bought: https://www.amazon.ca/dp/B07P7MVWL5?ref=ppx_yo2ov_dt_b_fed_asin_title

I suspect that having the antenna that comes with the Boron inside of a weather proof plastic enclosure tightly packed with a battery, a Boron and a charging controller affected the signal quality, but I am no antenna expert so that is just a guess. Since installing the external antenna the signal quality reported by my Boron went from 14% to fluctuating between 20% and 60% (some times dipping below 20%).

Would you provide the link to the ufl connector as well? I have a 404 unit that is in sketchy coverage in a basement. Thank you!

Hey MonitorMan,

This is what I bought:
https://www.amazon.ca/Superbat-Wireless-Extension-Bulkhead-Repeater/dp/B07P84VLTR/ref=mp_s_a_1_9_sspa?crid=2JPEYVU13GE15&dib=eyJ2IjoiMSJ9.XmZDlZOMXjBc_0LdpTE7Ugci3S8EQZ6nFawLbmN0U23cIF5a2Ha2hrhOdq33vUZYlrqElsZVPCnqCRndp79TUHi9G6pBY8zstYncnj9sUxA0zi_2zoQrExIuXo6LwZk44RYt32LvotjJPlyVWcWMptgTV_gpqXdQoXBUgAs2ZovBuTVmfgDDzEYY19YVk3caP2Z93eToXX_VeUHIER4dwA.30PkcjON1SLmguGlW_5s3kpThrilvFcGaWORGuH9qoE&dib_tag=se&keywords=ufl+adapter&qid=1729458101&sprefix=ufl+adapter%2Caps%2C80&sr=8-9-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9waG9uZV9zZWFyY2hfbXRm&psc=1

Thank you! I have a boron at my camp as a power outage monitor and the signal is weak. I tried adding an antenna a couple years ago, but must not hav3 bought the correct one as the signal strength didn’t improve much.

I installed another boron at my neighbor’s house and it is monitoring his sump pump. It sends hourly updates and I noticed his misses updates much more frequently than mine. I will try your antenna combo and see it that improves his reliability.