Robust Notecard error handling

I have an application that uses a Cell Notecard and send updates once per hour. The host is an ESP32 running Micropython. This application will run for 1 to 2 months posting every hour. And then it dies. I cannot easily access the device so it is very difficult to debug this. I can get someone to cycle power on the device at which point everything starts up again and runs normally.

The device moves around so sometimes it is out of cell range or has a poor connection. This is normal. It supposed to re-connect and continue to transmit when it comes back into range.

I’ve gone through your sample programs, but none of them seem to check and handle errors. I’m considering adding watchdogs to both the host and notecard at the next service interval. But this is a brute force patch. I would really we to handle any errors more gracefully.

My host firmware is very simple:

On power up:

  • send {req: hub.set, product: UID, mode: minimum}
  • send {req: card.wireless, mode: auto, method: primary}
  • send {req: card.location.mode, mode: continuous}

Main loop:

  • poll measurement data
  • On the hour:
    • send {req: note.update, file: sensors.db, note: measurements, body: [data]}
    • send {req: hub.sync}
    • loop ( send {req: hub.sync.status} ) until response contains “time”

The hourly update uses “note.update” because I don’t want a pile of queued up notes when the device is out of cell range. I also poll for the response to get the latest cell tower time so that I can update the host RTC. All of my loops have timeouts to break them in case the notecard fails to respond.

Is there other Notecard errors I should be checking? How can I know if the Notecard is “locked up”? And if somehow is locked, how can I reset it?

Thanks

Kevin

Hi @ktowers,

This is a great question and I have a little guidance I can provide here. First of all, you say:

This application will run for 1 to 2 months posting every hour. And then it dies.

What does this mean exactly? The host dies? The Notecard loses connectivity? Difficult to say?

The first thing I would check (assuming that it’s the Notecard that is losing connectivity), is to see if it’s in a penalty box. This generally means the Notecard is trying to make a cellular connection, but is unable to. Therefore, to save power, it will prevent itself from making additional attempts until a certain amount of time has elapsed.

It’s important to remember that the Notecard has a lot of flash available to store data and then sync when it’s able. Especially when you use templated Notefiles, you can save a lot to flash and then wait until cell service is restored before syncing (which the Notecard will do for you automatically).

Hope that helps!
Rob