top of page

GSM900 Module Read Message using PIC16F877A micro-controller

By Bernice Zuiya

                          Using a micro-controller which have a UART (Universal Asynchronous trans-receiver module) it is easy to interface directly with the GSM900 module without intervention of a USB to Serial converter, in this project I am going to give a short code written in embedded C language using the mikroC compiler for PIC

Introduction

Working :

                 A PIC16F877A is used to sends ATs Command to GSM900 module read and display the message to an LCD Display module, the connection between the module and the controller should be respected with respect of  common ground, here we can remind that the Rx and Tx of both part are crossed; which means RX of the module is attached to TX of the controller and inversely for the TX of the module but the ground should be common, after the process of sending AT Commands the Message will be displayed on LCD Display

Circuit Diagram

         The circuit diagram shown below is the very basic diagram required for GSM900 module read SMS Using the 16F877A micro-controller And display the message to an LCD display, you need to respect the connections to get best result.

  • a resistor of value 4k7 ohm is connected in series with +5 volt and the reset pin (1st pin)

  • Q1 is the crystal oscillator in this case its frequency oscillation is 20 MHz.

  • supply: the circuit is connected with a voltage maximum equal 5 volt

  • C1 & C2 are of 22pF.

Code :

sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
char txt_1[60];
char coke;
unsigned int i,j;
char *txt1;
void main(void){
UART1_Init(9615);
LCD_Init();
LCD_Cmd(_LCD_Clear);
LCD_Cmd(_LCD_Cursor_off);
    Delay_ms(100);
    txt_1[59]='\0';
    UART1_Write_Text("AT+CMGR=1");
    UART1_Write(13);
    UART1_Write(10);
 while(1){
    if(UART1_Data_Ready())
      {for(i=0;i<73;){if(UART1_Data_Ready()){coke=UART1_Read();i++;}}
                   for(i=0;i<58;) // 58 characters should be inserted in txt_1 array
                         {
                              if(UART1_Data_Ready())
                                   {
                                      txt_1[i] = UART1_Read();
                                      i++;                      
                                   }
                        } // end loop for(i=0;i<58;)
                        LCD_Out(1,1,txt_1);
                            for(j=0;j<60;j++){
                                 LCD_Cmd(_LCD_SHIFT_RIGHT);
                                 LCD_Out(2,1,"             ");
                                 Delay_ms(800);
                       }
                  for(j=0;j<60;j++){
                                LCD_Cmd(_LCD_SHIFT_LEFT);
                                LCD_Out(2,1,"             ");
                                Delay_ms(800);
                         }
                 }
          }
}

This code were written using mikroC compiler software, you can copy and compile it or modify it as well, this is used For GSM900 Read SMS using PIC16F877A

Download the full project here

bottom of page