Control and Monitor via SMS Part 2


Hi,everyone !!

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.


Hardware Required:

  1. GSM Modem
  2. SK40C
  3. URS232A
  4. Active SIM card
  5. Adapter 5A 2V
  6. Serial extension cable
  7. Jumper wires


Software required:

  1. Hyper Terminal


Quick Start – Interfacing GSM Modem with PC!!



  1. Insert a valid SIM card from any mobile provider into the SIM slot.
  2. Connect the GSM Modem to the supplied AC-DC adapter and also to the serial port of the PC.
  3. Select the correct COM Port in Hyper Terminal and set up the parameters as follows.clip_image005_thumb
  4. 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.clip_image006
  5. The GSM Modem should respond with “OK”.
  6. Now we can start sending the AT command to the GSM Modem.
  7. Use the following command to put the modem in text mode and it should respond with “OK”.clip_image008
  8. The GSM Modem should respond with “OK”.
  9. After that, we can send the SMS message with the following command:-clip_image009
  10. Replace the above phone number with your own number. The modem will respond with:clip_image010
  11. We can now type the message and send the message using the (CTRL+Z) key.clip_image011
  12. After few seconds, the modem will respond with the message ID of the message, indicating that the message has been sent correctly.clip_image012clip_image014                                                         “AT Commands to send a SMS 


  1. Set up the GSM Modem following step 1 – 7 in the previous section.
  2. Once the GSM Modem is ready, we can use a mobile phone to send a SMS to the modem.
  3. The following response received from the modem indicates a new SMS is received.clip_image015
  4. 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.
  5. To list out all the available SMS in the SIM card, we can use the following command:clip_image016
  6. The modem will respond with a list of SMS messages in the SIM card. 
  7. 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:clip_image018
  8. The modem will respond as follows:-clip_image019
  9.  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: clip_image020
  10. The modem will delete the message and return to “OK”.clip_image022                                     ” AT Commands to read and delete a received SMS”




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.


    poi                                                          “The LEDs can be turned on/off by sending SMS”


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. 

, , , , , , ,

Related Post

Simple steps to control Stepper Motor using 2Amp Motor Driver Shield and CIKU

PIC16F VS PIC18F:Analysis of PIC Mid-Range 8 bit family and Advanced 8-bits Family

Gesture Sensor (APDS9960) interface with SK40C+PIC16F877A


Leave a Reply

Your email address will not be published. Required fields are marked *