Home

Awesome

Prerequisites

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.

How does it work

Diagram

How-to

Install

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

Configure

Device

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.

Environment variables

Send

The default {prefix} for topics is sms2mqtt.

To send SMS:

  1. Publish this payload to topic sms2mqtt/send :
    {"number":"+33612345678", "text":"This is a test message"}
  2. SMS is sent
  3. A confirmation is sent back through MQTT to topic sms2mqtt/sent :
    {"result":"success", "datetime":"2021-01-23 13:00:00", "number":"+33612345678", "text":"This is a test message"}

Receive

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"}

Other topics

Additionnal topics (enabled using MOREINFO flag)

heartbeat topic (enabled using HEARTBEAT flag)

Troubleshoot

Logs

You need to have a look at logs using :
docker logs sms2mqtt

Updating

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.

Ref/Thanks

I want to thanks those repositories for their codes that inspired me :