How to Get Those Tricky IoT Devices Working with the IoT M2M Data SIM Card
August 19, 2024Launching an IoT Project for Cellular GPS Tracking: Should You Use Cat-M or NB-IoT?
September 9, 2024How to: Configure a Quectel BG96 on Linux for cellular connectivity
We had an article a few years ago on how to configure the TELIT modem on Linux using the Modem Manager. The article was great for modems that have Linux drivers. Some of the modems however do not have Linux drivers, such as the Quectel BG95 and therefore to get it connected to a cellular network with your IoT data SIM cards requires some AT command magic. We found that many of the guides we came across did not work. So we created our own and wanted to share back to the community. So here’s an article on how to connect cellular using AT commands modems without linux drivers.
Connect to the modem using a terminal
First we need to establish a terminal connection to the modem itself. Once you plugin your modem it will appear in the /dev directory. While many of the Cellular Modems will appear as ttyUSB1,2,3 the BG96 will appear as ttyAMA0 (/dev/ttyAMA0).
Once you have identified you modem connect a terminal window to it. You can do so with minicom or screen for example;
minicom -D /dev/ttyAMA0
Or
screen /dev/ttyAMA0
AT Commands to configure APNs and establish cellular connectivity
Okay, now that we have connected to the model with a terminal we can start issuing the AT commands.
For reading clarity purposes:
this is a command you enter
this is an answer coming back from the terminal
Additionally, we check if BIP is enabled on the modem (this is need when we do eSIM for IoT SGP.32 when the UICC established the IP connection to the EIM server). The answer indicates that BIP is enabled on the modem.
AT+QCFG="bip/auth"?
+QCFG: “bip/auth”,1
Here we check which MNO the Modem is currently connected to. The answer is T-mobile.
AT+COPS?
+COPS: 0,0,”T-Mobile”,0
This command checks the network registration status. The value 5
indicates that the modem is registered and is in roaming.
AT+CREG?
+CREG: 0,5
This command queries the status of the PDP context. The response indicates that the context is active (1
), and the IP address assigned is 10.64.11.242
.
AT+QIACT?
+QIACT: 1,1,1,”10.64.11.242″
This command queries the network scan mode. The response 0
indicates that the modem is set to automatic mode, scanning for any available network.
AT+QCFG="nwscanmode"?
+QCFG: “nwscanmode”,0
This command queries the IoT operation mode. The response 0
indicates that the modem is in normal operation mode.
AT+QCFG="iotopmode"?
+QCFG: “iotopmode”,0
This command queries the sequence in which the modem scans for networks. The response indicates a sequence where it scans for LTE first, then GSM, then WCDMA.
AT+QCFG="nwscanseq"?
+QCFG: “nwscanseq”,020103
This command queries the band configuration. The response indicates the supported frequency bands for the modem, but interpreting this requires knowledge of the specific band configurations.
AT+QCFG="band"
+QCFG: “band”,0xf,0x400a0e189f,0xa0e189f
This command queries the initialization status. The response 3
typically means that the modem is fully initialized.
AT+QINISTAT
+QINISTAT: 3
This command queries the SIM detection status. The response indicates that the SIM is not detected or disabled.
AT+QSIMDET?
+QSIMDET: 0,0
This command queries the SIM status. The response 1,1
indicates that the SIM is present and ready.
AT+QSIMSTAT?
+QSIMSTAT: 1,1
This command queries the PDP context definition. The response shows that the APN is simplex.iot
, but the IP address is still 0.0.0.0
, possibly indicating that the modem hasn’t fully connected to the network.
AT+CGDCONT?
+CGDCONT: 1,”IP”,”simplex.iot”,”0.0.0.0″,0,0,0,0
This command sets the PDP (Packet Data Protocol) context. It is used to configure the modem with the Access Point Name (APN) for packet-switched data services.
Details:
- 1: Context identifier (CID).
- “IP”: Specifies that the IP type is being used.
- “simplex.iot”: The APN used for the cellular network.
AT+CGDCONT= 1,"IP","simplex.iot"
This command activates the PDP context (establishes a data session) for context identifier 1 (the one we configured in the previous command). After this command, the modem should attempt to connect to the network using the specified APN and establish an IP connection.
AT+QIACT=1
This command queries the status of the PDP context. The modem responds with the status of the PDP context, including whether it is active and the IP address assigned to the modem.
AT+QIACT?
This command sends a ping to www.reddit.com
. The response indicates successful pings, with the IP address of the destination and the round-trip time in milliseconds.
AT+QPING=1,"www.reddit.com"
+QPING: 0,”151.101.65.140″,32,379,255
This command queries the current network information. The response shows that the modem is connected to a CAT-M1 network on LTE Band 12, with a network ID of 310410
(which corresponds to AT&T).
AT+QNWINFO
+QNWINFO: “CAT-M1″,”310410″,”LTE BAND 12”,5110
This command lists the available operators. The response shows a list of available networks, including T-Mobile, Verizon, AT&T, and others, along with their network IDs and status.
AT+COPS=?
+COPS: (1,”T-Mobile”,”T-Mobile”,”310260″,0),(1,”Verizon”,”Verizon”,”311480″,8),(1,”313 100″,”313 100″,”313100″,8),(2,”AT&T”,”AT&T”,”310410″,8),,(0,1,2,3,4),(0,1,2)
This command queries the firmware version of the modem. The response indicates that the firmware version is BG96MAR02A07M1G
.
AT+CGMR
BG96MAR02A07M1G
This command reads the current PDP context parameters. The response shows that the APN is simplex.iot
, the assigned IP address is 10.64.11.241
, and the DNS server IP is 172.25.128.100
.
AT+CGCONTRDP
+CGCONTRDP: 1,5,simplex.iot,10.64.11.241,,172.25.128.100,
We hope with these useful AT commands you can establish cellular connectivity and verify the status and parameters from the modem. Did we get something wrong or would you like to comment on the article? Drop us a note at marketing@simplexwireless.com!
This article was put together by James Hudgens, CTO, Simplex Wireless. https://www.linkedin.com/in/jim-hudgens/