Feasibility of using SMS to transmit PICAXE data?

vttom

Senior Member
I just had a thought...

Would it be possible to hook up a cell phone to a PICAXE using a serial link, and use the PICAXE to "instruct" the phone to send data via SMS?

I think the answer is yes, but invite others to weigh in.

I have a remote telemetry application in mind, but I haven't the faintest idea where to start WRT getting documentation on which cell phones support serial comms and what protocols they use (I'm under the impression they use "AT" command sets that vary by manufacturer).

Where might this all be documented? Has anyone attempted anything like this w/ a PICAXE or otherwise?
 

MPep

Senior Member
I believe that LanternFish is working on something similar. Using AT commands, rather that PDU. Hasn't released code yet AFAIK.
 

vttom

Senior Member
Well, I did some searching of this forum, and some Googling, and have convinced myself that it's certainly feasible, and actually quite straight-forward.

Now I just need to "shop around" and find a suitable phone that has a serial port and start experimenting.

Ideally, I'd like a pre-paid phone w/ GPS, but I could also make-do with a used phone and a bare-bones plan.
 

MPep

Senior Member
The problem I see is finding a cellphone that uses 'text' mode, as opposed to PDU.
Then the issue will be, Can I use serial as opposed to USB??
 

hippy

Technical Support
Staff member
It should be fairly straight forward to convert raw text into PDU format, even on a PICAXE.
 

lanternfish

Senior Member
Hi all. Just poking my head up as rather busy at work at the moment so mainly eating, sleeping and working.

Here is some BDU conversion code I was working on a while back. The BDU conversion worked in simulation but I dropped it when I found that I could use AT commands with the Nokia 6100. This saved heaps of time and code. Sorry about the lack of annotation but hope you can make sense of it. And it could do with some optimising if any one wants to use it.

Code:
************************************************************************************
*                                                                                  *
*                                    GPS2SMS                                       *
*                                  PICAXE 28X2                                     *
*                                                                                  *
*                                  lanternfish                                     *
*                                     2009                                         *
*                                                                                  *
************************************************************************************



'Directives

#PICAXE 28X2
#SIMSPEED 20

'Constants

SYMBOL NoBreak = 0
SYMBOL Padding = 0			; If Frame Length Odd

'Variables

SYMBOL TxtLenPDU = b0
SYMBOL TxtLenUnp = b1
SYMBOL PktSeqNum = b2
SYMBOL MSBChkSum = b3
SYMBOL LSBChkSum = b4

SYMBOL txtptr1 = b8			; Byte (n) Txt Buffer Pointer
SYMBOL txtptr2 = b9			; Byte (n+1) Byte in Buffer
SYMBOL bduptr  = b10			; BDU Buffer pointer
SYMBOL byte1   = b11			; BDU Conversion bytes
SYMBOL byte2   = b12			; BDU Converted Byte to store in BDU buffer
SYMBOL result  = b13			; BDU Conversion Result
SYMBOL multi   = b14			; BDU Multiplier
SYMBOL divisor = b15			; BDU Divisor
SYMBOL txtctr  = b16			; 
SYMBOL txtlen  = b17			; Length of txt to convert

SYMBOL FrameMSB = b18
SYMBOL FrameLSB = b19
SYMBOL SeqNo    = b20
SYMBOL Pointer2 = b21
SYMBOL Pointer1 = b22
SYMBOL Byte3    = b23
SYMBOL XORStart = b24
SYMBOL counter1 = b25

'b26 - b55 are RESERVED for storing BDU message

************************************************************************************
*                                                                                  *
*                                 Main Routine                                     *
*                                                                                  *
************************************************************************************
Setup:

	EEPROM 0,("1240567,045520S,170304E,456M",255)
	'lat:045520.S long:170304.E
	'Converted to 31D98C56B3DD62B219AD66BBC564335ACD768BC966B49AED06

	pointer1 = 0
	pointer2 = 10
	
LoadVariableRAM:

	READ pointer1,Byte1
	IF Byte1=255 THEN GOTO Main
	POKE pointer2,Byte1
	INC pointer1
	INC pointer2
	GOTO LoadVariableRAM
	
Main:

	setfreq m8
	
	GOSUB WakeUpNokia
	GOSUB GetVer
	GOSUB CheckVerReceived
	GOSUB Acknowledge
	GOSUB ASCII2PDU					;GPS Data Converted Here
	GOSUB CheckSum
	GOSUB SendSMSEven
	'GOSUB Acknowledge

