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.

receiving message to PIC through GSM modem

Status
Not open for further replies.

pic+gsm

Newbie level 4
Joined
Nov 24, 2012
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,324
Can someone help me pleas I am not sure how I can receive a text message from the GSM such as LED1ON and switch an LED1 on I have tried few ways but I can’t make it work

Code:
void readtheUSART(char *recbuffer)
 {
    unsigned char recivedata;

       do 
		{
		       recivedata = ReadUSART();
		       *recbuffer++ = recivedata;
		}
	 while (recivedata != '\n');  
}

/////////////////////////////////////////////
// in my main 
////////////////////////////////////////////

    char readmessage[10];
    char readnewline[50];
    char message_index;
    
    // Set Text Mode
	Comm("AT+CMGF=1\r\n");
    delay(300);

    
    // Read last SMS
    delay(300);
   for (aa= 0; aa<13; aa++)  //  recv2 = AT+CMGR=1\r\n;
	{
        if (recv2[aa] == 0)
            break;
       WriteUSART(recv2[aa]);
        while ( BusyUSART() );
    }

    // Read +CMGL: <index>,<status>,<from_address>,<mr>,<scts>
    readtheUSART(readnewline);
    // Read message led1on, led1off 
    readtheUSART(readmessage);
    // Read newline
    readtheUSART(readnewline);
    
    // Read message and return the value back
    if(memcmp("LED1ON", &readmessage, 6) == 0) {
        led1 = 1;
    } else if(memcmp("LED1OFF", &readmessage, 7) == 0) {
        led1 = 0;
    }
    
    // Delete last message
    delay(300);
	for (aa= 0; aa<13; aa++)  //   recv3 = AT+CMGD=1\r\n
	{
        if (recv3[aa] == 0)
            break;
        WriteUSART(recv3[aa]);
       while ( BusyUSART() );
    }
 

What is your GSM modem?
What are you using to receive the message?


Can someone help me pleas I am not sure how I can receive a text message from the GSM such as LED1ON and switch an LED1 on I have tried few ways but I can’t make it work

Code:
void readtheUSART(char *recbuffer)
 {
    unsigned char recivedata;

       do 
		{
		       recivedata = ReadUSART();
		       *recbuffer++ = recivedata;
		}
	 while (recivedata != '\n');  
}

/////////////////////////////////////////////
// in my main 
////////////////////////////////////////////

    char readmessage[10];
    char readnewline[50];
    char message_index;
    
    // Set Text Mode
	Comm("AT+CMGF=1\r\n");
    delay(300);

    
    // Read last SMS
    delay(300);
   for (aa= 0; aa<13; aa++)  //  recv2 = AT+CMGR=1\r\n;
	{
        if (recv2[aa] == 0)
            break;
       WriteUSART(recv2[aa]);
        while ( BusyUSART() );
    }

    // Read +CMGL: <index>,<status>,<from_address>,<mr>,<scts>
    readtheUSART(readnewline);
    // Read message led1on, led1off 
    readtheUSART(readmessage);
    // Read newline
    readtheUSART(readnewline);
    
    // Read message and return the value back
    if(memcmp("LED1ON", &readmessage, 6) == 0) {
        led1 = 1;
    } else if(memcmp("LED1OFF", &readmessage, 7) == 0) {
        led1 = 0;
    }
    
    // Delete last message
    delay(300);
	for (aa= 0; aa<13; aa++)  //   recv3 = AT+CMGD=1\r\n
	{
        if (recv3[aa] == 0)
            break;
        WriteUSART(recv3[aa]);
       while ( BusyUSART() );
    }
 

What is your GSM modem? my GSM is using AT commands (TC35)
What are you using to receive the message? pic 18F
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top