Discussion in "Embedded GSM Development" started by    muahaha_psp    Apr 6, 2010.
Tue Apr 06 2010, 07:18 AM
#1
hi, can i ask a question...i have a circuit that consist from a sim300 gsm module that connected to pic16f877a by using max232. my circuit design is to detect if an sensor is triggered (ir), then the microcontroller will send sms to the user. i have acomplished this feature and my other problem is i cannot send sms to the microcontroller to switch on a relay to trigger a 5v relay that connected to my output (light). can u help me?
Tue Apr 06 2010, 08:09 AM
#2
post your program here for more help.

what are AT Commands you are using for this job...

[Topic moved to Embedded GSM Development Forum]
Tue Apr 06 2010, 08:20 AM
#3
this is my program.

#include <16f877A.h> //ic driver
#use delay(clock=20000000) //clock speed
#fuses hs,noprotect,nowdt,nolvp //ic setting
#use rs232 (baud=115200,xmit=PIN_C6,rcv=PIN_C7,PARITY=N,stream=GSM) //Serial Com Port for GSM

#byte PORTA=5 //define port address
#byte PORTB=6
#byte PORTC=7

#define led1 PIN_A0 //define pin
#define led2 PIN_A1
#define InfraRed PIN_B0
#define buzzer PIN_C0
#define light PIN_C1


//sensor
long timer=0;
int alarm=0;



//GSM register
int GSM_getsms=0;

//Serial register
char rx_buff;
char rx[80];
int rx_set=0;
int rx_cnt=0;

#int_rda //Serial interrupt to collect gsm data
void serial_isr (){

rx_buff=getc(); //collect sms command
if(rx_buff==0x0A){ //start byte
rx_cnt=0; //reset counter
}
rx[rx_cnt]=rx_buff; //move received data to array
rx_cnt++; //counter +1

if(rx[0]==0x0A && rx_buff==0x0D){ //end byte receive
rx[0]=0;
rx_set=1; //valid set data received
}
}

void main () //main program
{

set_tris_a(0x00); //define io pin; 1:input;0:output
set_tris_b(0xFF); //A0-A3:output,B0-B5:input,c0-c2:output
set_tris_c(0x00);

port_b_pullups(true); //enable pull up at port b

setup_port_a(NO_ANALOGS); //no analog signal

PORTA=0; //off all leads
PORTB=1;
PORTC=0; //off all portc output

enable_interrupts(GLOBAL);

fprintf(GSM,"AT+CMGD=1\r"); //Delete message, \r: return key
delay_ms(1000);

do
{
{
if(input(InfraRed)==0){
delay_ms(1000);
fprintf(GSM,"AT+CMGS=\"+60137546293\"");
fputc(0x0D,GSM); // command for enter
delay_ms(1000);
fprintf(GSM,"Infrared Sensor Activated : House Door Opened! ");
fputc(0x1A,GSM); // command for ctrl+Z
delay_ms(1000);
fputc(0x0D,GSM); // command for enter
delay_ms(1000);
output_low(InfraRed); // Switch off InfraRed PORT
fprintf(GSM,"AT+CMGD=1");
delay_ms(1000);
fputc(0x0D,GSM);
delay_ms(1000);
}

if(input(InfraRed)==0){
alarm=1;
}
if(input(InfraRed)==1){
alarm=0;
}
if(input(InfraRed)==0){
output_high(led1);
}
if(input(InfraRed)==1){
output_low(led1);
}
if(alarm==1){
output_high(buzzer);
}
if(alarm==0){
output_low(buzzer);
}


if(rx_set==1){
rx_set=0; //reset

if(rx[3]=='T' && rx[4]=='I'){ //SMS received +CMTI: "SM",1
printf("AT+CMGR=1\r"); //Get SMS
}
if(GSM_getsms==1){ //Get Message
GSM_getsms=0;


if(rx[1]=='1'){ // Light

if(rx[2]=='0'){
output_low(light);
output_low(led2);
}
if(rx[2]=='1'){
output_high(light);
output_high(led2);
}
}
}

delay_ms(2000); //wait for GSM process
printf("AT+CMGD=1\r"); //Free memory
delay_ms(1000);
}

if(rx[3]=='G' && rx[4]=='R'){ //Prepare get SMS +CMGR:
GSM_getsms=1;
}

rx[4]=0; //Free memory
rx[5]=0;
}

timer++;
}while(TRUE);
}



