Thursday 5 December 2013

GSM Shield SIM900D with PIC16F877A

Hi there!..So this is my partial project for my research proposal on how I integrated my GSM Shield module, specifically the SIM900D, with the PIC16F877A microcontroller unit. In this project, I only constructed a sending process function by using a push-button. Therefore, every time I would press the push-button, a fixed message would be sent to a specific recipient. This is only a basic construction of understanding the GSM Shield function and its AT Commands.

The image that is shown below is the GSM Shield SIM900D that I used for my project. You can purchase this at http://www.e-gizmo.com/KIT/gsm%20shield.html for about 1,995.00 pesos.



Features and Specifications of GSM/GPRS Shield:
 • Industry proven SIMCOM SIM900D Module 
• Buffered UART provides additional layer of protection
• Fused power input
• On board LDO voltage regulator
• UART/SUART switch selectable port (gizDuino)
• On board manual power switch
• SIM Card Holder


Here is the circuit I made by integrating the PIC16F877A and the GSM Shield:




Be sure to connect the Tx of the GSM Shield to the Tx of the PIC and the Rx of the GSM Shield to the Rx of the PIC. Take note also that the GSM needs to be powered by a 1.5A and 5VDC supply and its ground must be COMMON to the ground of the circuit.

For the PIC16F877A programming code, I used a programming language which is the "MikroC Pro for PIC". MikroC has an awesome and numerous features of built-in libraries along with examples of small programs in order for the user to simply understand the functions. Here is my program code: (REMEMBER: This is only a sending process, it does not consist of a receiving capability yet.)



/*---------------------------FLEET MANAGEMENT SYSTEM-------------------------
      MikroC Programming by Kirk Macaraeg
-------------------------------------------------------------------------------------------*/

void GSM_Init(void);

void GSM_send(void);
void GSM_receive(void);

void main(void) {


TRISD=0b00000010;     //RD1 is an input

PORTD=0x00;                //The rest of RD pins are output

UART1_Init(9600);     //Initialize and establish communication at 9600 bps

Delay_ms(250);
UART1_Write_Text("AT+CMGD=1");  //Delete mesage sotred in inbox1
UART1_Write(0x0D);              //<CR>

while(1)

{

if(PORTD.F1==0)           //if pushbutton is pressed

{
  PORTD.F0=0;               //LED OFF

  GSM_Init();                   //calls GSM_Init function

  GSM_send();                 //calls GSM_send function

  PORTD.F0=1;                //LED1 blinks 3 times

  Delay_ms(250);

  PORTD.F0=0;

  Delay_ms(250);

  PORTD.F0=1;

  Delay_ms(250);

  PORTD.F0=0;
  Delay_ms(250);

  PORTD.F0=1;

  Delay_ms(250);

  PORTD.F0=0;

  Delay_ms(250);
  }


 }

}
/*----------------------------------------------------------------------
                      GSM INITIALIZING PROCESS
----------------------------------------------------------------------*/

void GSM_Init(void)

{
  UART1_Write_Text("AT\r");
  UART1_Write_Text("AT+CMGF=1");      //Text Mode
  UART1_Write(0x0D);                                //<CR>
  Delay_ms(250);
  UART1_Write_Text("AT+CMEE=2");      //Write Mode
  UART1_Write(0x0D);                               //<CR>
  Delay_ms(250);
  UART1_Write_Text("AT+CFUN=1");      //Full Phone Functionality
  UART1_Write(0x0D);                               //<CR>
  Delay_ms(250);
}

/*----------------------------------------------------------------------

                       GSM SENDING PROCESS
----------------------------------------------------------------------*/

void GSM_send(void)

{
  UART1_Write_Text("AT+CMGS=\"09429185691\"");    //send SMS to this number
  UART1_Write(0x0D);                              //<CR>
  Delay_ms(250);
  UART1_Write_Text("F.M.S. GSM with PIC Testing\r");  //message to be sent
  UART1_Write(0x1A);                                  //<CTRL+Z>
  Delay_ms(250);

}


Here is an actual video of what I have made:





Project made by: Kirk Benedict P. Macaraeg

3 comments:

  1. Hello. I just want to ask you can use the RS232 port of GSM module and connect it to PC and connect Rx/Tx pins to both PIC and GSM at the same time? Will the PC see what the PIC will encode to the GSM through the PC's Hyperterminal? Thank you.

    ReplyDelete
  2. its not working please help...

    ReplyDelete
  3. hi all, it is not working , program or eeprom data has invalid address [180003] for this device

    help me please

    ReplyDelete