The GSM module used in this project is a SIM900 based module which can communicate with other devices using RS232 serial communication port. It works on 9V power supply and the image of the same is given below:
Fig. 2: SIM900 GSM Module connected to Tx pin of Arduino board module through max232
TTL logic levels a max232 IC is used to make a bi-directional conversion between the RS232 and TTL logic levels. The Tx pin of the Arduino board is connected to the Rx pin of the GSM module through the max232 and the Rx pin of the Arduino is connected to the Tx pin of the GSM module using max232 itself.
The working of this project is explained based on the Arduino pro-mini board and the IDE version 1.0.3 for windows. The advantage of this board is that it comes in very small in size; any kind of connectors can be soldered on its periphery according to our requirements. It is very breadboard friendly and occupies very less space of a typical breadboard.
The image of the Arduino pro-mini board and the Arduino IDE are shown below:
Fig. 3: Typical Arduino Pro-Mini Board
Fig. 4: Arduino IDE Software Window
Since the Arduino pro-mini board has no circuitry for interfacing it with the serial port or the USB port of the PC, an external USB to TTL converter board is required to connect it with the PC. This hardware helps in programming the Arduino board and also helps in the serial communication with the USB port of the PC.
Fig. 5: External USB to TTL converter board for programming Arduino and serial communication
It is assumed that the reader has gone through the project how to get started with the Arduino and tried out all the things discussed there.
The code written in the Arduino is able to communicate with the GSM module using AT commands. The AT commands are send or received from the module using the serial communication functions provided by the Arduino library. The functions like Serial.begin() which helps to initialize the serial port with a given baud rate, Serial.write() to send a data to the serial port, Serial.available() and Serial.read() functions to read data from the serial port are used in this project and they are already discussed in previous projects on how to do serial communication with the Arduino, how to send and receive serial data using arduino and how to do serial debugging with the Arduino.
GSM modules respond “OK” when it receives the command “AT” and it is the best way of check communication between the module and the microcontroller.
AT+CMGS – This command is used to send the SMS from a GSM module. The command should be followed by the number to which the message needs to be sent. After a Carriage return one can send the SMS text to the GSM module which is then send after it receives a <CTRL+Z>
The syntax for sending a SMS using the AT commands with a GSM module is shown below;
SYNTAX : AT+CMGS=”mobile_number” <ENTER><write the text><CTRL+Z>
For example to send an SMS “hello” to the number 123456789 the following command can be used;
The implementation of the project which can receive the SMS text and the number to which it needs to be send from the PS2 keyboard and use them to send SMS with the help of the GSM module is represented using the following block diagram:
Fig. 6: Block Diagram Of Sending And Reciving SMS Using PS2 Keyboard and GSM Module With Arduino
The code for this project is so written that it will send the string “AT+CMGS=”” to the GSM module first and then waits for the user to enter the required number using the standard PS2 keyboard. The Arduino reads the data from the PS2 keyboard using functions from the custom PS2 library file called “PS2Keyboard.h” which has all the necessary routines for accessing a PS2 keyboard. There are basically three functions which the user can directly make use in their code and are namely keyboard.begin()”,keyboard.available() and “”. The details of how to use these functions to interface a PS2 keyboard is already discussed in a previous project on how to interface the PS2 keyboard with the Arduino.
As the user types the number to which the SMS needs to be sent the code reads those letters from the keyboard and directly sends those numbers to the GSM module using the serial communication functions. Once the user presses the ENETR key the code stop reading from the keyboard for a while and sends the string ““r” which forms the part of the message sending command before the actual text. The code then waits for the user to enter the SMS text. Once the user starts typing the text on the keyboard the Arduino again redirect the letters to the GSM module till the user presses the ENETR key again. Once the ENETER key is pressed the code again stops reading from the keyboard and sends the value equivalent to the <CTRL+Z> to the GSM module to complete the message sending command.
Try to send the command using the PC with the help of any serial monitoring software and make sure that the module is sending message to the specified number. Then one can verify and upload the code which can send the same commands to the Arduino board as explained in the project how to get started with the Arduino. Once the board is reset after successfully uploading the code the Arduino sends the same command to the GSM module enabling it to send SMS to the number specified in the code.
Make sure that the GSM module has been turned on at least 2 minutes before the Arduino board start sending the commands so that the GSM establish a communication with the cellular network corresponding to the SIM card inserted in it.