Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem connecting pic18f452 with wavecome modem through max232

Status
Not open for further replies.
sir i have the modem sending message to my handphone via the modem already......now i just need to adjust the code so that when i send sms to the modem, the mcu reads it and turns on the alarm.....i do not know how to do that......sir do u know any example code that i can use as refference?
This is related project, GSM Switch and this is GSM Lesson code.
 

i have done this code for my project......when i send sms "ALARM" my buzzer will turn on and if the switches 1 and 2 are high it will notify me through sms "INTRUDER".... the intruder part works fine....but im not able to compile the ALARM part ...when i compile it says not enough parameters.....what am i doin wrong? i just want the pic to read sms from sms location 1 and if it reads ALARM then it will turn on the buzzer...here is my code pls help me guys...





#define intruder PORTB.f7
#define button_ON PORTB.f6
#define blockcar PORTD.f7
#define alarm PORTD.f6

void main()
{
trisb = 0xff; // SET PORTB AS INPUT
portd = 0x00; // SET INITIAL VALUE FOR PORTD
trisd = 0x00; // SET PORTD AS OUTPUT
UART1_Init(9600); // SYNCHRONIZE BAUDRATE WITH HANDPHONE
Delay_ms(100);
trisc.f7 = 1; // SET Rx DATA IN
trisc.f6 = 0; // SET Tx DATA OUT

while(1)
{
ON:
while(1)
{blockcar=0;
if(button_ON==0)
{
UART1_WRITE_TEXT("AT+CMGD=1,4");
UART1_WRITE(0X0D);
goto ON;
}
else if (button_ON==1)
{
UART1_WRITE_TEXT("AT+CMGR=1");
UART1_WRITE(0X0D);
UART1_Read_Text( "ALARM");
goto ALARM
}
else
{ goto INTRUDER;
}
}
ALARM:
while(1)
{alarm=1;
if (button_ON==0) // WAIT FOR USER INTERRUPT
{goto ON; // BACK TO START AFTER USER INTERRUPT
}
}
INTRUDER:
while(1)
{ if((button_ON==1)&&(intruder==1))
{
blockcar=1;
goto SSMS;
}
}
SSMS:
while(1)
{ UART1_Write_Text("AT+CMGS=");
UART1_Write(0x22); // "
UART1_Write_Text("+60125920540"); // My cellphone no here
UART1_Write(0x22); //"
UART1_Write(0x0D) ; //<CR> mean (Enter)
UART1_Write_Text("INTRUDER"); // my Text
UART1_Write(26); // Ctrl+Z
UART1_Write(0x0D); //<CR> mean (Enter)

goto USERINT; // GO TO BLOCKING CAR
}
USERINT:
while (1)
{ blockcar=1; // BLOCKING THE CAR
if (button_ON==0) // WAIT FOR USER INTERRUPT
{goto ON; // BACK TO START AFTER USER INTERRUPT
}
}
}
}
 

you should not use so many while (1) loops in a program... its difficult to maintain the stack for them...

---------- Post added at 19:45 ---------- Previous post was at 19:33 ----------



you should send 0x0a and 0x0d in combination which is equivalent of "ENTER"... I dont see that..

---------- Post added at 19:46 ---------- Previous post was at 19:45 ----------

you have not set the message format of AT+CMGF ?????????????//
 

i just need the main code for reading a specific sms message example alarm and then turning an output high. i do not want to change the code much because the sending sms to mobile part is fine............

does this code work
UART1_READ_TEXT("ALARM","OK",80);
alarm=1;

alarm is defined as ouput on pin d6;
DOES THIS MEAN WHEN THE PIC READS ALARM IN THE SMS MESSAGE IT WILL TURN ON
 

does this code work
UART1_READ_TEXT("ALARM","OK",80);
alarm=1;
It's not straight forward like that. Read the AT Command manual.

Your handphone send SMS, then GSM receive, PIC will receive AT+CMTI
Then PIC read the SMS by sending command AT+CMGR=1. 1 is SMS location, it also can be 2,3 or what any number.
But, what I do, I delete SMS location 1 at the beginning, so I always can read SMS location 1.

See this 2 example GSM Signboard and GSM Switch.
 

ok then ill put AT+CMTI for pic to understand that a new message has arrived and then AT+cmgr=1 for the pic to read the message at location 1 but what code do i use for pic to understand let say the word "alarm" and then gives a high on its outputs?
 

ok then ill put AT+CMTI for pic to understand that a new message has arrived and then AT+cmgr=1 for the pic to read the message at location 1 but what code do i use for pic to understand let say the word "alarm" and then gives a high on its outputs?
Read the AT Command manual, when you send AT+CMGR=1, then what GSM Modem will reply.
This reply is the example: +CMGR: “REC UNREAD”,”0146290800”,”98/10/01,18:22:11+00”,<CR><LF>ABCdefGHI OK

Then you need to process this string.
 

abang i need help in doing the string.......the examples u gave has none of those......i know when i give AT+CMGR=1 i will get the info as above.....i have already tested with hyperterminal......i have also tested my pic with hyperterminal.....at+cmgd and at+cmgr works but i do not know how to write the code for the pic to understand the alarm command from the sms message and give a high on it input.....tolong la abang im so close already
 

abang i need help in doing the string.......the examples u gave has none of those......i know when i give AT+CMGR=1 i will get the info as above.....i have already tested with hyperterminal......i have also tested my pic with hyperterminal.....at+cmgd and at+cmgr works but i do not know how to write the code for the pic to understand the alarm command from the sms message and give a high on it input.....tolong la abang im so close already
That you need to study all in my blog.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top