Continuous operation - MKR 1500

Hi

I am piecing together a program that calls a http endpoint every hour, adjusting the RTC and reads energy meter with modbus. (NBClient, GPRS, NBAccess RTCZero, ArduinoModbus and ArduinoRS485)

Posting the values back at next request.

I could use some advice on how to achieve maximal continuous operation.

Should I try to do a timed program restart every so often, or should the Arduino be able to run for months/years without breaking down.

Is the NB-IoT modem the Achilles heel? So should I monitor requests and advise the end user when no request has been made for a couple of hours, making hard reset only option.

Any help/ thoughts is appreciated

IMHO:

  • The Achillies heel ist the connection / TCP socket. The mobile network can kick you out, the TCP socket can die, the modem can become unresponsive (My experience: Even after a hard reset)
  • I would try to open LTE-M, check, open TCP connection, check, push the data in the socket, check and then close everything vice versa, wait 1 hour and repeat, trying to keep the AT console alive.
  • The modem is it's own computer with memory, os and so on, you can only communicate over the AT console. If there is just a ERROR or no response you can do nothing.
  • Check zbeldings approach without the MKRNB lib: Http post to thingspeak - Google Docs

Hi intstarep

Thanks for your answers :slight_smile:

Would i be a terrible/useless idea to just call this, e.g every 5 days

NVIC_SystemReset(); // processor software reset

Can/should this be used to reset the modem every x days

// enable the POW_ON pin
pinMode(SARA_PWR_ON, OUTPUT);
digitalWrite(SARA_PWR_ON, HIGH);

// reset the ublox module
pinMode(SARA_RESETN, OUTPUT);
digitalWrite(SARA_RESETN, HIGH);
delay(100);
digitalWrite(SARA_RESETN, LOW);

Not very elegant but a iot device must be built for that ;=)

Is it recomended to do timed reset or not, asking due to lack of experince?

Thanks in advance

Recommended is maybe the wrong term, i would try to avoid it, but i also use the
#include <WDTZero.h>

Thanks intstarep

I will rephrase the question :slight_smile:

Will it do more damage/instability to do a timed reset NVIC_SystemReset(); every like 5 days, than not?

Will NVIC_SystemReset() also reset the modem or should SARA_RESETN also be invoked every like 5 days?

We have quite good NB IoT coverage I Denmark, don’t know if this makes it more stable.

Will WatchDog WDTZero.h also have impact on the modem?

I don’t have any issues yet on modem or board, but still early days in my test, but would like it to be as stable and self-repairing as possible :slight_smile:

The problem is IMHO not the board reset but the modem who, as an independent "computer" is not reseted then because it has it's own power supply. If you check the wiring, the reset and the power on controlled with your code are not cutting the power, so if the modem is unproductive, no way to do smth. Write stable code, thats my hint.

HI

When testing the sample code on An MKR 1500 - i looks like it works, and restarts, but the serial monitor stops writing after first run, do you know what I am missing?


#include <WDTZero.h>

WDTZero MyWatchDoggy; // Define WDT

void setup()
{
  int t = 20; // Initialize serial and wait for port to open, max 10 seconds
  Serial.begin(9600);
  while (!Serial)
  {
    delay(500);
    if ((t--) == 0)
      break;
  }
  Serial.print("\nWDTZero-Demo : Setup Soft Watchdog at 32S interval");
  MyWatchDoggy.attachShutdown(myshutdown);
  MyWatchDoggy.setup(WDT_SOFTCYCLE32S); // initialize WDT-softcounter refesh cycle on 32sec interval
}

void loop()
{
  unsigned int t = 0;

  Serial.print("\nWatchdog Test1 - run 60 seconds with a WDT.clear()\n");
  for (t = 1; t < 60; ++t)
  {
    MyWatchDoggy.clear(); // refresh wdt - before it loops
    delay(950);
    Serial.print(t);
    Serial.print(".");
  }

  Serial.print("\n\nWatchdog Test2 - Free run wait for reset @32s\n");
  for (t = 1; t > 0; ++t)
  {
    delay(950);
    Serial.print(t);
    Serial.print(".");
  }

  Serial.print("\nYou will never read this line");
}

void myshutdown()
{
  Serial.print("\nWe gonna shut down ! ...");
}

ahh, sorry, I just have to restart my serial window :slight_smile:

HI

My program with the watchdog implemented, ran for about 1 month.
Then it was stuck in this

 boolean connected = false;
  // After starting the modem with NB.begin()
  // attach to the GPRS network with the APN, login and password
  while (!connected)
  {
    Serial.println("while (!connected)");
    if ((nbAccess.begin(PINNUMBER, APN) == NB_READY) &&
        (gprs.attachGPRS() == GPRS_READY))
    {
      Serial.println("GPRS_READY");
      connected = true;
    }
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }

And burning a new program didn't help, but disconnection the power worked.

Is there any method to do a modem reset from code?

Or

Can I use a small electronic circuit to monitor my watchdog and reset the power to the board if the watchdog doesn't reach its checkpoint? Can I use a relay or MOSFET with a timed delay to achieve this function?

ChatGBT said:

if (nbAccess.getSignalStrength() == 0) {
    nbAccess.restart();
  }

But these does not exist in nbAccess

As you wrote before:

// enable the POW_ON pin
pinMode(SARA_PWR_ON, OUTPUT);
digitalWrite(SARA_PWR_ON, HIGH);

// reset the ublox module
pinMode(SARA_RESETN, OUTPUT);
digitalWrite(SARA_RESETN, HIGH);
delay(100);
digitalWrite(SARA_RESETN, LOW);

But then you have to repeat all the AT commands to re-establish the mobile connection, tcp sockets etc. after a reboot grace time.

Maybe you can try to reset the modem with the code above and then reset the mkr (and your code) within the hooked "myshutdown":
MyWatchDoggy.attachShutdown(myshutdown);

“One good test is worth a thousand expert opinions.” - Wernher von Braun

I am not that familiar with what you mean by AT commands, can you be more specific, sorry for my lack of knowledge :slight_smile:

I am not sure what you mean I can do, more than real live test it, by it is a long wait, 1 month?

Would it be overkill to do the ublox module reset, every time the watchdog is restarting the program, I mean does all these resets harm the modem?

I am greatly appreciative of all your help, thanks!

Just initialize with nb.access(true); and check the serial monitor the see the AT commands. This is the interface between your sketch and the modem

Some say yes, this can harm the modem

If you reset the modem, you have to start the whole process of establishing the network etc. The modem is a second independent fully computer which can be controled ONLY of that AT interface. Now imagine a cold, hard boot on the modem-computer side.

Hi,

I am now a little worried that I have chosen the wrong hardware for my project. That is why I am posting this.

Any help is highly appreciated :slight_smile:

since you are pretty sure your code gets stuck here, i would re write it as follows:

Hi KASSIMSAMJI

Thanks a lot :slight_smile:

My code is now in the setup section. I assume I have to put it in the loop somewhere, just before I need to communicate with the server?

I have a watchdog timer set to 32 seconds. I assume I just need to set it to 180 seconds or so?

The problem here is that when the connection dies, your variable connected remains true and there will be no reconnection attempt.

there are two tasks commented out and numbered 1 and 2 in the if statement block

the first task hard resets the modem the second one soft reboots the MKR

the OP needs to wrote those taks in :upside_down_face: