Go Down

Topic: AT commands and GSM (Read 7922 times) previous topic - next topic

trendski

Jul 29, 2011, 05:31 pm Last Edit: Aug 01, 2011, 10:34 am by trendski Reason: 1
Hi,

[moved from networking]

I've got my Arduino communicating via a terminal emulator with a siemens A60 mobile phone. I can make calls etc... ok.

I think my A60 only supports PDU and not text mode

Code: [Select]
AT+CMGF ? +CMGF: 0 OK

If I try to set PDU then text mode I get:

Code: [Select]
AT+CMGF =0 OK

AT+CMGF =1 ERROR


I found this tool http://stud.usv.ro/~amurariu/SMS%20and%20PDU%20format.htm which is supposed to translate text to PDU, but I'm not sure..

I tried a simple message like hello world and got this from the tool:

Code: [Select]
AT+CMGW=23 07910447946400F011000A9270042079330000AA0BE8329BFD06DDDF723619

I substituted my own phone numbers and used AT+CMGS to send the message direct. Also after reading a GSM dev manual of AT commands I put in this to the terminal:

Code: [Select]
AT+CMGS=23<CR>

07910447946400F011000A9270042079330000AA0BE8329BFD06DDDF723619<ctrl-Z>


(The manual gave this format: AT+CMGS=<length><CR><pdu><ctrl-Z>)

It printed what looks like gobbledegook and then ERROR, but checking the Hex box on the terminal lets it output some hex numbers

Can anyone please help?


PS I know I could get a phone that supports text mode but I would like to use this one as it was free and I already hacked the cable etc.. Also I may learn more if I try using this more difficult method.
Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

robtillaart

Please post your Arduino code ...
PLease tell us what went wrong, what you expected, what you got etc
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

trendski

#2
Jul 31, 2011, 05:29 pm Last Edit: Aug 01, 2011, 10:33 am by trendski Reason: 1
Hi robtillaart,

thanks for offering to help. Here is my Arduino code (cut and paste from the tutorial) I didn't make any changes:
The mobile is a siemen a60

Code: [Select]
/* SparkFun Cellular Shield - Pass-Through Sample Sketch

SparkFun Electronics Written by Ryan Owens CC by v3.0 3/8/10

Thanks to Ryan Owens and Sparkfun for sketch */

#include <NewSoftSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module.

#include <string.h>         //Used for string manipulations

char incoming_char=0;      //Will hold the incoming character from the Serial Port.

NewSoftSerial cell(2,3);  //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.

void setup()

{

 //Initialize serial ports for communication.

Serial.begin(9600);

cell.begin(9600);

Serial.println("Starting SM5100B Communication...");

}

void loop()

{

//If a character comes in from the cellular module...

if(cell.available() >0)

{

incoming_char=cell.read();    //Get the character from the cellular serial port.

Serial.print(incoming_char);  //Print the incoming character to the terminal.

}

//If a character is coming from the terminal to the Arduino...

if(Serial.available() >0)

{

incoming_char=Serial.read();  //Get the character coming from the terminal

cell.print(incoming_char);    //Send the character to the cellular module.

}

}



I am using Terminal v1.9b with same baud rate as the sketch to send AT commands. Communication basically works. I can send make a voice call using ATD<phonenumber>;
I can interogate the phone by AT commands also eg it tells me only PDU sms is available.

I want to send sms messages so I used a tool to translate my English message into PDU "hello world!" sent from 07790961101 to 07510189479.

The tool comes up with this:
Code: [Select]
AT+CMGS=25 079270976069111011000B927015109874F90000AA0CC8329BFD065DDF72363904

So next I put in AT+CMGS to the terminal and press send with the <CR> box also ticked.

Reply is:

Code: [Select]
AT+CMGS=25
>


then I put in the PDU part with a ctrl-z at end (#026#)

ie:
Code: [Select]
AT+CMGS=25
>079270976069111011000B927015109874F90000AA0CC8329BFD065DDF72363904#026#


then send

the reply is:
Code: [Select]

> Ýå'º‚ʺ²‚²ÊŠŠ‚Šþ‚ʺ‚ŠŠ‚ʺ¢2Ê‚‚(§LQ¢˜65DDF72363904#013
ERROR



A mixture of strange characters. The funny thing is it returns different ones on almost every attempt.


I was expecting something like:

Code: [Select]
CMGS
079270976069111011000B927015109874F90000AA0CC8329BFD065DDF72363904

OK



and an SMS arriving later at the destination phone on my desk.
I have also tried writing the #026# as just <ctrl-z> and <ctrl+z>, none of those work either.

Using the appropriate AT command I can retrieve PDU sms from the phone to the terminal and when I convert the encoded message
back I get the right result in the PDU conversion tool.


Cheers


Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

robtillaart

PLease modify your post, select the code and press the # button so code get appropiate tags... looks so much better ;)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

trendski

Thanks for the tip on inserting code - I wondered how they did that  8)
Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

robtillaart

Quote

AT+CMGS=25
>079270976069111011000B927015109874F90000AA0CC8329BFD065DDF72363904#026#

then send

the reply is:
Code:

