You need a GSM dongle "compatible" with Gammu : https://wammu.eu/phones/
Even if your dongle is not listed, it should works with.
If you need specific gammu settings to be added, feel free to open a PR or an issue.
For Docker, run it by executing the following commmand:
docker run \
-d \
--name sms2mqtt \
--restart=always \
--device=/dev/ttyUSB0:/dev/mobile \
-e PIN="1234" \
-e HOST="192.168.1.x" \
-e PORT=1883 \
-e PREFIX="sms2mqtt" \
-e CLIENTID="sms2mqttclid" \
-e USER="usr" \
-e PASSWORD="pass" \
domochip/sms2mqtt
For Docker-Compose, use the following yaml:
version: '3'
services:
sms2mqtt:
container_name: sms2mqtt
image: domochip/sms2mqtt
devices:
- /dev/serial/by-id/usb-HUAWEI_HUAWEI_Mobile-if00-port0:/dev/mobile
environment:
- PIN=1234
- HOST=10.0.0.2
- PORT=1883
- PREFIX=sms2mqtt
- CLIENTID=sms2mqttclid
- USER=mqtt_username
- PASSWORD=mqtt_password
restart: always
device
: Location of GSM dongle (replace /dev/ttyUSB0 with yours), it need to be mapped to /dev/mobile
NOTE: The /dev/ttyUSBx
path of your GSM modem could change on reboot, so it's recommended to use the /dev/serial/by-id/
path or symlink udev rules to avoid this issue.
PIN
: Optional, Pin code of your SIMHOST
: IP address or hostname of your MQTT brokerPORT
: Optional, port of your MQTT brokerPREFIX
: Optional, prefix used in topics for subscribe/publishCLIENTID
: Optional, MQTT client id to useUSER
: Optional, MQTT usernamePASSWORD
: Optional, MQTT password
The default {prefix} for topics is sms2mqtt.
To send SMS:
- Publish this payload to topic sms2mqtt/send :
{"number":" 33612345678", "text":"This is a test message"}
- SMS is sent
- A confirmation is send back through MQTT to topic sms2mqtt/sent :
{"result":"success", "datetime":"2021-01-23 13:00:00", "number":" 33612345678", "text":"This is a test message"}
- ✔️ You can send SMS to multiple Numbers using semicolon (;) seperated list. A confirmation will be sent back for each numbers.
- ✔️ You cand send very long messages (more than 160 char).
- ✔️ You can send unicode messages containing emoji like :
{"number":" 33612345678", "text":"It's working fine 👌"}
- ✔️ You can send very long messages containing emoji
Received SMS are published to topic sms2mqtt/received like this :
{"datetime":"2021-01-23 13:30:00", "number":" 31415926535", "text":"Hi, Be the Pi with you"}
- ✔️ You can receive long SMS messages
- ❌ You can't receive any MMS
- sms2mqtt/signal: A signal quality payload is published when quality change
E.g.{"SignalStrength": -71, "SignalPercent": 63, "BitErrorRate": -1}
You need to have a look at logs using :
docker logs sms2mqtt
To update to the latest Docker image:
docker stop sms2mqtt
docker rm sms2mqtt
docker rmi domochip/sms2mqtt
# Now run the container again, Docker will automatically pull the latest image.
I want to thanks those repositories for their codes that inspired me :
- https://github.com/pajikos/sms-gammu-gateway : I have a Huawei dongle and I found out that gammu 1.39 works fine with it 👌
- https://github.com/pkropf/mqtt2sms