How to: Send an SMS with PIC16F628A and SIM900A

March 03, 2016 by Jens Christoffersen

In this article I'll show you one way of sending an SMS using a PIC 16F628A and a SIMCOM SIM900A module.

In this article I'll show you one way of sending an SMS using a PIC 16F628A and a SIMCOM SIM900A module.

In a previous article, I did a firmware upgrade on my GSM module, so it would get registered to a European service provider. In that article, I briefly scratched the surface on AT commands and instructions.

In this article, I'll take it one step further. I'll send an SMS with my PIC 16F628A.


Complete breadboard.


To get the most out of this article, you'll need the following:

  • SIMCOM SIM900A module, upgraded to be able to get registered to a European service provider.
  • A computer running MPLAB X, and the XC8 compiler.
  • A PIC 16F628A and an MAX232.
  • A way to program your PIC, I'm using a PICkit 3.
  • Breadboard, jumperwires, and an LCD.
  • Parts from the parts list.


When the SIM900A module is powered up, a lot of things are going on. One of them are that the module is trying to get registered to a network. When it is successfully registered to a network, we can send SMS, receive SMS and get the service providers name. The main goal for this article is to send an SMS to a predefined number. To get the service providers name is a bonus.

The module communicates with the surrounding circuitry with TTL or with the onboard MAX232 IC. I'll be using the MAX232 interface. This means that all communication is done with the PICs UART, and all our commands from the PIC will be sent to the UART port with printf.


I've connected my breadboard like this:

Click on image for full size resolution.


Since I'm using an MAX232, I can use that to see and troubleshoot what the microcontroller is sending to the GSM module. To do this, I disconnect the GSM module, and connect my serial cable, and open up GtkTerm. Baud setting: 9600-8-N-1.


Connection to a computer to troubleshoot.


This is what the microcontroller is sending to the GSM module. The first three lines are only to verify that serial communication is working and to see what I'm sending. The last two lines are instructions to the GSM module.


I'm not getting a reply from the GSM module since it's not connected.


This is a screenshot of the bom.ulp from EagleCAD.


Although the software is commented, I'll go through some parts of it here. When the PIC is powered up, a short welcome message is displayed. Then a 15-second countdown starts. I've put in this countdown, for two reasons:

  1. Allow the GSM module to get registered.
  2. A visual display which shows the user that something is happening and the PIC is working.

When the countdown is finished, the PIC sends the command:


It is important to add Carriage return – New line, the \r\n. This tells the module to execute the text string that has arrived in the modules buffer.

The module then returns the string:

+CPOL: 1,0,” N NetCom”,1,0,1

This means that the module is registered to NetCom. NetCom is the service provider's name. It's this name we want to display on the LCD. Now we need to extract the name from the string. The way I do that, is to read the whole string into an array. Then I'll search for the “-signs". When the “-signs" are found, I store their position in another array. This is what I call "start and stop". Then I use the values from "start and stop" to display the characters in between on the LCD. Perhaps not the fanciest way of doing it, but it is simple.



To send the SMS I have to send some more AT commands.

First, I send the command:


This is the Select SMS Message format. The 1 tells the module to go into text mode.

Second, I send the command:


“receiver” is the number I want to send a message to.

Third, I send the command:

Message from PIC16F628A\r\n

This is the actual message. Since the message has multiple characters, including spaces, there's a nifty way to tell the module where the end of the message is. I have to send the EOF sign, which happens to be CTRL-Z.


This is the EOF character in the regular ASCII table. The module will now send the message.

Use this link to find documents regarding the SIM900A module.


You can download the c-source code from the link.


You should now be able to get your service providers name, and send an SMS with the SIM900A module, on a European network.

Pictures and video

Give this project a try for yourself! Get the BOM.

  • G
    GrahamRounce March 11, 2016

    Do we need a SIM card to make this work?

    Like. Reply
  • G
    GrahamRounce March 11, 2016

    Do we need a SIM card to make this work?

    Like. Reply