Arduino GSM shield
This is a very low cost and simple Arduino GSM and GPRS shield. We use the module SIMCom SIM900 . It’s the cheaper module now avalaible in the market. The module is not simple to mount by an hobbyst, so we use the Breakboard TDGGSM_900 that we presented here .
You can buy the GSM module premounted here .
This is the GSM_shield library documentation:
This Library is derived from Hwkitchen’s GSM Library http://www.hwkitchen.com and include the NewSoftSerial library to comunicate using the pin 4 (RX) and 5 (TX).
You can also use the pin 0 and 1 (RX and TX) but you must disconnect the module to upload the sketch (so it’s not very nice), and you must modify the library.
How install the library for Arduino
After downloading of the GSM_Shield Library unzip the GSM_Shield folder to Arduino
Folder\libraries\ (es. C:\Programs\arduino-0022\libraries\GSM_Shield)
In the GSM_Shield.zip you can find the library to comunicate with gsm module and the file for use the NewSoftSerial.
GSM_Shield library is created as standard class with the Gsm_Shield.cpp and Gsm_Shield.h source files. GSM_Shield class is based mainly on the serial communication
between the Arduino board and the GSM module placed on the GSM Shield. There are used standard AT commands for the communication with the GSM Module.
The Current version of library uses blocking version of communication.
It means that the program is blocked until the communication function is finished – so until required data are sent and required answer is received. The Advantage of that blocking approach is that it is easy to
understand the program flow. On the other hand there is also disadvantage that we can’t use the processor resources in the time when the program just waits for the incoming data.
Note: please pay attention to serial comunication mode. With the serial hardware (pin 0 and 1) you can reach the default baudrate of the module SIM900 (115200). But if you use the pin 4 and 5 the NewSoftSerial library can’t support (receive) the baudrate, so you must chose a lower baudrate.
With the command TurnOn(baudrate) you turn on the module and fix the baudrate. e.g. TurnOn(9600);
There are described important functions for the end user in this document.
The GSM_Shield Library contains also some functions that are used internally
and are not described in the document. It is also possible to use these
functions by the end user of course as they are defined as public but there
is needed to check the library source code with notes.
returns library version in format XYY -it means X.YY (e.g. 100 means vers. 1.00)
turns on the GSM module in case module is off and sends some initialization AT commands which are possible to send before registration -> InitParam(PARAM_SET_0)
Should be used at the beginning of the sketch in the setup() function.
Set also the module baudrate (Note: if you use the hardware serial, there are no limit to the baudrate, 115200 is possibile. But using the pin 4 and 5 the NewSoftSerial must be use and the baud limit is 57600).
baud value possibile: 4800, 9600, 19200, 38400, 57600, 115200(no use with this library which include NewSoftSerial)
void InitParam(byte group)
Sends parameters for initialization of GSM module
group: 0 – parameters of group 0 – not necessary to be registered in the GSM
1 – parameters of group 1 – it is necessary to be registered
void Echo(byte state)
Function to enable or disable echo
Echo(1) enable GSM echo mode
Echo(0) disable GSM echo mode
checks if the GSM module is registered in the GSM net.
This method communicates directly with the GSM module in contrast to the method IsRegistered() which reads the flag from the module_status
(this flag is set inside this method)
must be called regularly at the one place in the main sketch loop
(recommendation repeat time is from 1sec. to 10 sec.)
REG_NOT_REGISTERED – not registered
REG_REGISTERED – GSM module is registered
REG_NO_RESPONSE – GSM doesn’t response
REG_COMM_LINE_BUSY – comm line is not free
returns flag if the GSM module is registered in the GSM net
this method does not communicate directly with the GSM module,
just reads the flag so it is very fast unlike CheckRegistration()
which takes more than 20msec.
it is recommended to use this function everytime it is necessary to use some GSM function which needs GSM module is registered – checking ingoing SMSs, checking calls etc.
0 – not registered
>0 – GSM module is registered
checks call status
CALL_NONE – no call
CALL_INCOM_VOICE – incoming voice call
CALL_ACTIVE_VOICE – active voice call
CALL_NO_RESPONSE – no response
byte CallStatusWithAuth(char *phone_number, byte first_authorized_pos, byte last_authorized_pos)
checks status of call(incoming or active) and makes authorization with specified SIM positions range
parameters and return values:
phone_number: a pointer where the tel. number string of current call will be placed so the space for the phone number string must be reserved
first_authorized_pos: initial SIM phonebook position where the authorization process starts
last_authorized_pos: last SIM phonebook position where the authorization process finishes