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:
1
//**********************************************************
***************************************************//
2
3
//Author:Embed4u Team
4
//Compiler: CCS Compiler for Pic Microcontrollers
5
//Website: www.embed4u.com
6
7
//**********************************************************
***************************************************//
8
9
#include<16f877a.h> //Replace pic 18f4550 without code modification its working
10
#include<stdio.h>
11
#fuses HS,NOWDT,NOPROTECT,NOLVP
12
#use delay(clock=16000000)//16MHZ Crystal
13
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
14
void send_SMS_SIM1()
15
{
16
printf(βat+cmgs=\β+919000000000β³\nβ);//Enter Your Mobile Number1
17
18
putc(0x0d);
19
putc(0x0a);
20
delay_ms(1000);
21
}
22
void send_SMS_SIM2()
23
{
24
printf(βat+cmgs=\β+919111111111\β\nβ);//Enter Your Mobile Number2
25
26
putc(0x0d);
27
putc(0x0a);
28
delay_ms(1000);
29
}
30
void GSM_initialise()
31
{
32
printf(βat+cmgf=1\nβ);
33
34
putc(0x0d);
35
putc(0x0a);
36
delay_ms(1000);
37
}
38
void main()
39
{
40
port_b_pullups(TRUE);
41
GSM_initialise();
42
while(1)
43
{
44
if(input(PIN_B0)==0)
45
{
46
send1();
47
printf(β****Test****\n\rβ);
48
delay_ms(10);
49
printf(βALERT!!! Door A has opened\n\rβ);
50
delay_ms(10);
51
printf(β*******β);
52
putc(26);
53
delay_ms(1000);
54
55
send2();
56
printf(β****Test****\n\rβ);
57
delay_ms(10);
58
printf(βALERT!!! Door A has opened\n\rβ);
59
delay_ms(10);
60
printf(β*******β);
61
putc(26);
62
delay_ms(1000);
63
64
}
65
else if(input(PIN_B1)==0)
66
{
67
send1();
68
printf(β****Test****\n\rβ);
69
delay_ms(10);
70
printf(βALERT!!! Door B has opened\n\rβ);
71
delay_ms(10);
72
printf(β*******β);
73
putc(26);
74
delay_ms(1000);
75
76
send2();
77
printf(β****Test****\n\rβ);
78
delay_ms(10);
79
printf(βALERT!!! Door B has opened\n\rβ);
80
delay_ms(10);
81
printf(β*******β);
82
putc(26);
83
delay_ms(1000);
84
85
}
86
else if(input(PIN_B2)==0)
87
{
88
send1();
89
printf(β****Test****\n\rβ);
90
delay_ms(10);
91
printf(βALERT!!! Door C has opened\n\rβ);
92
delay_ms(10);
93
printf(β*******β);
94
putc(26);
95
delay_ms(1000);
96
97
send2();
98
printf(β****Test****\n\rβ);
99
delay_ms(10);
100
printf(βALERT!!! Door C has opened\n\rβ);
101
delay_ms(10);
102
printf(β*******β);
103
putc(26);
104
delay_ms(1000);
105
106
}
107
else if(input(PIN_B3)==0)
108
{
109
send1();
110
printf(β****Test****\n\rβ);
111
delay_ms(10);
112
printf(βALERT!!! Door D has opened\n\rβ);
113
delay_ms(10);
114
printf(β*******β);
115
putc(26);
116
delay_ms(1000);
117
118
send2();
119
printf(β****Test****\n\rβ);
120
delay_ms(10);
121
printf(βALERT!!! Door D has opened\n\rβ);
122
delay_ms(10);
123
printf(β*******β);
124
putc(26);
125
delay_ms(1000);
126
127
}
128
delay_ms(2000);
129
output_b(0xff);
130
}
131
132
}
For more detail: GSM Modem Interface with PIC 18F4550 Microcontroller