Two Factor Authentication by SMS is a reasonable security addition, but it can be very infuriating. It’s impossible to sign up for a google account without a mobile number, and if you change your number you can easily get locked out of an account. PayPal is especially annoying, as you can’t seem to change to mobile number outside your country of registration – since I’m currently traveling abroad without a UK phone number I often come up against a brick wall.

I’ve tried to use online services like Twillio and Nexmo, but they deliberately block any authentication codes from Google or other such services.

So… I had a spare Raspberry Pi 1B sitting around, so it would make a good project to buy a 3G USB dongle and have a go at creating my own SMS to email gateway, that I could buy a UK sim card for and stick in a friendly persons router next time I am in the UK….

Frustratingly, the Pi 1B is not really up to the task. Basically the main problem is that it cannot send enough power to the 3G USB dongle in modem mode, and so constantly resets. I think the USB ports can only supply something like 100mA on the Pi 1B which I remember being and issue when I was using it when I first got it (This is the original 256Mb version with the polyfuses). The option of having a powered USB port would mean I’d need 2x PSU plus network cable to router. So I gave up, and plumped for using my Pi Zero v1 plus a GPIO based wifi card (before the days of the Pi Zero W!). So it was a bit disappointing to not be able to find a use for my ‘classic’ Pi 1B, but it does show that the later models really have made a good step up, not just performance but sorting out the power issues which are a bit of a bug bear.

One thing that I did have to do on the Pi 1B (I suspect because of low power), was to get the 3G dongle to switch from USB disk to USB modem mode. This site basically got me there:

But I have to say, the Pi Zero was a lot smoother….

Raspberry Pi Zero 1
Redbear Wifi & bluetooth pHAT
micro usb adaptor cable
HuaWei E173 3G modem
Sim card

After installing Raspbian lite (April 2017), I setup dataplicity (which allows remote connection easily from anywhere in the world, so I can change things remotely if needed). Then I did the following to setup:

$ sudo apt-get update  
$ sudo apt-get install gammu   
$ lsusb # check it is attached
Bus 001 Device 003: ID 12d1:1436 Huawei Technologies Co., Ltd. E173 3G Modem (modem-mode)
# it is already in modem mode!

$ dmesg | grep tty # look to find which console the dongle is on
$ sudo gammu-config # in the menu set port: /dev/ttyUSB0
$ sudo gammu --identify
Device               : /dev/ttyUSB0
Manufacturer         : Huawei
Model                : E173 (E173)
Firmware             :
IMEI                 : xxxxxxxxxxxxxxxxxxx
SIM IMSI             : xxxxxxxxxxxxxxxxxxx
# we can see the details of the dongle and sim

$ gammu getsms 0 1 
Location 2, folder "Inbox", SIM memory, Inbox folder
SMS message
SMSC number          : "+447777555555"
Sent                 : Sat 03 Dec 2016 18:52:58  +0800
Coding               : Unicode (no compression)
Remote number        : "555555"
Status               : Read

Received test message string here

So that’s the setup completed. Part 2 I’ll get some python code together to link up sms and email.