Raspberry Pi and Frontline SMS
(I think I'm the first person to try this - so I decided to document the process.)
A few weeks ago, I won a Raspberry Pi at the #OTA12 hackday. It arrived on Friday, so I thought I would turn it into an SMS server using the incredible FrontlineSMS.
0. Setting up the Pi
This is the easy part. Follow the excellent guide on the eLinux wiki. Essentially, download the Debian image, extract, and dd it onto an SD card.
The hardest part was finding a full sized SD! In the end, I found an old adapter and stuck in a 2GB micro SD card.
1. First Boot
My first boot was a failure. Nothing appeared on the screen. So, I switched off the power, unplugged every lead, plugged them back in, and powered it on. Success!
The first thing I did was ensure the operating system was up to date.
Check for updates:
sudo apt-get update
Then, apply those updates
sudo apt-get upgrade
This took a few minutes.
Finally, set up SSH or VNC if you plan on using the machine remotely.
2. Dongle Hardware
FrontlineSMS maintains a list of USB dongles which work with its service. I used a Vodafone branded Huawei E220. Sold as Vodafone K3565
The Raspberry Pi only has 2 USB slots - the dongle was slim enough not to interfere with the other USB cable, but it did mean I could only run either a keyboard or a mouse without using a hub. It's recommended that you use a powered USB hub - although my keyboard and mouse didn't seem to draw too much power.
3. Frontline SMS
Downloading Frontline SMS via the commandline (using v1.6 because v2 isn't ready for Linux yet)
wget http://frontlinesms.com/download/secure/FrontlineSMS-distribution-1.6.16.3-linux_i686-dist.zip
Unzip
unzip FrontlineSMS-distribution-1.6.16.3-linux_i686-dist.zip
Run
cd FrontlineSMS-distribution-1.6.16.3 ./FrontlineSMS.sh
Gave an error - FrontlineSMS requires Java.
4. Installing Java
The Java install takes about 140MB of disk space. After downloading and extracting FrontlineSMS, I only had about 220MB of free space. I deleted the FrontlineSMS zip file and had 234MB free. Just about enough room!
sudo apt-get install openjdk-6-jdk
Wait several minutes and you'll be good to go.
5. Running for the First Time
Frontline SMS requires a GUI.
Running a GUI is as easy as typing
startx
The resolution was set at the slightly odd dimensions of 1264*672 - which meant there was a large black border around the screen.
Open a terminal (Start, Accessories, LXTerminal, then type
cd FrontlineSMS-distribution-1.6.16.3 ./FrontlineSMS.sh
After several minutes of waiting, FrontlineSMS started!
However, no matter what I tried, I couldn't get FrontlineSMS to detect the dongle. The OS could see it fine (using "lsusb" and "dmesg"), but it just didn't appear to be detected by FrontlineSMS.
A delve into the commandline, showed this error:
librxtxSerial.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform) thrown while loading gnu.io.RXTXCommDriver
6. Installing the Correct Libraries
We need to load the correct (ARM) version of rxtx.
sudo apt-get install librxtx-java
Find where the install process has dumped it
find . -name "librxtxSerial.so"
It should show you two location - the first being where the correct version is, the second where the FrontlineSMS version is.
./usr/lib/jni/librxtxSerial.so ./home/pi/Desktop/FrontlineSMS-distribution-1.6.16.3/librxtxSerial.so
All we need to do is overwrite the incorrect version.
cp /usr/lib/jni/librxtxSerial.so /home/pi/Desktop/FrontlineSMS-distribution-1.6.16.3/
Then, run
./FrontlineSMS.sh
And, after some warnings and waitings, you should see
Hey Presto! FrontlineSMS up and running on a Raspberry Pi!
(Oh! I finally worked out how to do screenshots! install scrot and run "scrot -d 10" to take a screenshot after 10 seconds.)
7. Manually Sending an SMS
Running FrontlineSMS via Java on a 700MHz ARM device is very slow. It is possible to talk directly to the dongle and manually tell it to send SMS.
First, I installed picocom.
sudo apt-get install picocom
To find out where the dongle has been installed, type:
dmesg
Which will give an long output, which should contain some text like this like this:
option 1-1.2:1.1: GSM modem (1-port) converter detected usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0 option 1-1.2:1.0: GSM modem (1-port) converter detected usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1
The dongle installs itself in two places - ttyUSB0 & 1. It's the first one we want.
Connect by issuing this command
picocom /dev/ttyUSB0 -b 115200 -l
Which will give you the output
port is : /dev/ttyUSB0 flowcontrol : none baudrate is : 115200 parity is : none databits are : 8 escape is : C-a noinit is : no noreset is : no nolock is : yes send_cmd is : ascii_xfr -s -v -l10 receive_cmd is : rz -vv Terminal ready
From now on in, we're typing commands directly into the dongle. You cannot press the delete key! Copy & paste, or be careful when typing!
First, to make sure everything is working, we type
AT
We should see this response
OK
Next, set the dongle to text mode
AT+CMGF=1
Again, the response should be
OK
Let's send our first SMS!
AT+CMGS="+447700900123"
This will not say "OK", rather, it will prompt us to type a message
>
Type your message, so the screen looks like
> This is a test
DO NOT HIT ENTER. Instead, hit CTRL and Z at the same time.
You should see a response like
+CMGS: 193 OK
The number is the "sent items" reference. Within a few moments, the SMS should have been received.
You can send an SMS to the dongle. To check for messages, type the command
AT+CMGL="ALL"
You should see all the messages in the inbox
+CMGL: 0,"REC READ","+447700900000",,"12/06/19,13:53:19+04" Received +CMGL: 1,"REC READ","+447700900321",,"12/06/23,17:16:29+04" Testing +CMGL: 2,"REC UNREAD","+447700900555",,"12/06/23,23:27:48+04" This is another test
To quit picocom, hold down CTRL, then hold down A, then hold down X.
Useful Links
A collection of links I found useful when writing this blog post http://designbuildtestrepeat.wordpress.com/2008/04/29/huawei-e220-on-linux-for-sms/ http://www.diafaan.com/sms-tutorials/gsm-modem-tutorial/ http://www.shapeshifter.se/2008/04/30/list-of-at-commands/ http://raspberrypi.homelabs.org.uk/raspberrypi-the-arduino-development-tool/ http://developer.vodafone.com/labs/opensource/linux-connection-manager/operating-systems/ubuntu-linux-setup/ For unlocking Huawei modems
garagedeveloper says:
svbito says:
Brice says:
Nick says:
Lars says:
Lars says:
Lars says:
Adel says:
aryeh says:
Danielle Murray says: