GSM TEXTing problem

tim griff

Member
Hello,

I'm trying to use a maestro gsm module to control my central by receiving exact 4 character texts ( NORM = normal, HOUR will extend the heating etc)

using 20M2 chip and a rs232 to ttl adapter.

SEROUT using pinc.7 8MHZ I want to send AT+CMGR= 1 ,13(CR) ( will delete all message at reading, so the the message I want will always be message 1

SERIN using pinc.0 8MHZ I want extract the number calling and the four character after the CR so it does not matter if I mis the first character, I can use a qualifier on say "07"

Allow I've tried this on my pc using a terminal emulator and all is well what I get back from the picaxe is

b0 = a
b1= T
b2 =+
b3= C
b4= m
b5=g
b6 = r
b7= "="
b8 = 1
b9 = 1
b10 = 3 I,ve turned echo off (ATE0)

Even if I just try sending AT I should get back "OK" but still get just the command back.
If I don't put enough variables in the SERIN line it the DEBUG hangs which makes me think the data is coming from the modem; my logic probe also see the data coming in from pin c.0

thanks tim
 

hippy

Senior Member
I want to send AT+CMGR= 1 ,13(CR) ... Allow I've tried this on my pc using a terminal emulator and all is well what I get back from the picaxe is

b0 = a
b1= T
b2 =+
b3= C
b4= m
b5=g
b6 = r
b7= "="
b8 = 1
b9 = 1
b10 = 3 I,ve turned echo off (ATE0)
That 1 and 3 seem to come back as separate data, when that seems it should be a CR, single ASCII character with decimal value 13, you are perhaps not sending what you think. It also seems a bit odd that the initial "A" has been returned as "a".

Perhaps post your full code.
 

tim griff

Member
That 1 and 3 seem to come back as separate data, when that seems it should be a CR, single ASCII character with decimal value 13, you are perhaps not sending what you think. It also seems a bit odd that the initial "A" has been returned as "a".

Perhaps post your full code.
Thanks Hippy,
Firstly A or a was a typo on my part what gets "returned" is what I type in

the code
init:

setfreq m8

main:
serout c.0, T9600_8, ("aT","13")


serin c.7,T9600_8,b1,b2

debug
pause 3000
goto main

If I just use SERIN (not using SEROUT) and ring the modem I see in the variables that I expect.

13, 10 A,T, +, R,I,N,G ....etc

To make things simple I now just send "AT", $0d ( The response as you know should be "OK")

what I get back is
b1=A
b2= T
b3 = 13

I think Echo is off, but even if it's not I should see a CR and OK at the above variables

Thanks for you help, this was has me stumped
 

Attachments

tim griff

Member
Hi Hippy ,
That was the full code, as I just wanted to see the data coming off the modem. I've just come in from the workshop and now send $0d instead of "13". I've also resent the echo command in uppercase(ATE0 [ off]) and now see the data.

My intention is to (by text) put the boiler into different modes and to set the frost temperature. I'll be able to monitor boiler faults and text or send a burst of ring tone to me /user as acknowledgement that the command has been executed.

thanks tim
 

hippy

Senior Member
Whether AT commands are terminated by CR, LF or CR plus LF, and what CR or LF characters are returned with any response, will vary upon GSM module implementation and configuration.

The "AT" command should echo an "OK" response but it may be that the first character is corrupt, especially as using a Txxxx baud rate and not setting the line high at initialisation. Even with that it could still be that the first command is seen as corrupt.

I am not a great fan of the DEBUG command and prefer to use SERTXD to report to a terminal. I would suggest running the code below to see what that produces. Depending on the result that code can then be further tailored to what your module is actually doing, or modified to try and figure out why the results are not as expected ...

Code:
#Picaxe 20M2
#Terminal 9600
#No_Data

Symbol TX    = C.0     ; Tx to GSM module
Symbol RX    = C.7     ; Rx From GSM module
Symbol BAUD  = T9600_8

Symbol QUOTE = $22

High TX
Pause 2000
SetFreq M8
SerTxd( "Started", CR, LF )
Do
  Pause 4000
  SerTxd( "Sending ...", CR, LF )
  SerOut TX, BAUD, ( "AT", CR )
  SerIn  RX, BAUD, b0, b1, b2
  SerTxd( "Received ...", CR, LF )
  SerTxd( "b0 = ", #b0, TAB, QUOTE, b0, QUOTE, CR, LF )
  SerTxd( "b1 = ", #b1, TAB, QUOTE, b1, QUOTE, CR, LF )
  SerTxd( "b2 = ", #b2, TAB, QUOTE, b2, QUOTE, CR, LF )
Loop
 

lbenson

Senior Member
re: serout c.0, T9600_8, ("aT","13")

You know that with "13", you're not sending a carriage return, but an ascii "1" followed by an ascii "3".

Omit the quotes to send CR:

serout c.0, T9600_8, ("AT",13)
 

tim griff

Member
Thank you both very much

Yes I was sending 13 not CR and I'd switched off echo with the modem on the bench and then fitted into the project, what I failed to send AT&W to save the parameters.
I shall go and stand in the corner with a dunce's cap on...........!!!!!! thanks again
 

tim griff

Member
Nearly finished

I just need to engrave the lid with the mode titles.
The black bit sticking out is a 18b20 to measure temperature and will set " frost" stat
The 7 pin plug allows me to unplug the unit and use the 7 pin plug as a "shorting plug " to return the boiler back to standard operation.
regards
 
Top