I made a script that checks to see if there is an Internet connection. Basically it pings Google’s ip address. If no answer after several tries, it calls for a reboot of the Raspberry Pi. I have my Crontab running this script once every 12 hours. I figured it should solve any connection problems where I can no longer ssh into the pi using the Remote Terminal.
Problem is, when the connection goes down like it did today, the pi will reboot but the connection will stay down. I verified the pi rebooted by checking the system’s uptime.
I expected a reboot to act like a hard reset which is physically turning the pi off and on again. The hard reset seems to be what’s needed to clear up connection issues. However the reboot command does not.
Is there an AT command that I can run instead of a system reboot that will restart/reset the modem and give me what I want, a restored connection? I would love not to have to drive 40 minutes to physically restart the pi when it loses connectivity.
PS, the connection was lost today after attempting a firmware update of the manager.
Manager Version: 1.12.2
Outdated, update to 1.12.7.
To follow up,
This time the auto reboot fixed the connection and my cellular came back at midnight after I wrote the above post.
Two lost connections before that (it happens every couple of months), auto rebooting did not work to restore the connection. One of those times I was 600 miles away and could not get back to physically reset the unit for a week.
I wish I could figure out what the trick is to setting up an auto-restore script for when the connection is lost. If you have a strategy that is different than sudo reboot, I would love to know. Thanks in advance!
PS, the firmware update was successful when the unit came back online.
The connection was lost two more times, but my auto-reboot script brought it back online both times. I have the script running in the crontab at noon and midnight, and if there is no internet connection after several ping attempts, the Pi will reboot itself.
A more elegant script might check for connectivity using the AT commands specific to our modems, and restart the modem (not the whole Raspberry Pi) if the connection is lost. Another layer of decision making could check for an actual cell signal, and if there isn’t one, don’t bother rebooting/restarting because the unit is out of cell tower range. If someone wants to create such a script and post it here, please do!
@ensar, my device keeps going offline, even though the connectivity is available and the cellular signal is good.
I programmed the Pi 4 to reboot if there is no signal, every 6 hours now. Where the device used to go for weeks or months without a glitch, it now loses connectivity sometimes just a few minutes after a reboot.
You are already using CORE. core_manager service already does the steps you mentioned (checking your internet connection, restarting the modem if you do not have internet, checking network registration, etc.). If you are running a script related to the modem, make sure that it does not conflict with core_manager, otherwise your connection will be inconsistent. You can see the connectivity status of your device in the CORE dashboard. You do not need to restart the Rasperry Pi. Just work on your cellular module with AT commands. There are useful AT commands for your module below:
Thank you @ensar for the list of AT commands and references! That will help.
I was wondering what happens with the Core Manager when the connection goes down and will not return without a reboot? You can see the screenshot below of my Core Dashboard at the time I am typing this. When the connection goes down, the green bar turns red and says Device Offline, but the green dot next to Cellular Connection Status remains green and says Available. Also the signal quality will be fine.
The Connectivity Status bar graph shows how often the connection has been down, which in the last week has been 21.4% of the time. When it goes down it stays down unless rebooted. When the green bars come back on the graph, this is because of my crontab script.
I’ll look through the descriptions of those AT commands and try a few out. But would restarting the core_manager service be enough, without having to invoke any AT commands? I still would need to run my recovery script from the crontab on a daily schedule, because when the connection is down I cannot use Remote Terminal to access the device (it is a 40 minute drive from where I live).