Endless:

	GOTO Endless
	

************************************************************************************
*                                                                                  *
*                                   Suboutines                                     *
*                                                                                  *
************************************************************************************
	
WakeUpNokia:

	'Send 128 U's serially to wake up cellphone
	RETURN
	
GetVer:

	'HSEROUT NoBreak,(FrameID,Dest,Srce,Command,0,1,0,3,0,1,SeqNo,Padding,MSBChkSum,LSBChkSum)

	SEROUT 0,N9600_8,(FrameID,Dest,Srce,Command,0,1,0,3,0,1,SeqNo,Padding,MSBChkSum,LSBChkSum)
	RETURN
	
Acknowledge:

ReceiveAck:


	RETURN



SendAck:




	RETURN
	
CheckVerReceived:

	RETURN
	
ASCII2PDU:

Initialise_Converter:

	txtptr1 = 0
	txtptr2 = txtptr1 + 1
	bduptr = txtlen + 5
	
Convert_ASCII_To_PDU:

	multi = 128
	divisor = 2
	counter1 = 0
	
	DO UNTIL counter1 = 7
	
		GET txtptr1,byte1
		GET txtptr2,byte2
			
		IF byte2 = 255 THEN GOTO Last_BDU_Byte
			
		result = byte2 // divisor
		result = result * multi
		byte1 = byte1 OR result
		PUT bduptr,byte1

		byte2 = byte2 / divisor
		PUT txtptr2,byte2
			
		INC txtptr1
		INC txtptr2
		INC bduptr
		multi = multi / 2
		IF multi = 1 THEN LET multi = 128:ENDIF
		divisor = divisor * 2
		IF divisor = 256 THEN LET divisor = 2:ENDIF
		
		INC counter1

	LOOP
		
		INC txtptr1
		INC txtptr2	
		INC txtctr
		GET txtptr1,byte2
		IF byte2 = 255 THEN 
			GOTO Last_BDU_Byte
		ELSE 
			GOTO Convert_ASCII_To_PDU
		ENDIF

Last_BDU_Byte:

		PUT bduptr, byte1	
		
	RETURN

SendSMSEven:

	'HSEROUT NoBreak,($1E,$00,$0C,$02,0,TxtLenPDU,0,1,0,1,2,0,7,$91,$36,$9A,$2C,$16,$A3,
$D1,$6E,$38,$1B,$0C,$15,0,0,0,TxtLenUnp,$0A,$91,$36,$9A,$2C,$16,$A3,$C9,$70,$34,$1B,$0C,
$A&,0,0,0,0,0,0,b10,b11,b12,b13,b145,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27,
b28,b29,b30,b31,b32,b33,b34,b35,b36,b37,0,PktSeqNum,MSBChkSum,LSBChkSum)

	SEROUT 0,N9600_8,($1E,$00,$0C,$02,0,TxtLenPDU,0,1,0,1,2,0,7,$91,$36,$9A,$2C,$16,$A3,
$D1,$6E,$38,$1B,$0C,$15,0,0,0,TxtLenUnp,$0A,$91,$36,$9A,$2C,$16,$A3,$C9,$70,$34,$1B,$0C,
$A7,0,0,0,0,0,0,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27,
b28,b29,b30,b31,b32,b33,b34,b35,b36,b37,0,PktSeqNum,MSBChkSum,LSBChkSum)
	RETURN

SendSMSOdd:

	'HSEROUT NoBreak,($1E,$00,$0C,$02,0,TxtLenPDU,0,1,0,1,2,0,7,$91,$36,$9A,$2C,$16,$A3,
$D1,$6E,$38,$1B,$0C,$15,0,0,0,TxtLenUnp,$0A,$91,$36,$9A,$2C,$16,$A3,$C9,$70,$34,$1B,$0C,
$A&,0,0,0,0,0,0,b10,b11,b12,b13,b145,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27,
b28,b29,b30,b31,b32,b33,b34,b35,b36,b37,0,PktSeqNum,Padding,MSBChkSum,LSBChkSum)

	SEROUT 0,N9600_8,($1E,$00,$0C,$02,0,TxtLenPDU,0,1,0,1,2,0,7,$91,$36,$9A,$2C,$16,$A3,
$D1,$6E,$38,$1B,$0C,$15,0,0,0,TxtLenUnp,$0A,$91,$36,$9A,$2C,$16,$A3,$C9,$70,$34,$1B,$0C,
$A7,0,0,0,0,0,0,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26,b27,
b28,b29,b30,b31,b32,b33,b34,b35,b36,b37,0,PktSeqNum,Padding,MSBChkSum,LSBChkSum)
	RETURN

