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

Tue Nov 29 2016, 02:49 PM
jaykumar
Dear sir, elevator microprocessor control , the vendor locked the control, pls help me how can we decode the password
Sat Nov 26 2016, 10:24 AM
manikanta B
hello i know about gsm,gps and zigbee but i dont know how to use them while programming. can anyone suggest me how to use them
ExperimenterUK
Sat Nov 19 2016, 07:09 PM
@Protaz.. Really you would be better off asking on one of the many Arduino user sites
Fri Nov 18 2016, 05:39 AM
Protaz
Hi, am new in programing, but I have few skills in electronic. I want to make an automatic timing system for institutions using arduino uno. Any one to assist me how to program the microcontoller?
Tue Nov 15 2016, 04:45 AM
Hemangi patel
hello, i am working on atmega128 board and i want to interface with sd card with using fat32 file system. i am totaly new in this field .so pls anyone can u suggest me some imp links.thanks
Thu Nov 10 2016, 01:40 PM
ajith raj
hi frds i make voice control robot using blutooth module
Wed Oct 26 2016, 08:23 AM
ishalt
is it possible to completly get the robot running from java code
Sun Oct 23 2016, 05:50 PM
mamata thakur
plz send full mini project report for ic 741&ic 555 tester
Wed Oct 19 2016, 03:30 PM
riddhi1296
can you provide an explanation for the inverter 8051 code and how it works
ExperimenterUK
Sat Oct 15 2016, 12:15 AM
@snaya. Create a thread in the 8051 forum for your questions

Downloads

Comments

Jonathan.kei
Mon Nov 21 2016, 04:30 PM
AVRuser1
Sun Nov 20 2016, 06:07 PM
JaguarPaw
Thu Nov 17 2016, 07:44 PM
PeterJohn
Mon Nov 14 2016, 05:54 PM
evigna
Wed Nov 02 2016, 02:03 PM
ozancakiroglu
Thu Oct 27 2016, 01:54 PM
[email protected]
Fri Oct 21 2016, 10:35 PM
Beliwars
Sat Oct 15 2016, 09:40 AM

Online

Guests: 42, Members: 0 ...

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

Members: 37792
Newest member: Jonathan.kei
Forum Activity
Centurio Avatar
Posted By Centurio
Mon Nov 28 2016, 08:46 AM
Hi there,long time ago... i've a short question to...
kirangowle Avatar
Posted By kirangowle
Wed Nov 16 2016, 03:56 PM
Hello Forum members,After a long time i am back to...
Pratik_Suthar Avatar
Posted By Pratik_Suthar
Thu Oct 13 2016, 12:39 PM
@martin the HEX file provided in the project is no...
ajay_bhargav Avatar
Posted By ajay_bhargav
Thu Oct 06 2016, 06:15 AM
Hi Phil, Do you want to add this to existing proje...
ajay_bhargav Avatar
Posted By ajay_bhargav
Thu Oct 06 2016, 06:13 AM
CE should be high when you go for reading mode/wai...
ajay_bhargav Avatar
Posted By ajay_bhargav
Thu Oct 06 2016, 06:03 AM
You can also use ESP8266 with its SDK to write app...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Oct 03 2016, 11:15 PM
This is an old thread and the links no longer work...
martinsnc115877 Avatar
Posted By martinsnc115877
Wed Sep 14 2016, 12:51 PM
sir, i did your led scrolling mass display, and it...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Sep 09 2016, 11:45 PM
The Hex file for this project is a bit too big for...