Marabe
Newbie level 4
- Joined
- Nov 24, 2012
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,333
hello everyone.
i am working on a project called GSM Based home security alarm.i am using pic16f887 and a m-q6 gas sensor and a pir motion sensor.i have build a motion sensor circuit on breadboard without the gas sensor and it works perfectly well.now i wanted to connect the gsm module which is the siemens TC35 module to the motion sensor circuit,i have used max232 as the level shifter.the problem i have is,i cant get the sms on my fone when using pic16f887 but i can send and make a call using the gsm modem on the hype terminal.i have attached the my c code and the manual of the modem i am using.please help me as i am left with two days before the presentations. below is my c code.
unsigned int motion_rd, gas_rd;
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 top[] = "GSM BASED";
char bottom[]="SECURITY SYSTEM";
char txt1[] = "0";
unsigned int alarmCounter = 0;
void SendMessage();
void main()
{
uart1_init(9600);
delay_ms(100);
ansel=0x03;
anselh=0;
c1on_bit=0;
c2on_bit=0;
TRISA = 0XFF;
TRISD = 0;
PORTD = 0;
Sound_Init(&PORTB,6);
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); //clearing display
Lcd_Cmd(_LCD_CURSOR_OFF); // turning off the cursor
Lcd_Out(1,4,top);
Lcd_Out(2,1,bottom);
adc_init();
do
{
// detect motion
motion_rd = ADC_read(2);
gas_rd = ADC_read(3);
if( gas_rd < 5)
{
IntToStr(gas_rd,txt1);
Lcd_Cmd(_LCD_CLEAR); //clearing display
Lcd_Out(1,2,"SYSTEM ENGAGED");
Lcd_Out(2,1,txt1);
//Lcd_Out(2,1,"GAS LEAKAGE");
// Lcd_Out(2,1,"GAS LEAKAGE");
alarmCounter ++;
//gas_rd = 0;
Delay_ms(300);
}
if(motion_rd > 1)
{
IntToStr(motion_rd,txt1);
Lcd_Cmd(_LCD_CLEAR); //clearing display
Lcd_Out(1,2,"SYSTEM ENGAGED");
// Lcd_Out(2,1,txt1);
Lcd_Out(2,1,"MOTION DETECTED");
Lcd_Out(2,1,"MOTION DETECTED");
alarmCounter ++;
motion_rd = 0;
Delay_ms(300);
}
if(alarmCounter != 0)
{
SendMessage();
PORTD = 0x01;
alarmCounter ++;
Delay_ms(100);
if(alarmCounter == 20)
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,2,top);
Lcd_Out(2,1,bottom);
alarmCounter = 0;
PORTD = 0x00;
}
}
}
while(1);
}
//Send a GSM message if there is any security bridge.
void SendMessage()
{
uart1_write("AT");
uart1_write(13);
delay_ms(10);
uart1_write("AT+CMGF=1"); //set to massage mode and text mode
uart1_write(13);
delay_ms(10);
uart1_write("AT+CSCA=+26655820088"); // set the simcard/phone massage center number
uart1_write(13);
delay_ms(10);
uart1_write("AT+CMGS=+26662050052"); //set the phone number which the sms will be send to.
uart1_write(13);
//uart1_write_text("AT+CMGS=+26662050052");
delay_ms(10);
//uart1_write("\r");
UART1_Write_Text("WARNING!!Motion detected"); // my text
UART1_Write(0x1A); //(CR) means Enter
UART1_Write(0x0D); //(CR) means Enter
Delay_ms(100);
}
i am working on a project called GSM Based home security alarm.i am using pic16f887 and a m-q6 gas sensor and a pir motion sensor.i have build a motion sensor circuit on breadboard without the gas sensor and it works perfectly well.now i wanted to connect the gsm module which is the siemens TC35 module to the motion sensor circuit,i have used max232 as the level shifter.the problem i have is,i cant get the sms on my fone when using pic16f887 but i can send and make a call using the gsm modem on the hype terminal.i have attached the my c code and the manual of the modem i am using.please help me as i am left with two days before the presentations. below is my c code.
unsigned int motion_rd, gas_rd;
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 top[] = "GSM BASED";
char bottom[]="SECURITY SYSTEM";
char txt1[] = "0";
unsigned int alarmCounter = 0;
void SendMessage();
void main()
{
uart1_init(9600);
delay_ms(100);
ansel=0x03;
anselh=0;
c1on_bit=0;
c2on_bit=0;
TRISA = 0XFF;
TRISD = 0;
PORTD = 0;
Sound_Init(&PORTB,6);
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); //clearing display
Lcd_Cmd(_LCD_CURSOR_OFF); // turning off the cursor
Lcd_Out(1,4,top);
Lcd_Out(2,1,bottom);
adc_init();
do
{
// detect motion
motion_rd = ADC_read(2);
gas_rd = ADC_read(3);
if( gas_rd < 5)
{
IntToStr(gas_rd,txt1);
Lcd_Cmd(_LCD_CLEAR); //clearing display
Lcd_Out(1,2,"SYSTEM ENGAGED");
Lcd_Out(2,1,txt1);
//Lcd_Out(2,1,"GAS LEAKAGE");
// Lcd_Out(2,1,"GAS LEAKAGE");
alarmCounter ++;
//gas_rd = 0;
Delay_ms(300);
}
if(motion_rd > 1)
{
IntToStr(motion_rd,txt1);
Lcd_Cmd(_LCD_CLEAR); //clearing display
Lcd_Out(1,2,"SYSTEM ENGAGED");
// Lcd_Out(2,1,txt1);
Lcd_Out(2,1,"MOTION DETECTED");
Lcd_Out(2,1,"MOTION DETECTED");
alarmCounter ++;
motion_rd = 0;
Delay_ms(300);
}
if(alarmCounter != 0)
{
SendMessage();
PORTD = 0x01;
alarmCounter ++;
Delay_ms(100);
if(alarmCounter == 20)
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,2,top);
Lcd_Out(2,1,bottom);
alarmCounter = 0;
PORTD = 0x00;
}
}
}
while(1);
}
//Send a GSM message if there is any security bridge.
void SendMessage()
{
uart1_write("AT");
uart1_write(13);
delay_ms(10);
uart1_write("AT+CMGF=1"); //set to massage mode and text mode
uart1_write(13);
delay_ms(10);
uart1_write("AT+CSCA=+26655820088"); // set the simcard/phone massage center number
uart1_write(13);
delay_ms(10);
uart1_write("AT+CMGS=+26662050052"); //set the phone number which the sms will be send to.
uart1_write(13);
//uart1_write_text("AT+CMGS=+26662050052");
delay_ms(10);
//uart1_write("\r");
UART1_Write_Text("WARNING!!Motion detected"); // my text
UART1_Write(0x1A); //(CR) means Enter
UART1_Write(0x0D); //(CR) means Enter
Delay_ms(100);
}