> Ýå'º‚ʺ²‚²ÊŠŠ‚Šþ‚ʺ‚ŠŠ‚ʺ¢2Ê‚‚(§LQ¢˜65DDF72363904#013
ERROR

disclaimer: no experience recently with phone modems

I see that the end of the send and receive string are similar.
- is the length  (25) also interpreted as HEX or DECIMAL?  I assume HEX as the part that looks like strange chars in the reply are approx 37 bytes.
  The string you sent is longer!

wrt the special characters.
<CR> is one single character with ascii code 13  ;
Note: The Arduino serial monitor cannot send this char

<CTRL-Z> is one single character with ascii code 26;
Can be created by  holding the CTRL key and pressing the Z

ON a standard PC - Any char can be made by holding the ALT-key and typing in the ASCII code (3 or 4 digits with a leading zero if needed) e.g. ALT 159 => ƒ

Hopes this helps,






Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

trendski

#6
Aug 01, 2011, 03:53 pm Last Edit: Aug 01, 2011, 07:48 pm by trendski Reason: 1
Hi, thanks for the reply.

Quote
I see that the end of the send and receive string are similar.
- is the length  (25) also interpreted as HEX or DECIMAL?  I assume HEX as the part that looks like strange chars in the reply are approx 37 bytes.
 The string you sent is longer!


I understand from the AT command manual that in code
Code: [Select]
AT+CMGS=25

25 is the length of the PDU data unit in octets. This is automatically generated by the tool PDU (http://stud.usv.ro/~amurariu/SMS%20and%20PDU%20format.htm).

As you say parts of the message match up and make sense whilst others don't.
This got me thinking and now I can report some progress. Sometimes I get an error message that means there are invalid chars in the string from the phone.

Firstly I thought the phone does need to be told by the terminal what it's own number is - so I eliminated that. and I got a far better match between the sent and reply messages.
But still no joy.

So I tried saving the message instead of sending it direct:
Code: [Select]

AT+CMGW=19

> 00110000910000AA0CE8329BFD06DDDF72363904#026#
+CMGW: 4
OK


This means the message hello world message was successfull saved in storage index 4 on the phone  :)

This is the command to send message at mobile_index 4 to my mobile on my desk
Code: [Select]
AT+CMSS=4,07510189479

+CMSS: 4
OK





It worked. A very satifying ring tone from my recieving phone and a Hello World sms - great!

So next I tried a direct message
Code: [Select]
AT+CMGS="mesage PDU"


In the PDU tool I eliminated the senders number (the phone already knows that) and I also put the international dialling version of my reciever's No in (UK = +44phoneNumber)

It worked! Another message waiting, but this time sent direct. Weirdly there were still some funny chars in the reply from the phone in the terminal window  :smiley-eek:

WRT special chars:
Quote
wrt the special characters.
<CR> is one single character with ascii code 13  ;
Note: The Arduino serial monitor cannot send this char


I am using a Terminal emulator (terminal v1.9b https://sites.google.com/site/terminalbpp/)

Many thanks for putting me on the right track. I need now to write a sketch that does all this using the Arduino, not just using a terminal window.

So I'll get onto that Tuesday



PS

I can send char 13 <CR> to the mobile phone as it is controlling via the Rx/Tx pins in the fake serial cell

I tried this and it works:

Code: [Select]

cell.print("AT+CMSS=1, +447510189479 ");// send sms saying "Shed Intruder Alarm" stored at index 1 in the phone
cell.println(13,BYTE);  // ASCII equivalent of <cr>


Thanks again


Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

HugoPT

#7
Aug 01, 2011, 09:35 pm Last Edit: Aug 01, 2011, 09:36 pm by hugo007 Reason: 1
Hello
I'm also working on a project with a gsm modem for sms alarm.
You dont need to convert the message with PDU.you can seend it directly
here is my code:
Code: [Select]
void  alarme()
{
sensor_alarm1 = digitalRead(28);    //
sensor_alarm2 = digitalRead(29);    //
sensor_alarm3 = digitalRead(30);    //
delay(300);
if(sensor_alarm1 == 1){
       Serial2.println("AT+CMGF=1"); //Set modem in SMS mode
delay(500);                   //wait 500 ms
Serial2.print("AT+CMGS=");    //
       Serial2.println("123456789");            //Number of sms destination
Serial2.println();            //blank line
delay(500);                   //delay 500 ms
       Serial2.println("text to seend");            
       Serial2.println(26, BYTE);    //Seend <Control Z>
delay(50);
       delay(300);

}


Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

trendski

#8
Aug 02, 2011, 10:05 am Last Edit: Aug 02, 2011, 02:11 pm by trendski Reason: 1
Hi Hugo007,

thanks for the input. Unfortunately my phone only supports PDU sms messaging so the line:

Quote
Code: [Select]
Serial2.println("AT+CMGF=1"); //Set modem in SMS mode


Dosn't apply. I have to use:
Code: [Select]
Serial2.println("AT+CMGF=0"); //Set modem in SMS PDU mode

Although it does that by default anyway.

Are you using a GSM shield or old mobile / modem?
Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

HugoPT

Hello
Thats bad this way is more simple. Im using a modem that I bought on ebay and it connect via serial port on arduino
Good luck my friend
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

Go Up