MQTT with Sensor Tag

MQTT with Sensor Tag

This is an example using the SensorTag Bluetooth module from Texas Instruments to send data to TagoIO. There is no code modification needed in the SensorTag side, and as it uses the MQTT protocol, only a configuration setup is needed. For the connectivity, the SensorTag uses Bluetooth to communicate to a mobile device. Texas Instruments offers a mobile app that converts this communication to a MQTT protocol and pushes the data to cloud using cellular or wifi technology.

Learn more about the SensorTag CC2650 and how to get started.

In this example, all the data from the sensors will be post to TagoIO. We will visualize the sensor information on the dashboard in real-time. In the current hardware version that was tested here, the SensorTag contains 10 sensors including support for light, digital microphone, magnetic sensor, humidity, pressure, accelerometer, gyroscope, magnetometer, object temperature, and ambient temperature. There is no native way to control the LED or Buzzer of the module using MQTT subscribe method.

Adding the Device

Click on Devices , then click on 'Add Device' button. Select the connector type: MQTT, look for the SensorTag device.

When a device is created, go to details of your device, then copy the token generated for it.

Setup the SensorTag to send data to TagoIO

First, download the App for Android or Apple devices called SensorTag. Make sure that you select the right App for your CC2650 Bluetooth SensorTag, as other similar versions may be available for download. Install it, and follow the steps showed here.

Open the App, and push the power key on your SensorTag so that it starts to communicate with your mobile device, then click on Cloud configuration, make sure that the Bluetooth module of your device is enable, then click on your device on the list.

Click in All, or if you have multiples SensorTag click on icon on top right, then select Advanced Configuration.


In the Advanced cloud config section, select the MQTT Protocol and then configure the following fields:

Broker Address: mqtt.tago.io (without https://)
Broker Port: 1883
Username: tagoio
Password: <Enter here the Device-token (copied on last step)>
Publish Topic: data
Subscribe Topic: (not used - leave as is)
Publish rate: 5000 (may change later)

One example of a configuration screen is showed in the figure below. The highlighted fields are the ones that you need to enter with the information as mentioned above.

Now, you can turn the switch on of the App as showed below to start pushing data to TagoIO.

If the configuration is correct and you have a network connection, some data should already have arrived in your account.

You can see the data arriving on Live Inspector, it's a tab on your device details, your device is connected on TagoIO but the data will not be saved on your bucket yet, you should create an Action to choose a MQTT topic.  This last step is important because will can have a lot topics and just save one and not another.

Creating a MQTT Action to save data

Click on Action, create a new one, select MQTT Topic as the type of trigger, and Insert data to device bucket as the type of action. Then select your device and type data, on topic, save and you are done.


    • Related Articles

    • MQTT

      MQTT stands for MQ Telemetry Transport; it's an extremely simple and lightweight publish-subscribe messaging protocol. It was designed for constrained devices and low-bandwidth, high-latency or unreliable networks. TagoIO has its own MQTT broker, ...
    • MQTT - Process data, Publish it and Subscribe to a topic

      In this tutorial, you will learn how to process data, publish to a topic, and subscribe to it. We will be using the MQTTX client throughout this tutorial. Connecting to TagoIO MQTT Broker To publish a topic via TagoIO's MQTT, you must first add a ...
    • Trigger by MQTT Topic

      The trigger type, Trigger by Variable, allows you to execute your Action when data is sent to an MQTT topic. TagoIO has its own MQTT broker that is responsible for pushing data to clients in case something new is published in the specific topics they ...
    • MQTT - Publishing and Subscribing

      You can publish to your MQTT topics by coding a script that will run from an Analysis. When the analysis runs, your script can publish a topic that can be received by any device that has subscribed to that specific topic. There are different ways to ...
    • MQTT Retain on TagoIO Broker

      TagoIO's MQTT broker, while not designed to support the native retain feature found in standard MQTT protocol implementations, we offer a workaround to achieve similar functionality. This approach involves utilizing Analysis and Actions features to ...