In connection with today’s advance technology and field of embedded electronics project, interfacing GSM module with pic microcontroller is very important for remote and wireless communication. GSM stands for Global system of mobile communication is widely used chip and reliable mobile network. If we done interfacing GSM module with pic microcontroller then we can use this huge GSM network as input out output for our project.
In my project I use GSM module for sending SMS to a specified GSM mobile number. And here you can learn how we did interfacing GSM module with pic microcontroller. Here we did interfacing of GSM module with PIC16F877 microcontroller. So to complete our project we are used
1) PIC16F877 Microcotroller
2) SIM300 GSM module ( I used NOKIA 5130c Mobile phone as a GSM module)
3) Serial cable (For interfacing between Microcontroller and GSM module)
Project Objective:
To complete the project we should follow some steps
1) Test the simple AT Command.
2) Connect a call to a GSM mobile number (Dial a number).
3) Send a text message to a mobile number
Now question is how we test AT command?
You can easily test it on windows Hyperterminal software. See bellow picture how it look like.
Here you can find the step by step process of how we test AT command? Must see the video
AT Command:
AT+CMGF Message Format : This command is used to select SMS protocol data unit (PDU) mode or SMS Text mode.
AT+CSCS Select TE character set : This command informs the data card of which character set is used by the TE. The data card is then able to convert character strings correctly between TE and ME character sets.
AT+CMGS Send Message : Sends a message from a TE to the network (SMS-SUBMIT). The message reference value <mr> is returned to the TE on successful message delivery. Sending can be cancelled with the <ESC> character. <ctrl-Z> must be used to indicate the ending of the message body.
Circuit Diagram:
Bellow you will see the Circuit Diagram of interfacing GSM module with pic microcontroller
Now to run this project you need the Embedded C Code. I write the C code on Mikcro c Pro for Pic bellow you will see the C-Code
// Purpose : To send SMS from PIC Microcontroller.
// Author : Subham Dutta
// Date : 03-01-14
// Website : www.nbcafe.in
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
void main() {
int a[10];
lcd_init();
Lcd_Cmd(_LCD_CLEAR);
lcd_out(1,1,”Send SMS to”);UART1_Init(9600); // Initialize UART module at 4800 bps
UART1_Write_Text(“AT+CMGS=”);
Delay_ms(1000);
lcd_out(2,1,”9800220107″);
UART1_Write(0x22); //” double qoute
Delay_ms(2000);
UART1_Write_Text(“9800220107”); // Your Telephone Number cd_chr_cp(uart_rd);
UART1_Write(0x22); //” double qoute
UART1_Write(0x0D); // mean Enter
Lcd_Cmd(_LCD_CLEAR);
lcd_out(1,1,”MASSAGE:”);
lcd_out(2,1,”WWW.NBCAFE.IN”);
Delay_ms(2000);
UART1_Write(0x22);
UART1_Write_Text(“WWW.NBCAFE.IN”); //My Text Test
UART1_Write(0x22); //” double qoute
Delay_ms(2000);
UART1_Write(26); //Ctr +Z
Delay_ms(2000);
UART1_Write(0x0D); // mean Enter
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
lcd_out(1,1,”SEND”);
lcd_out(2,1,”SUCCESSFULLY”);
}
For Proteus circuit diagram and how It simulate? must see the video given bellow.
32 thoughts on “Interfacing GSM module with PIC Microcontroller”
Thanks realy awsom post and help me lot
thanks
hi Subham Dutta,
The coding suitable for PIC C Compiler?
Regards,
wen
Hi wen this code is suitable for Mikcro c pro for pic and personally it is good software with huge library backup.
Mikcro c Pro same with PCW?
what you mean by PCW?
Hi Shubham,
What do is –double quote– written in code
In AT command you have to send (“) (double quote) as a character and ASCII code of double code is (0x22). so send over UART i write command
UART1_Write(0×22); //” double quote
hope may i clear you?
hellow the code is ok.i want now to receive sms from gsm and display it to lcd.please i need source code for this help me.thanks
it depend on which GPS MODEM you used. Please see the datasheet of that modem their you must find that code.
thanks
subham
How can I get the text repeatedly for a certain gap of time? Plz hlp me…..
Thanks
Ranjan
hi ranjan from where you want to get the text please mansion.
Thank you for sharing! Great information! Which GSM module are you using? Also, can any PIC recognize the ASCII (0x22) double quote character? And (0x0D) as enter?
yes any pic can recognize those ASCII
Hi Shubham sir I am from IT background and I am try your code mentioned above but I am getting errors. Please could you send me the project file of this mikro c pro software for this interfacing
What should i do if i want to connect a lm35 with it and display the temperature in a mobile phone through gsm modem?
smart work, i tried every thing is ok but it can not send sms where is be my problem
hey the program u have given is it the complete program ???
please help im not receiving any sms when using the program in proteus
sir,
Can i use the content of your project as my final year project?
Thanx & Regards,
Ranjan Tarafder
yes you can and please inform us after completing your project wish you very good luck for your project.
Thank you very much. Yes i will do reply you as soon as it is completed…..
Please can u give me or upload this complete this project, so it will help me as a demo for my project (gsm based smart protection using pic 18f452). Please upload proteus files with Hex files . Thanks
can you help me please i want to know if i follow those steps i’ll be able to send a variable sms to un phone help please !!
yes you can
why i cannot connect modem in device manager with my iphone?
so i cannot type in hyperterminal
Good information everything works thank you.
please say..
how to interface zigbee with pici6f877a
please if u HAVE a usb programmer schematic pliz forward it to my mail at absolomgapara@gmail.com
the above code is showing error in mickro c, what should I do?
can any one plz help me in my project IR REMOTE BASED CONTROLLING HOME APPLIANCES USING PIC16F877 can any 1 plzz as fast as much with CIRCUIT DIAGRAM & PROGRAM OR ANY 1 IN THAT my Simulator is MPlab
Sir, I refer all but i have problem in interfacing of mobile bluetooth to pic 18f452
Comments are closed.