i use ccs programming for this.....the idea is to send sms to trigger certain relay like example to on light bulb,...can anybody help me? about the sms that microcontroller send to user handphone to inform about the sensor triggerd i've already accomplished..only this one keep delaying my work..ur opinion is greatly needed...

Get Social

Information

Powered by e107 Forum System

Conversation

Fri Nov 28 2014, 06:31 AM
babar
aoa ,, i need a project for 8051 microcontroler can some one plz give me the pdf form of this project android control robot
Fri Nov 28 2014, 06:30 AM
babar
hi
ExperimenterUK
Thu Nov 20 2014, 06:00 PM
@Mehboob.. I don't think you can do that.
Sat Nov 15 2014, 06:41 AM
Mehboob
Pls can you send me code in c of PWM generation using UART/serial port in 8051.
Fri Nov 14 2014, 02:51 PM
mohammad aqil
NEED A BOOK ON MICROPROCESSOR AND INTERFACING BY D.V.HALL. RIGHT NOW, I SHALL BE VERY THANK FULL TO U....
Thu Nov 13 2014, 02:15 PM
m
please code hex project avr blood pressure monitor
Thu Nov 13 2014, 05:56 AM
Lambo
hi mate, whats the ajay-bhargav? tell us more pls
ExperimenterUK
Wed Nov 12 2014, 12:56 AM
@tmtm000.. have you been able to join ?
ExperimenterUK
Wed Nov 12 2014, 12:54 AM
@Alice..become a member,then send a PM to ajay_bhargav the site owner.
Tue Nov 11 2014, 03:58 AM
Abhishek Bansal
Thanks a lot for your informative tutorials!

Downloads

Comments

PsySc0rpi0n
Thu Nov 27 2014, 02:00 PM
hanifnoor
Thu Nov 27 2014, 09:42 AM
dpkraju
Wed Nov 26 2014, 02:18 PM
sankalp_s
Tue Nov 25 2014, 05:13 PM
dodul
Mon Nov 24 2014, 10:08 PM
VikiPeter
Tue Nov 18 2014, 09:13 AM
gentlboy
Sun Nov 16 2014, 11:13 PM
philipeastbourne
Wed Nov 12 2014, 05:32 AM

Online

Guests: 57, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37552
Newest member: PsySc0rpi0n
Forum Activity
PsySc0rpi0n Avatar
Posted By PsySc0rpi0n
Fri Nov 28 2014, 07:05 AM
Good morning. Thanks for replying. The problem in ...
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Nov 28 2014, 04:44 AM
You can read status of pin before starting the gam...
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Nov 28 2014, 04:37 AM
As ExperimenterUK (Phil) said, searching for speci...
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Nov 28 2014, 04:31 AM
[Topic moved to AVR Discussion Forum]
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Nov 28 2014, 04:29 AM
If you have worked on normal C language then Embed...
PsySc0rpi0n Avatar
Posted By PsySc0rpi0n
Thu Nov 27 2014, 02:30 PM
Hi...I'm new in forum and with programming 8051 co...
hanifnoor Avatar
Posted By hanifnoor
Thu Nov 27 2014, 09:45 AM
while(msg_array[i]!='\0') { if(msg_array[i]=...
rearthur2003 Avatar
Posted By rearthur2003
Thu Nov 27 2014, 05:23 AM
there are two types of diodes ir rx which is coat...
rearthur2003 Avatar
Posted By rearthur2003
Thu Nov 27 2014, 05:19 AM
First you will need to let us know what IDE you pl...
engr1931 Avatar
Posted By engr1931
Thu Nov 27 2014, 05:18 AM
yes sir! i only know assembly, and still in proces...