Safest way to detect Connection loss


i use the MKR NB 1500 as a GPS Tracker. I get the Position via I2C from GPS, send it via MQTT to my Broker an then save the Values to an SQL DB.
Everything works fine until the board loses the connection due to a lack of network coverage.
How do I find out whether the modem still has an active, reliable connection to the network?

Serial.println (nbAccess.isAccessAlive ());
Serial.println (scannerNetworks.getSignalStrength ());

are ok long after the antenna is disconnected.
Is there a web to recognize this faster without e.g. pinging permanently?

Another question:
Which commands are necessary to reconnect the modem?

nbAccess.begin (PINNUMBER, "internet.t-mobile", "t-mobile", "tm"));
gprs.attachGPRS ();

are both commands necessary?


void loop() {

if ((scannerNetworks.getSignalStrength().toInt() > 9) && (nbAccess.isAccessAlive() == 0)) {
  Serial.println("try to attach");
  nbAccess.begin(PINNUMBER,"internet.t-mobile","t-mobile ","tm");

This block the Unit completely :frowning:

Problem solved by moving to TinyGSM.


can you share the working example with TinyGSM? I'm working with these boards for month and still have problems with a stable connection which lasts for longer then a day.

Would be great to have an alternative way.

Thanks, sladig

What about: The MQTT broker is online so i have a connection <-> Vice versa
i do a simple one:

      if (client.connected() == 1)
        mqtt_status4 = "Online";
      if (client.connected() == 0)
        mqtt_status4 = "Offline";}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.