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.

How to send at+cpms="me","me","me" to serial port

Status
Not open for further replies.

Isuru Senarath

Member level 2
Joined
Apr 10, 2012
Messages
42
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,580
HI
I am using AT89S52 to read a sms which attached to motorola C168. I need to transmit AT+CPMS="ME","ME","ME" to serial port as below, How can I do it?
Code:
void SMSString(char*text) ;

SMSString("AT\r"); // AT commands to initialize gsm modem
delay(50);

SMSString( "ATe0\r"); // turn off echo
delay(50);

SMSString( "AT+CPMS="ME","ME","ME"\r"); // select memory
delay(50);

SMSString( "AT&W\r"); // save settings
delay(50);

SMSString( "AT+CMGF=1\r"); // select text mode for sms
delay(50);
  
SMSString( "AT+CNMI=2,1,0,0,0\r"); // notification of new sms

When I am doing this in KEIL uVision3, there is an error called "error c141: syntax error near 'ME' ". How can I transmit to serial port without any trouble?
 

It is propably because you need to place a backslash (\) before a quotation mark (""). This is the way to keep your compiler happy about embodying quotation marks inside a declared string.
In real life you would say AT+CPMS="ME","ME","ME", but in C it must be like:

unsigned char str[] = "AT+CPMS=\"ME\",\"ME\",\"ME\"";

In this way the compiler understands that a string is not terminated with the quotation mark, but this quotation mark is actually part of the string.
 

Hi,
Thanks for your help. I works now. I have another problem, that is when I am sending a SMS using AT command (AT+CMGS="tel no" message and ctrl+z) it will successfully send. but I cant read the received sms. It will show as <unreadable format>. What is wrong with my AT commands?
 

I cant read the received sms. It will show as <unreadable format>
Where do you see this "unreadable format"? Do you use a treminal software? This is strange in any case, because sms is received as string.
 

I saw this through my phone. It will display as unreadable format.
 

OK, now it makes sence. This means that you are not sending ASCII characters from the GSM or there is some violation of the send sms command. Double check the code that sends the sms payload from your MCU to the GSM.
If you can debug the code, it would be really usefull to stop before you send the sms and check the contents of the serial output buffer.
 

How can I check whether I an sending ASCII characters or not? How can I set up the basic configurations to send ASCII characters from my GSM module (Motorola C168).
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top