Introduction: Two Way MQTT-SMS Bridge (Linkit One)

About: IT-professional by day, DIY hobbyist (among other things) on my free time. I always have one or more projects going on. Usually something to do with home improvement or a tech project or a combination of the t…

This project is for the Linkit One. This prototype board is programed like an Arduino but has a lot more features. This project demonstrates the GSM (SMS) and built in WiFi units.

The features of this project:

  • Connect to WiFi
  • SMS
  • Creates two-way SMS to MQTT bridge
    • Send outgoing SMS to any destination with any message body from the Linkit One board from any MQTT client in the network.
    • Relay incoming SMS messages to the MQTT bus. The first word (up to first space) is the topic. Anything following is payload. I.e. you can control your personal IoT by SMS. A word of caution though. If you have anything sensitive (alarm system?) you should definitely add code to qualify incoming numbers before passing messages to the MQTT bus.

Step 1: Setup

  1. Install the IDE as described by Mediatek:Linkit One IDE
  2. Upload a simple blink sketch to the LIO just to get warm.
  3. Get your SIM ready:
    1. First put the SIM in a phone
    2. Use phone settings to remove SIM-lock (PIN). The LIO GSM module doesn't support PIN.
    3. Slide the SIM into the holder on the back with the connector facing the board and the cut corner sticking out (see picture)

Step 2: The Code

  • Download the sketch
  • Download the PubSub MQTT client library for Arduino:
  • If you don't already have a MQTT server on your network, install one, e. g. Mosquitto server.
  • Install a MQTT GUI client for testing. I like MQTT-spy.
  • Open up the sketch and enter enter network settings and MQTT-server settings
  • Upload
  • Open up the serial monitor and watch the action.
  • If the WiFi connections succeeds but the MQTT connection fails (I had that problem), change protocol version to 3.1. Edit the PubSubClient.h like so:


Step 3: Using the Bridge

    Get started

    • Open MQTT-spy
    • Subscribe to everything: /# and #

    MQTT to SMS

    • Using MQTT-spy, publish to topic: /lio_1/smsto/your_phone_number. Whatever you put in the payload will be the message body of the SMS

    SMS to MQTT

    • Send a SMS to the Linkit One board. Anything before the first space is published to MQTT as a topic. Anything after is the payload. You can even do a loopback test by sending a SMS containing "/lio_1/smsto/your_phone_number hello".