GSM/ GPRS modem can be connected directly to your computer’s serial port for wireless GSM communications including sending and receiving text messages. It can also be connected to your remote RS232 serial equipment allowing you to ‘dial up’ your system for remote management. This includes data loggers such as Data Taker and Pace Scientific. GPRS connectivity also allows you to integrate this modem in your application for an ‘always on’ remote management system. Available with a built-in TCP/IP stack and you can easily create software to interface to the modem over your standard internet connection.
Covered in this tutorial:
- Material required (Hardware and software)
- Additional information about the gesture sensor
- Code overview
#If you have a further inquiry about this tutorial, please post it in our technical forum as we seldom check the comment section in the tutorial site.
- Hyper Terminal
Quick Start – Interfacing GSM Modem with PC!!
- Insert a valid SIM card from any mobile provider into the SIM slot.
- Connect the GSM Modem to the supplied AC-DC adapter and also to the serial port of the PC.
- Select the correct COM Port in Hyper Terminal and set up the parameters as follows.
- Power on the GSM Modem and wait for it to initialize. While waiting, we can use the following command to make sure we can communicate with the GSM Modem.
- The GSM Modem should respond with “OK”.
- Now we can start sending the AT command to the GSM Modem.
- Use the following command to put the modem in text mode and it should respond with “OK”.
- The GSM Modem should respond with “OK”.
- After that, we can send the SMS message with the following command:-
- Replace the above phone number with your own number. The modem will respond with:
- We can now type the message and send the message using the (CTRL+Z) key.
- After few seconds, the modem will respond with the message ID of the message, indicating that the message has been sent correctly. “AT Commands to send a SMS “
- Set up the GSM Modem following step 1 – 7 in the previous section.
- Once the GSM Modem is ready, we can use a mobile phone to send a SMS to the modem.
- The following response received from the modem indicates a new SMS is received.
- The last character indicates the memory index number, we use this index to read or delete this message. In this case, the index number is 1.
- To list out all the available SMS in the SIM card, we can use the following command:
- The modem will respond with a list of SMS messages in the SIM card.
- To read a single message, we have to use the read command. We must first know the index of the message. For instance, to read the message on memory location 1, we use:
- The modem will respond as follows:-
- Once we have read a message, we can free the memory by deleting the message from the storage. For instance, to delete the message on memory location 1, we use:
- The modem will delete the message and return to “OK”. ” AT Commands to read and delete a received SMS”
INTERFACING GSM MODEM WITH URS232A!!
After having the basic idea on how to use a GSM modem for sending and receiving SMS, we can now start to make a mini project – GSM Enabled Smart Home.In this project, we use the SK40C together with URS232A.
“Components for GSM Enabled Smart Home”
Before we go further to discuss the coding part, let’s take a look at how this thing works.
When the SK40C is turned on, we need to wait until the GSM modem to initialize and “Ready” to be shown on the LCD.
“Ready” will be shown when the GSM modem has been initialized.
When SW1 on SK40C is pressed, it will send a SMS “Warning: Switch 1 has been triggered!” to the owner’s mobile phone.
” SMS will be sent to the mobile phone when SW1 is triggered”
The owner can also control the LED on the SK40C. To turn on the LEDs, type “on” and send the SMS to the GSM modem. Type “off” to turn off the LEDs.
In this section, we will look at the firmware to interface with the GSM modem. Only the important parts will be discussed.
Let’s start with two of the most important functions in this example. The first one is the function to send an AT command to the GSM modem and the second one is to read a line of string from the modem.
“Function to send an AT command to the GSM modem”
“Function to receive a line of string from the GSM modem”
Right after powering up the SK40C, we need to initialize the GSM modem and wait until the “Call Ready” string is received from the modem. We need to make sure that we power-up the GSM modem first so that it’s ready to communicate when we turn on the SK40C. The following figure is the code snippet to initialize the GSM modem.
“Code snippet to initialize the GSM modem”
If the GSM modem has been set up successfully, “Ready” will be shown on the LCD. Now the program is waiting for the user input either from the push button or the SMS. If SW1 is pressed, the following code will be executed to send an SMS to notify the house owner. Please remember to change the highlighted number to your own mobile number.
“Code snippet to send a SMS to the house owner when SW1 is triggered”
If there is a new SMS received by the GSM modem, the program will read the content of the SMS and turn on/off the LEDs accordingly.
“Code snippet to read a SMS and turn on/off the LEDs accordingly”
In a nutshell, GSM modem makes remote controlling and monitoring possible without needing long range wireless transceiver provided the GSM modem is located within the coverage area of any mobile provider. Besides smart home, GSM modem is also widely used together with the GPS module as a security system for automobile. When the car is stolen, the GSM modem can send the GPS location of the car to the owner and the owner can shut off the engine of the car by just sending a SMS.