Cell modem troubleshooting
Cell modem power
Almost all cell modems compatible with Sensorgnomes use a lot of peak power and they exceed the power capabilities of rPi 3B and 4B USB ports. You must:
use a cell HAT or a USB cell modem plugged into a powered USB hub, never attempt to power the cell modem from the rPi's USB ports (a cell HAT needs to be plugged into USB for data, it doesn't receive power through the cable, however)
use a 20W power adapter (a good 15W may work)
use short, quality USB power cables
If the cell modem does not have enough power it will seem to work fine but not connect to the network. This is because it has plenty of power while idle but experiences voltage sags when trying to transmit causing the output signal to drop or fail to modulate correctly.
Cell HATs and USB
If you use a cell HAT it is easy to overlook that it came with a short USB cable. The 40-pin connector of the rPi provides power and some low-level controls (e.g. to detect that a cell HAT is installed). However, the cell modem is fundamentally a USB device: all the data goes over USB. Thus you must use the USB cable to connect the HAT to one of the USB ports.
Resetting the cell modem
You can reset all the software on the Sensorgnome by rebooting, however, this has only a minor impact on the cell modem. It can help if there are errors at the USB level in communicating with the cell modem. The only way to fully reset a cell modem is to power cycle it, which in the case of a HAT means power cycling the rPi.
SIM-o-rama
Most problems occur when starting cell service, i.e., placing a fresh SIM card into a cell modem and powering it up. When a connection does not get established quickly there may be a problem or you may simply be underestimating how slow things can be. Have enough coffee or tea handy to keep you awake, or better, plan on a couple of brief testing sessions per day over a couple of days. Or at least plan your day so you can let the modem do its thing for an hour a couple of times. Letting it noodle away over-night when it's in an enabled/registering or enabled/searching loop is not an unreasonable strategy...
Why initiating cell service can be very slow
Many SIMs sold for Sensorgnome type of usage work globally or continent-wide across many providers and many frequencies. This is a large space for the modem to scan and attempt to get service, either from "native" networks or via roaming.
The cell modems used for Sensorgnomes and the software are not as sophisticated as cell phones. Things take more time.
The "Super SIM" made by Twilio (and resold by SixFab among others) has multiple personalities used for different regions of the world. It switches personality after failing to connect for a number of minutes. You may be waiting for it to fail using the AsiaPac personality, then the China personality, then the South America personality, then...
Try your cell phone's SIM!
If your cell phone uses a physical SIM (as opposed to an eSIM) and your Sensorgnome cell modem is in a enabled-searching-registering endless loop (i.e. doesn't manage to connect) you can try your cell phone's SIM in the Sensorgnome. You probably need one of those cut-out SIM size adapters because your phone most likely uses the nano size while the modem uses the micro size. If your phone's SIM provides service you know that the SIM or it's service is the issue (or the carriers it has access to don't cover your spot).
Note that in the US the phone SIM may not work or only work briefly if it uses the Verizon network 'cause of "approved devices" nonsense. AT&T may have some such issues too.
SIM activation
You did activate your SIM, right? Most SIMs used for data-only service as typically used in Sensorgnomes have some form of activation performed on some web site.
What the Sensorgnome software does
The Sensorgnome software does not interact with the cell modem a whole lot. The sg-control
service, which is the main data processor and also provides the web-ui, primarily queries the ModemManager every few seconds to update the state of the cell modem in the web ui.
A check-modem
service also checks on the modem state and if it is not connected asks it to connect every few minutes. It tries to balance the need to let the modem "do its thing" trying to find a cell provider vs. ensuring that the cell modem doesn't give up and just sits there idle. Unfortunately there is no status indication for when it's still trying vs. has given up.
Once the cell modem connects everything happens automagically through a set of standard Linux services and the ModemManager. An IP address is acquired, a route to the internet is established, and its priority is such that ethernet and then wifi take precedence if they're available.
What to look for in the Web UI
The Web UI has fairly simple info about the cellular connection. It does not allow any actions to be taken. The reason is that there isn't much that can be done without a lot of information and knowledge. Cell modems are very complex (they run a full Linux operating system) and do their thing on their own. For the Sensorgnome use-case they either work, or take time to work, or don't work and when they don't work it's very difficult to figure out where the problem lies.
Cellular Panel
The Sensorgnome Web UI's network tab has a panel for cellular connections:
This screen shot shows a modem that is successfully connected. The first item to look at is that state: the (i) brings up a brief explanation of common states. If the modem doesn't connect it often says "enabled" but then cycles through "registering" or "searching" over the course of a minute or two.
When connected ensure that the Sensorgnome got an IP address:
In some situations the modem may also show a list of providers at the bottom of the panel. This at least indicates that "something is working".
When asking for help a screen capture of the cellular panel is very helpful! Also mention if it cycles through several states.
APN, ip-type, and roaming
Ensure that the config box has the correct APN for your SIM provider. You should have gotten the APN when you purchased the SIM or it may be available on the SIM provider's web site.
The cell modem initially connects to a cell network and then it needs to tell the network where to route the packets so they can be billed before they enter the internet at large. This is what the APN does. For example, you may have a French Orange SIM and use it in the US. The modem may connect to AT&T's cell network on roaming and AT&T needs to be told to route packets to/from Orange in France. Orange will count the bytes for billing before forwarding to the internet and may apply rate limiting depending on the contract. Often, however, the SIM works even if an incorrect APN is specified because it has a default APN built-in...
The roaming flag should be on in almost all cases. It is only useful if you need to ensure the SIM doesn't roam due to cost ramifications.
The ip-type should be ipv4v6 in almost all cases, allowing both IPv4 and IPv6. There are some budget IPv4-only SIMs that may need an "ipv4" setting.
Command-line troubleshooting
Some more detailed information can be obtained via the command line through SSH. (From bitter experience, it is also easy to get lost in undecipherable LTE details and not accomplish much of anything...)
The modem is managed by the Linux ModemManager. The first step is to list the modems (there should be only one) to get the numeric ID of the one installed (typ. zero but can be other if it gets reset or the USB cable is messed with):
The number of interest is after /Modem/
. The general info and state of the modem can be queried using its id:
Other than info like the specific cell modem model the status section reveals whether it thinks its connected:
Also of interest is the operator info as well as whether a bearer is connected. The bearer "carries the internet packets" over the cell connection:
The bearer can then be queried for specifics (the bearer ID increments each time the cell modem looses service and reconnects):
To check that Linux has hooked everything up the best is to check that it has a route and then try it out:
This means linux thinks it can route to the internet at large (the "default") via the cellular network device (wwan0
, or for some modems usb0
). You can now try it out by pinging 1.1.1.1 (cloudflare dns service) using that device/interface:
Checking the cell phone's GPS
The GPS in most cell modems has to be explicitly activated. This is something done at boot time by a Sensorgnome script, which also finds out which USB serial device corresponds to the GPS and then allows gpsd, the GPS daemon, to listen to it.
Warning: due to a mis-feature in ModemManager it is not possible to activate the cell phone's GPS if no SIM is present in the cell modem. A cell connection is not required but a SIM is.
The ModemManager can provide info on the GPS status and activation from the modem's perspective:
The key is to see gps-nmea
as enabled. It is unclear what "signals: no" means as in this case the GPS has a 3D fix...
In the status result of the mmcli -m 0
command mentioned above there is a section System > ports which lists all the serial ports provided by the modem and one of them should say gps, often it's /dev/ttyUSB2
. If all went well then /dev/ttyGPS
should be a symlink to that serial port:
The best way to check further is to run the gpsmon
utility which connects to gpsd
to query GPS data:
This shows that the GPS has a fix and the lines with a $GPG
prefix scroll by as the GPS reports position and time updates. If gpsmon
just shows some cryptic info (JSON) and stops it may be worthwhile to restart gpsd
using sudo systemctl restart gpsd.service
Note that the GPS info in the web interface is entirely dependent on gpsd
so if gpsd
(e.g. observed via gpsmon
) doesn't know about the GPS then the web UI can't show anything. Gpsd
only knows about a GPS after it receives and can parse some stanzas.
Last updated