###Arduino GSM Sketches
These are a collection of sketches to be used with the Arduino GSM Shield. They focus primarily on using the shield through serial communication instead of using the Arduino GSM library. I found the library to be clunky and not allow me to do what I wanted to do.
As an initial setup, simple upload the basic-gsm-serial-communication.ino sketch to your Arduino with the shield. Once uploaded, use an application which lets you communicate over serial directly. I prefer to use Cool Term. Once you're connected over USB, push and hold the power button on the Arduino GSM shield until you see the status LED solid and the net LED blinking.
List of AT commands: http://arduino.cc/en/uploads/Main/Quectel_M10_AT_commands.pdf
####Notes on modifiying the Arduino SoftwareSerial Library
In working with the Arduino GSM shield, I kept finding text messages were only being halfway delivered. Meaning I would only see have the message. This happened with a couple of the AT Commands that I was using which return larger amounts of information. The problem I kept encountering is that the serial buffers in both the SoftwareSerial Library and the GSM library were too small causing the messages and information to be incomplete. I simply edited those variables in the library in order to get things to work properly.
If using the SoftwareSerial Library, modify the SoftwareSerial.h file to increase the buffer from 64 to 256.
This can be done by:
- Go to the Arduino application (Applications > Arduino) and right click. Select show package contents
- Find the file Resources > Java > libraries > SoftwareSerial > SoftwareSerial.h
- Change the line: _#define SS_MAX_RX_BUFF 64 to _#define SS_MAX_RX_BUFF 256
- Save file
For the GSM Library:
- Go to the Arduino application (Applications > Arduino and right click. Select 'Show Package Contents'
- Find the file Resources > Java > libraries > GSM > GSM3CircularBuffer.h
- Change the line: __#define BUFFERSIZE 128 to __#define BUFFERSIZE 256
- (I also changed the BUFFERMASK value to 0xFF though I'm not sure that is necessary)
- Save file
####Notes for using AT Commands All of these commands work on the Quectel M10 GSM module which is used on the Arduino GSM Shield. If using other GSM modules, consult the data sheet or manual for that specific module. Each company adds and uses different commands which may cause confusion. That being said, there is a list of standard AT Commands which work across all modules. They too can be found online. Below are all most common commands.
- AT Check to see if the module is active. Should return 'OK'
- AT+CREG? Is the module registered to the network? Set mode first: AT+CREG=2
- AT+COPS? What network is the module registered?
- AT+CMGF=1 This puts the module into text mode so messages can be sent/received
- AT+CMGS="number",129, <body of message> <hex return character '1A'> Send a text message. When using CoolTerm, enter this command, the use 'Command+T' to bring up another window. This will let you type ASCII and Hex. Type your message, and the add '1A' as Hex. Note: When sending a message through OpenBTS, you do not need to use the 129.
- AT+CMGL="ALL" Lists all text messages that are on the device (or network)
- AT+CMGR=<index> Read SMS message at index number
- AT+QBAND? What band am I on?
- AT+CIMI Get the IMSI number from the module
- AT+CSQ Check the signal strength
####Notes on sending an SMS with AT Commands There are a series of commands which must be executed in order to send an SMS using AT Commands. First the module must be in text mode. Then, you must send the AT+CMGS command with the destination number, 129, body of the message and a return character. When using Cool Term this character must be a hex character. Not sure if this is always the case.
- AT+CMGF=1 Set the module into text mode
- AT+CMGS="destination phone number", 129, <body of message> <hex return character '1A'> Note: When sending SMS messages through OpenBTS you do not need to use the 129 code.
####Notes on receiving SMS messages The module must be in text mode. Then you can query the network for all of the messages or a message at a specific index.
- AT+CMGF=1 Set the module into text mode
- AT+CMGL="ALL" List all text messages that are on the network
- AT+CMGR=<index> read an SMS at a specific index
####Notes on deleting SMS messages Deleting messages is very simple but very important to do as the buffer size of the GSM is not very big. This means that it can only display two or three messages at a time when you use the command AT+CMGL="ALL". By deleting old messages, you will be able to see the newest message.
- AT+CMGD=<index> delete an SMS message at a certain index
####IMSI/TMSI As mentioned above, you can access the IMSI number with the command AT+CIMI. The TMSI is also available through accessing the SIM card, though a bit more complicated. The AT Command is AT+CRSM which provides access to the SIM card information. To access the TMSI, use the command:
AT+CRSM=176,28542,0,0,11
The TMSI is the first eight digits in the response value. These are in HEX format.