Cracking on with my Raspberry Pi, I’ve written my first program in Python.
The aim – to be able to send an SMS via a 3G USB dongle.
The problem – the way SMS needs to be encoded is hideously complicated.
For example, suppose you want to send “This is a very simple message :-)” to the phone number +447700900123.
This is the command that you need to send to your dongle:
WHAT? THE? JUDDERING? FUCK?!
Python is already pre-installed on the Raspberry Pi – which is handy. So here is a tool I whipped up which will generate the above gibberish.
Running the program should show this:
Which phone number do you want to send an SMS to? (e.g. +447700900123) : What message do you want to send? : For FLASH SMS, type 0. For regular SMS, type 1 : Which SMSC will you use? (e.g. +447802002606) :
And will output this:
The source is on GitHub – or please find in below for your edification and delight.
This is my first outing in Python, so I’m sure I’ve made a few syntactic and stylistic mistakes. Any corrections gratefully received.
The source is on GitHub.
In order to actually send the SMS, you will need to put the modem into PDU mode, this is done by the command
So, as per my earlier post on sending SMS, the complete sequence is
AT+CMGF=0 AT+CMGS=60 07914487...
Then press CTRL+Z to send.