ReceiveSMS:

	'HSERIN (FrameID,Dest,Srce,$02
	RETURN

CheckSum:	
	
	MSBChkSum = b24 XOR b26 XOR b28 XOR b30 XOR b32 XOR 
b34 XOR b36 XOR b38 XOR b40 XOR b42 XOR b44 XOR b46 XOR 
b48 XOR b50 XOR b52 XOR b54
	LSBChkSum = b25 XOR b27 XOR b29 XOR b31 XOR b33 XOR 
b35 XOR b37 XOR b39 XOR b41 XOR b43 XOR b45 XOR b47 XOR 
b49 XOR b51 XOR b53 XOR b55
	RETURN


#rem
'Notes

'FrameID

$1E - Send SMS
$7F - Acknowledge Frame
$D1 - Get Version

'Dest

$00 - Phone
$0C - PC/MCU

'Srce

$00 - Phone
$0C - PC/MCU

'Command

$02 - SMS Function

#endrem
MPep raises a valid point re using cellphones in that you will need to find a model that allows serial comms over serial rather than later models that use USB. Heaps of interweb info on Nokia f-bus.

As for sending/receiving AT commands, will finish my write up and post over the next few days, now that nearing the end of a very busy month at work.

Cheers
 
Last edited:

MPep

Senior Member
@LF,

Does the above PDU code work?? Seeing as you changed over to AT commands, that is.
Thanks for posting :D

I have used AT commands for something else, and they sure are straight forward to use.

I am aware of F-Bus and M-Bus, although I haven't used them. They appear proprietary to Nokia though. PDU should be accepted by ALL cellphones. AT commands are only used by some manufacturers who are nice enough to us!!

@MODERATORS,
LF's post seems unreasonably wide. Any way of fixing that?
 
Last edited:

lanternfish

Senior Member
@MPep

It simulated ok. 7-bit text in was compressed to correct 8-bit BDU out. I used a couple of online converters to check. Wish I had been more thorough in commenting the code as I may have a wee bit of trouble describing each line.

The scratchpad was used to store the text starting at address 0 and the PDU output was stored from address 128.

Yes, f-bus and m-bus are proprietary to Nokia but both are a serial bus The m-bus being single line, bidirectional and the f-bus haveing seperate rx and tx lines. A Nokia 6100 will use m-bus and auto-detects the baud rate. That makes things easy. Of course, the f-bus voltage levels are 3V.

I think the width problem is because of the 128 U's that are meant to wake up the Nokia cellphone and the PDU serial output lines. I have split the lines so they will need to be rejoined to test in simulator.

AT is definitely the way to go if the cell phone allows it. Am wondering if it is even worth experimenting with all these when Sparkfun and others sell Telit quad band GSM modems that are combined with a SirfIII GPS module. Expensive!

Cheers
 
Last edited:

MPep

Senior Member
Hi LF,

Thanks for that. So your current code is for AT commands over M-Bus? Interesting.

You needed 128x "U" to wake up the cellphone?? Incredible!

Thanks for changing your posting.
Much easier to read.

Will study this in due course.

Cheers,
MPep.
 

lanternfish

Senior Member
The information of using 128 U's was from some website. Not sure why they would be needed as this wasn't made clear.

Didn't get to hardware test the code as I found I could use AT commands and so stopped development of the program.

And in my hurry to post I mistakenly wrote M-Bus when it should have been F-Bus.

I a m re-reading some notes on PDU conversion so should be able to add some comments to the program in the next few days.

Am also stripping back the AT comand program to make it more readable for others, particularly to answer vttom's original query.

Cheers
 

lanternfish

Senior Member
A wee update. I believe the 128 U's are a way of sync'ing the auto-baud function with early/mid model Nokias. I wonder if 128 are actually needed?

On Monday I will provide some comments on my PDU conversion code. I will also start a new thread on AT commands to Nokia 6100 and will link to it in this thread as well.

Cheers
 
Top