SIM908 - AT commands
- December 05 2015
- Another projects
- 2774 Reads
- 0 Comments
Repetition again.
You have to connect UART from SIM908 module to your microcontroller (Tx module - Rx microcontroller, Rx - module - Tx microcontroller). You can use USB-UART convertor.
A lot of AT commands is same for SIM900 and another SIM types.
Communication: The module doesn't send end character (e.g. \0) and number of bytes. It's a problem. I found three solutions.
The first of them: timeout. In endless loop, where the code waits on recieve char is condition. If is set flag of timer, the loop ends. This solution is very easy, but it has one disadvantage. If The modul send message after timeout, the message will not recieve - microcontroller will not wait for recieving message.
Next solution is waiting for \r\nOK\r\n - almost all messages end this AT command, but not all. Disadvantage is clear. Module can send other end string (typically \r\nERROR\r\n) or doesn't send any.
The last of them is recieving characters in interrupt. It's similar as the first solution. Advantage this solution is that the microcontroller can do other function.
If you want to communicate with module, you have to keep several conditions. 99% instructions has to be sent with
1.) Test of communication: This command try as first. You test a working module.
Send command: AT\r\n
Recieve message: AT\r\n\r\nOK\r\n
2.) PIN code: This command tests if the SIM card is without PIN code.
Send command: AT+CPIN?\r\n
Recieve message: AT+CPIN?\r\n\r\n+CPIN: READY\r\n\r\nOK\r\n
3.) Registration to the mobile network.
Send command: AT+CREG?\r\n
Recieve message: AT+CREG?\r\n\r\n+CREG: x,y\r\n\r\nOK\r\n
This value x means if the module is registrated in mobile network, home network or not.
Y value means technology (GSM, UTRAN, HSDPA and another).
Expected recieve message: AT+CREG?\r\n\r\n+CREG: 1,1\r\n\r\nOK\r\n
If message is AT+CREG?\r\n\r\n+CREG: 0,1\r\n\r\nOK\r\n, send AT+CREG=1\r\n command. This AT command enable access to mobile network (important during first setting)
4.) Signal measurement:
Send command: AT+CSQ?\r\n
Recieve message: AT+CSQ\r\n\r\n+CSQ: xx,y\r\n\r\nOK\r\n
xx is signal and y is bit error during transmission.
E.g. value 2 means -109 dBm, value 10 is -93dBm is sufficient for communication with BTS, value 15 is -83 dBm is good and value 20 and higher (-73dBm) is signal excellent.
There are main AT command which used for test connection to the mobile network or communications or signal measurement.
After registration to the mobile network, you can send SMS.
Type of message:
AT+CMGF?\r\n
If the recieve message is AT+CMGF?\r\n+CMGF: 1\r\n\r\nOK\r\n, format of SMS is TEXT (it's easy for next work). If the receive message is +CMGF: 0 format of message is PDU.
AT+CMGF=1\r\n
change format of SMS to TEXT type.
Sending SMS perform the following sequence of AT commands:
AT+CMGS="PhoneNumber"\r\n
After recieve character > send
Message\r\n0x1A\r\n
0x1A is character for sending message. It is Ctrl+Z sequency.
The message can be it:
AT+CMGS="+420XXXyyyyyy"
> Test SMS. https://chiptron.cz
Except this message: \r\n+CMGS: 10\r\nOK\r\n, where value 10 is number of sent SMS.
Reading unread message:
AT+CMGL="REC UNREAD"\r\n
If you change REC UNREAD for ALL, it cause list of all SMS or REC READ list of read SMS.
Delete all messages:
AT+CMGDA="DEL ALL"\r\n
Turn off module:
AT+CPOWD=1\r\n
Urgent turn off module:
AT+CPOWD=0\r\n
If you want to use GPS part of SIM908 module, you have to turn on GPS part:
AT+CGPSPWR=1\r\n
recieve message: AT+CGPSPWR=1\r\n\r\nOK\r\n
after, you have to do reset of module (cold start)
AT+CGPSRST=0\r\n
recieve message: AT+CGPSRST=0\r\n\r\nOK\r\n
Read data from GPS. You can perform with several NMEA message. Frequently is used GGA.
AT+CGPSINF=2\r\n
NMEA message GGA may like this:
$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
Turn off GPS part:
AT+CGPSPWR=0\r\n
Přijat? zpr?va: AT+CGPSPWR=0\r\n\r\nOK\r\n
Sources:
Datasheet, Reference Manual another information about SIM908
http://m2msupport.net/m2msupport/software-and-at-commands-for-m2m-modules/
List of AT commands: http://m2msupport.net/m2msupport/atcreg-network-registration/