Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

Following page describes how to use a ZTE ML190 USB drive to receive SMS and forward them to another mobile phone number. But you can also send the SMS in an eMail or do other stuff. You can control any devices at home, i.e. turn on or turn off some device, open and close your garage and much more.


Update 5/2/2023

gammu requires Pyhon2 and will not be migrated to Python3. Therefore I now use smstools. Sample event handler smsevent includes a lot of sample code which only has to be adapted to the specific requirements.




Following description is for a ZTE ML190 USB Stick

Bus 001 Device 009: ID 19d2:0117 ZTE WCDMA Technologies MSM
T:  Bus=01 Lev=02 Prnt=02 Port=02 Cnt=03 Dev#=  9 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=19d2 ProdID=0117 Rev=00.00
S:  Manufacturer=ZTE,Incorporated
S:  Product=1&1 Surf-stick
S:  SerialNumber=MF190xxxxxxxxxxx
C:  #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 3 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage


SMS relay server overview

gammu is used to poll for SMS all the time. A small script is called whenever gammu receives a SMS. The content of the SMS is read and send via SMS to another phone or via eMail to some recipients. The script can easily be changed to do anything else with the SMS.


Infrastructure installation and test

sudo apt-get install usb-modeswitch usb-modeswitch-data

Now you should see ttyUSB devices

ls -la /dev/serial/by-id/
total 0
drwxr-xr-x 2 root root 100 Jan 12 19:38 .
drwxr-xr-x 4 root root  80 Jan 12 19:38 ..
lrwxrwxrwx 1 root root  13 Jan 12 19:54 usb-ZTE_Incorporated_1_1_Surf-stick_MF19001MOD010000-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root  13 Jan 12 19:54 usb-ZTE_Incorporated_1_1_Surf-stick_MF19001MOD010000-if01-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root  13 Jan 12 19:54 usb-ZTE_Incorporated_1_1_Surf-stick_MF19001MOD010000-if02-port0 -> ../../ttyUSB2

The device is either /dev/ttyUSB2 or /dev/ttyUSB3 and thus an udev rule in /etc/udev/rules.d/98-usb-serial.rules has to be created and activated with udevadm trigger

SUBSYSTEM=="tty", ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="0117", SYMLINK+="ZTE"

Install gammu

sudo apt-get install gammu

Next call gammu-config to configure gammu.  Change port to /dev/ZTE and connection to at. Next test the configuration with

gammu --identify
Device               : /dev/ZTE
Manufacturer         : ZTE
Model                : MF190 (MF190)
Firmware             : BD_MF190V1.0.0B09
IMEI                 : xxxxxxxxxxxxxxx
SIM IMSI             : yyyyyyyyyyyyyyy

Next send an SMS to a known phone number, e.g. +4947114712

sudo -i -- bash -c 'echo "Das ist eine SMS von gammu" | gammu --sendsms TEXT +494711472'


Installation and configuration of gammu-smsd

gammu has to read incomming SMS and send them to another mobile. I wrote a small bash script which accomplishes this task. Copy this script into /usr/local/sbin.

sudo apt-get install gammu-smsd

The installation will try to start the service but will fail. You have to update the configuration in the next step.

sudo vi /etc/gammu-smsdrc

Make sure to have

# Configuration file for Gammu SMS Daemon
port = /dev/ZTE
connection = at
service = files
logfile = syslog
# Increase for debugging information
debuglevel = 0
# read and handle SMS
runonreceive = /usr/local/sbin/
# Paths where messages are stored
inboxpath = /var/spool/gammu/inbox/
outboxpath = /var/spool/gammu/outbox/
sentsmspath = /var/spool/gammu/sent/
errorsmspath = /var/spool/gammu/error/

gammu-smsd now has to be restarted again

sudo systemctl start gammu-smsd
sudo systemctl status gammu-smsd.service

Now check whether gammu-smsd sends a SMS

sudo -i -- bash -c 'echo "This is a SMS from gammu" | gammu-smsd-inject TEXT +491714711471


Activation and contol of gammu-smsd

Sometimes it's required to start/stop the gammu-smsd

sudo systemctl stop gammu-smsd
sudo systemctl stop gammu-smsd

The SMS relay server sends eMails to two different eMails: One is used by the admin and the other is used by the phone owner. All SMS are send to both. SMS starting with * are send to the admin only.

Special SMS can be send to manage/monitor the server. All eMails are send to the admin eMail.

*help - display possible admin commands
*status or just * - send an eMail to verify the server receives SMS and sends eMails
*echo <some text> - sends <some text> via eMail
*restart - restarts the gammu daemon
*cancel - shuts down the gammu daemon



gammu-smsd Log is /var/log/gammu-smsd.log. There you also find debug messages of the relay script.

 If there is a connectivity issue check whether a PIN is required:

echo -e 'AT+CPIN?\r' > /dev/ttyUSB2
cat /dev/ttyUSB2

If yes add following statement in your config file

pin = 4711

At some point in time I detected there were intermittent connection initialization failures. When I deleted the pin from the SMS card and thus the pin definition became obsolete everything works fine now.

In addition you can enable debug logging for gammu-daemon if you face any issue. debuglevel 3 usually is sufficient. Add

service = files
logfile = /var/log/gammu-smsd.log
# Increase for debugging information
debuglevel = 3



gammu-smsd version 1.38 hangs from time to time. Therefore I installed the current version 1.41. You have to checkout the git source github and build the code on your Raspberry  from source..

Update 11/22/2020: Looks like the intermittend hang is related to power or USB issues. I now use gammu 1.40 which is included in buster and use an active USB hub for the ZTE and the hangs are gone.

Update 8/23/2021: I got following message Ignoring incoming SMS info as not a Status Report in SR memory in the log. It looks like it's just a bad reception which causes this error message and incorrect error handling in gammu. I move the receiver to another place and the message vanished.




The Gammu Manual

Gammu smsd man page

Gammu man page

Gammu files backend

Add comment

*** Note ***

Comments are welcome. But in order to reject spam posts please consider following rules:
  1. Comments with string http are rejected with message You have no rights to use this tag
  2. All comments are reviewed by hand and thus it usually takes one day until a comment will be published.