This document contains some useful AT commands to interact with Raspberry Pi HAT cellular modules.
- Make sure the raspberry Pi is up-to-date and the serial port is enabled. To enable the serial port run this command and then follow the prompts as shown:
- Choose Interfacing Options (5):
- Choose P6 Serial:
- Press No to the prompt below then Reboot.
- The package,
screen, should be installed by default on your Linux distro. If not, you can install it via,
sudo apt or sudo yum install screen. You may also use
minicomif you want additional customization.
screendefaults to ttyS0 unless otherwise specified.
- Sample Command:
- To see which port your device is connected to, you can run
ls -l /dev.
- Debian Repository for accessing specific versions: - https://packages.debian.org/bullseye/screen - https://launchpad.net/ubuntu/+source/minicom
Now that you know how to run AT commands on your device, here are some common commands that you can use.
|Commands||What does it do?||Sample Reponses|
|AT||Same thing as "Hey!" in real life. This is used to check if you are able to communicate with the device.||OK|
|AT+COPS=?||To see all available carriers. This command will also filter out carriers that are not compatible with the SIM card.||0, 1, "T-Mobile" or 0, 4, "AT&T"|
|AT+COPS = (#, #)||Check the current network. Obtain two #'s from the above command. For example, if you want to connect to T-Mobile, you would do AT+COPS=(0,1).||"T-Mobile" or "AT&T"|
|AT+CCID||Check the SIM ID IMEI NUMBER||OK|
|AT+CREG?||Network Registration Status. You can run the AT+CREG=? for available flags.(#, "Current Network Name", PLMN #)||OK|
|AT+COPS=?||List of available networks. This response is valuable to switch carriers.||(4, "Network Name", PLMN #), (2, "Network Name 2", PLMN #2) ...|
|AT+COPS = 1, 0 "Carrier Name"||Manually connect to a network. This is also known as PLMN selection.||If all went well, you should get an OK response. If there is an error, it will reply back with CME ERROR. The error usually occurs if your provider's SIM does not support the carrier you are connecting to. Please check with your wireless provider on the list of providers that is supported in your area.|
|AT+BANDS||Manually select a cellular band. This shouldn't be used often unless you are having issues with network congestion. The numbers seen in the sample result is different for every device.||OK 0100004000 B12 045000000 B5|
Raspberry Pi 4 has intermittent issues recognizing which USB port to use for serial communication. Even if you specify ttyUSB3 or ttyS0, the Pi often thinks that there is a separate serial port located on the device. In order to fix this issue, we recommend using a bluetooth keyboard and mouse - this will mitigate the confusion the Pi goes through.