Playing with a GSM modem (SIM800L)
Sunday night playing with AT commands and a SIM800L GSM modem.
Introduction
It has been a while since I bought a SIM800L GSM modem, but I needed more time to play with it. I was always busy with other projects, but I had some free time this weekend, and I decided to play with it. The most challenging part is to work with AT commands, as there is a massive list to go through. I found a great website with a list of AT commands for the SIM800L modem. I will use this website as a reference for the AT commands that I will use in this post.
Hardware
The hardware that I used for this project is the following:
If the power to the SIM800L is enough, the onboard LED starts blinking. If it blinks every second, it is searching for a network. You will know if it’s connected to the network when it blinks every three seconds. If the LED blinks very fast, it’s connected through GPRS.
Software
Mostly I use CLI tools for this project. One of the following(whichever you might be more comfortable with):
- screen
- picocom
- minicom
The Commands
Basic AT check
Command: AT
|
|
Check the modem
Command: AT+CGREG? / AT+CEREG
Queries for the packet-switched network status. If the response is +CGREG: x, 5 or +CEREG: x,5, then you can jump ahead to step 5. The x in the x,5 part indicates the URC status and is not essential for this step; the 5 indicates that the modem is registered to a network and is roaming. With Onomondo SIMs, you will always be roaming, which is why the response x,5 is always expected.
|
|
Check the firmware version
Command: AT+CGMR
|
|
Check the signal strength
Command: AT+CSQ
That return corresponds to a RSSI value of -93 dBm. This is only slightly better than marginal coverage. We should still be able to make a call on this signal condition, but the throughput may not be that good.
|
|
Signal strength table
|
|
Check the SIM card
Command: AT+CPIN?
|
|
Check the network selection mode
Command: AT+COPS?
Checks if the modem is in automatic selection mode. Some modems are set by default and don’t need to be set manually. If the response is anything other than +COPS: 0, you will need to set it to choose the network operator automatically using AT+COPS=0.
Beware of manually using AT+COPS=0 and AT+COPS=2, however.
|
|
Check the available networks
Command: AT+COPS=?
|
|
Make a phone call
Command: ATD+447572785067;
|
|
Hang up the phone
Command: ATH
|
|
Repeat the last call
Command: ATDL
|
|
Repeat the last command
Command: ATE1
This command will repeat the last command that was sent to the modem. This is useful if you want to repeat a command without typing it again.
|
|
Receive a phone call
Command: ATA
|
|
Send SMS
Command: AT+CMGS="+447572785067"
The +CMGS command is used to send SMS messages. The +CMGS command is followed by the phone number of the recipient. The phone number must be enclosed in double quotes. The phone number must be in international format. The +CMGS command is terminated by a carriage return (CR) character. The modem will then respond with >. This indicates that the modem is ready to receive the SMS message. The SMS message must be terminated by a CTRL+Z character. The modem will then respond with +CMGS:
|
|
Read the IMEI
Command: AT+CGSN
|
|
Name of manufacturer
Command: AT+CGMI
|
|
Model of the modem
Command: AT+CGMM
|
|
Read the battery voltage
Command: AT+CBC
|
|
Resources/References
- https://m2msupport.net/m2msupport/voice-call-at-commands-to-set-up-voice-call/
- https://www.smssolutions.net/tutorials/gsm/sendsmsat/
- https://m2msupport.net/m2msupport/voice-call-at-commands-to-set-up-voice-call/
- https://microchipsupport.force.com/s/article/Dial-phone-number-using-AT-command
- https://m2msupport.net/m2msupport/sim-at-commands-for-sim-presense-and-status/
- https://onomondo.com/help-center/testing-debugging/how-do-i-test-connectivity-with-at-commands/
- https://www.sparkfun.com/datasheets/Cellular%20Modules/AT_Commands_Reference_Guide_r0.pdf