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

hiast
Thu Jun 16 2016, 03:03 PM
help please how do i initiate port 3 as an input port in assembly? acutely there is push switch connecting to p3.2 push switch connecting to p3. 3 push switch connecting to p3.4 push switch connecting to p3.5 and i need to call function when the user pressed the push switch for the previous pins (not used as counter and not as timer… just call a function ( do special thing) when any push switch is pressed ???????
Mon Jun 06 2016, 12:02 PM
nida hussain
hi.. i need some help with keypad interfacing code.like i want to write a code in c language that takes an input of 2 digit numbers from a keypad interfaced with 8051 mc and stores the entered values in some array
Sat May 28 2016, 04:34 PM
kibrom berhe
c code for locker security system based on rfid and gsm
ExperimenterUK
Wed May 25 2016, 05:05 AM
@ Ramanjaneyulu, post in forum,explain your problem
Mon May 23 2016, 11:34 PM
Ramanjaneyulu
Hi, I Am using at89c4051 for my application, I want 5u sec dely.. Up to 1milli sec iam able to producing delay. Beyond the 1milli second, I am unable to produce the acceurate dely. Plz any one help me
Sat May 21 2016, 09:51 PM
A K
i want to mak an auto dialer using gsm and atmega 16. please helpe me how to write a code to auto dial a number saved in sim
Sat May 21 2016, 10:42 AM
Alec
Hi im trying to program my 89s51 with a usbasp so any ideas on the circuit?
Wed May 18 2016, 10:08 AM
Tashu joshi
anyone know how to develop
Wed May 18 2016, 10:07 AM
Tashu joshi
i'm working for resporatry system using 8051,
Wed May 18 2016, 10:06 AM
Tashu joshi
i'm developing a respiratory system using Arduino

Downloads

Comments

dyoussef
Wed Jun 29 2016, 07:29 PM
sung7333
Tue Jun 28 2016, 06:23 AM
Bonolai
Fri Jun 24 2016, 06:02 AM
hiast
Sat Jun 11 2016, 02:30 PM
alex1311
Thu Jun 09 2016, 06:57 AM
zaft93
Sun May 15 2016, 01:52 AM
CELEBI
Thu May 12 2016, 08:28 AM
Suro1996
Wed May 11 2016, 06:07 PM

Online

Guests: 46, Members: 0 ...

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

Members: 37770
Newest member: dyoussef
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Jun 30 2016, 05:44 AM
I think the display/ editor software added the a...
dyoussef Avatar
Posted By dyoussef
Wed Jun 29 2016, 07:34 PM
Hello, I am referencing this project: http://www.8051projects.net/wiki/I2C_Implementation_on_PICI am using PIC16F1847 and XC8 so I've had to make a few changes to the code. While making changes, my compiler gave me an error for the I2CWait function for the while statement. It says "unexpected token amp". Here is the line in question:while ((SSPCON2 &amp; 0x1F ) || ( SSPSTAT &amp; 0x04 ) );I changed the register names to be consistent with my PIC but it didn't solve the problem.What changes do I need to make to this function so that this error does not occur?
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Jun 22 2016, 07:54 PM
I can't see why it should work sometimes and not o...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Jun 22 2016, 12:58 AM
You could use T0 and T1 to trigger interrupts but ...
Karan123 Avatar
Posted By Karan123
Tue Jun 21 2016, 04:40 AM
I am not Getting you . the project is to interfac...
Karan123 Avatar
Posted By Karan123
Tue Jun 21 2016, 04:34 AM
Hello,Thanks , It Works . Master-Slave address Ma...
alex1311 Avatar
Posted By alex1311
Mon Jun 20 2016, 11:38 AM
Football is my passion and I have dreamt of becomi...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Jun 17 2016, 11:00 PM
>But Can't modify code at Receiver End for Differe...
hiast Avatar
Posted By hiast
Fri Jun 17 2016, 03:25 PM
thanks for help,i wanted to write this code as you...
Karan123 Avatar
Posted By Karan123
Fri Jun 17 2016, 12:19 PM
I don't your applications . But below should help ...