Increase your Embedded skills with our new online classes (from Just Rs750/-) for details click here

Home > Projects > GSM Modem Interface with PIC 18F4550 Microcontroller

GSM Modem Interface with PIC 18F4550 Microcontroller

July 5th, 2013

GSM Modem Interface with PIC 18F4550 Micro controller:

Description:
In this project we use PIC 18F4550 Micro controller in transmitter section keys are connected to PB0 to PB3. If we press the key PB0 the Pressed Key Value is transmitted to the micro controller section i.e receiver section . In the controller we pre programmed to open the door A. If we press the key PB1 means the particular port is enabled and it sends enabled signal to the receiver micro controller section. In that particular port we pre programmed to open the door B. Likewise we pre programmed for all four pins to do a particular task. At the same time the acknowledgement message send to the pre assigned mobile number through GSM Modem. Doing some slight modification in the code you can develop your own applications.

GSM Modem Testing Procedure:
1. Insert SIM Card into SIM Tray.
2. Connect Cross Cable Modem to Microcontroller.
3. Open Hyperterminal from Windows select COM Port and Set Baud Rate 9600.
4. Enter AT hyperterminal then ENTER Respond ‘Ok’ ACK from GSM Modem.
O.k will come modem is working fine.
Sending SMS from GSM Modem:
AT+CMGF=1 Press ENTER
Ctr+Z 0x0D and 0X0A for ENTER;
AT+CMGS=Mobile No
Dial voice Call AT Command:
ATD9000000000; //for Dial voice call through GSM Modem.
ATH Press Enter //Hang up the voice call.

Source Code:



//*************************************************************************************************************//

//Author:Embed4u Team
//Compiler: CCS Compiler for Pic Microcontrollers
//Website: www.embed4u.com

//*************************************************************************************************************//

#include<16f877a.h> //Replace pic 18f4550 without code modification its working
#include<stdio.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=16000000)//16MHZ Crystal
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void send_SMS_SIM1()
{
printf("at+cmgs=\"+919000000000"\n");//Enter Your Mobile Number1

            putc(0x0d);
            putc(0x0a);
            delay_ms(1000);
}
void send_SMS_SIM2() 
{
printf("at+cmgs=\"+919111111111\"\n");//Enter Your Mobile Number2

            putc(0x0d);
            putc(0x0a);
            delay_ms(1000);
}
void GSM_initialise()
{
printf("at+cmgf=1\n");

           putc(0x0d);
           putc(0x0a);
           delay_ms(1000);
}
void main()
{
   port_b_pullups(TRUE);
   GSM_initialise();
      while(1)
      {
         if(input(PIN_B0)==0)
         {
            send1();
            printf("****Test****\n\r");
            delay_ms(10);
            printf("ALERT!!! Door A has opened\n\r");
            delay_ms(10);
            printf("*******");
            putc(26);
            delay_ms(1000);
            
            send2();
            printf("****Test****\n\r");
            delay_ms(10);
            printf("ALERT!!! Door A has opened\n\r");
            delay_ms(10);
            printf("*******");
            putc(26);
            delay_ms(1000);
            
         }
         else if(input(PIN_B1)==0)
         {
            send1();
            printf("****Test****\n\r");
            delay_ms(10);
            printf("ALERT!!! Door B has opened\n\r");
            delay_ms(10);
            printf("*******");
            putc(26);
            delay_ms(1000);
            
            send2();
            printf("****Test****\n\r");
            delay_ms(10);
            printf("ALERT!!! Door B has opened\n\r");
            delay_ms(10);
            printf("*******");
            putc(26);
            delay_ms(1000);
            
         }
         else if(input(PIN_B2)==0)
         {
            send1();
            printf("****Test****\n\r");
            delay_ms(10);
            printf("ALERT!!! Door C has opened\n\r");
            delay_ms(10);
            printf("*******");
            putc(26);
            delay_ms(1000);
            
            send2();
            printf("****Test****\n\r");
            delay_ms(10);
            printf("ALERT!!! Door C has opened\n\r");
            delay_ms(10);
            printf("*******");
            putc(26);
            delay_ms(1000);
            
         }
         else if(input(PIN_B3)==0)
         {
            send1();
            printf("****Test****\n\r");
            delay_ms(10);
            printf("ALERT!!! Door D has opened\n\r");
            delay_ms(10);
            printf("*******");
            putc(26);
            delay_ms(1000);
           
            send2();
            printf("****Test****\n\r");
            delay_ms(10);
            printf("ALERT!!! Door D has opened\n\r");
            delay_ms(10);
            printf("*******");
            putc(26);
            delay_ms(1000);
           
         }
         delay_ms(2000);
         output_b(0xff);
      }

}

Suppose we want use voice call from GSM modem using Pic Microcontroller the following code is working in your Applications.
Voice Call Code:



//*************************************************************************************************************//

//Author:Embed4u Team
//Compiler: CCS Compiler for Pic Microcontrollers
//Website: www.embed4u.com

//*************************************************************************************************************//

#include<16f877a.h> //Replace pic 18f4550 without code modification its working
#include<stdio.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=16000000)//16MHZ Crystal
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void voice_call()
{
printf("ATD9000000000;\n");//Enter Your Mobile Number

            putc(0x0d);
            putc(0x0a);
            delay_ms(1000);
}

void GSM_initialise()
{
printf("at+cmgf=1\n");

           putc(0x0d);
           putc(0x0a);
           delay_ms(1000);
}
void main()
{
   port_b_pullups(TRUE);
   GSM_initialise();
      while(1)
      {
         if(input(PIN_B0)==0) //if Port pin B0==0 the voice call is activated
         {
           voice_call();
           
         }
        
         delay_ms(2000);
         output_b(0xff);
      }

}

Circuit:

R.F TWS434 Transmitter Circuit:

R.F RWS434 Receiver Circuit:

Video:

Comments are closed.