Recovering from Electron running out of data

Hi All,

I’ve implemented @zoltan-fedor’s fix here, which works well for the scenarios where the sim gets unplugged or the antenna comes off or the device gets kicked off the network during some maintenance.

However, it did not work for when an Electron of mine ran out of data. In this scenario the device ran out of data, then went into the flashing blue mode. I increased the data, but the device never reconnected, even though I could see it was cycling in and out of deep sleep mode.

Are there certain scenarios where the modem has to be power cycled beyond a deep sleep? I’m trying to decide if I need an external watchdog that can remove power from the electron for a period of time.

Also, is there a system event for this scenario? Right now I am using “setup_update”, but I am wondering if being rejected by the cell tower has a different firmware event.

I’ve never tested it with running out of data, and blinking blue is not what I would have expected to happen, but this code sample has a pile of techniques for dealing with breaking out blinking blue, resetting the modem, and other things that can be helpful for robustness:

What would you expect to happen, if not blink blue?

I figured you get blinking cyan. You still should be able to reach the cellular network (blinking green) but you wouldn’t be able to get to the cloud (breathing cyan) since IP data would be blocked. But that’s just a guess, I don’t actually know what happens.
Edit: Now that I think about it, maybe the entire SIM gets deactivated when you hit the limit, so you would be stuck at blinking green. And there’s a thing at least in 0.4.8 where if you get stuck in blinking green it sometimes goes into blinking blue. So maybe that’s what’s happening.

did you try the ApplicationWatchdog to recover from Listening-Mode?
ApplicationWatchdog wd(180000, watchdogCallback);

I had some issues with SIM cards (contact issue, SIM disabled), the ApplicationWatchdog successfully reset the electron.


1 Like

@joky, yes, I am using both the application watchdog and an event handler to put my device into SLEEP_MODE_DEEP when there is a connectivity issue. This works well for situations like sim card gets unplugged, antenna is removed, etc. It doesn’t seem to work when the data limit is exceeded.

@rickkas7, I have yet to try your firmware, but my firmware implements most of what yours does for smart reboot, with the exception of AT+CFUN=16. Do you know why this command would be more beneficial than a SLEEP_MODE_DEEP reboot?

Really, what I am trying to decide is whether the Electron is capable of recovering itself from all of the cellular data connectivity issue edge cases. It seems to do OK for most of them, but I keep finding additional issues, like this one. I think in the end I will have to add an external power cycle watchdog to my device in order to protect against unknown edge cases.


I see. My product should never go into listening mode. Never. Never ever.

Yes, it is quite comfortable for developing on my desk, but it is a big pain if the product goes into listening mode at any remote site.

1 Like

No, SLEEP_MODE_DEEP is good for resetting the modem. I only tried the AT+CFUN=16 as an experiment. Both seem to work.

@rickkas7, Is there anything in your code that does more than SLEEP_MODE_DEEP to reboot the modem? Looks like you are calling, but does this do anything more than what SLEEP_MODE_DEEP does?

No, it’s not necessary to turn cellular off; that’s done automatically with SLEEP_MODE_DEEP as long as you’re not also using SLEEP_NETWORK_STANDBY. SLEEP_MODE_DEEP should be sufficient, I think.