This is an example using the SensorTag Bluetooth module from Texas Instruments to send data to Tago. 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.

To learn more about the SensorTag CC2650 and how to get started, click here.

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 (left side menu), then click on Add Device button. Select the device type: MQTT. The SensorTag module will be the device to be added, we will give it the name ‘dev01’. Therefore, enter with the name ‘dev01’ and click on ‘Save’.

When a device is created, Tago automatically creates a bucket for it. 

All devices should use a valid token when accessing TagoIO. You can copy the device-token from the bottom of the page as shown below. 

If you already closed this page, you can always go later to the ‘General information’ section of the Device, click on ‘Tokens’ , and copy the token to be added in the SensorTag and Analysis section later. 

Adding the Analysis

For this example, we will setup the SensorTag to publish data to a reserved topic that will trigger an analysis (to run the script that you will upload). The topic is: tago/analysis/analysis_id.

A payload will be pushed to the analysis to be parsed, and the data will be saved in the bucket. The analysis_id used here will be the one you will generated now.

There are three steps to complete this operation:

  1. In your account, under the Analysis section, add a new analysis. Select Timer Interval = never (or Timer Disabled), and upload the file that contains the script to run. The script coded in Noje.js can be found here. Make sure that you upload only the *.js file.
  2. Under the Environment Variables tab, enter with: Variable Key: device_token and Variable Value: <paste the device-token here>
  3. From the tab More, copy the AnalysisID to be used in the MQTT Setup later. (Make sure you are copying the AnalysisID, and not the Analysis-Token).

And, save your work in this section.

MQTT Setup

Because all sensors are integrated inside the SensorTag, and its firmware is ready to read all sensors and push the data to a server using MQTT protocol when paired with a mobile device, only a quick setup is necessary.

First, download the App for Android or Apple devices called SimpleLink Starter. 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 any key on your SensorTag so that it starts to communicate with your mobile device. Make sure that the Bluetooth module of your device is enable.

Click on the cloud icon with a X on top to setup your MQTT broker. Then, click on Edit, and select Advanced configuration under the Manual configuration section.

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

Broker Address:
Broker Port: 1883
Username: token
Password: <Enter here the Device-token>
Publish Topic: tago/analysis/<Enter here the Analysis_ID>
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 Tago.

If the configuration is correct and you have a network connection, some data should already have arrived in your account. You are ready to visualize the data at Tago.

Building the Dashboard

Let’s build a nice dashboard to visualize the data sent by your SensorTag. Click Dashboards, then +on the top right side of the dashboard, type the name of your dashboard, and click on ‘Save’. Let’s add one widget to show the variable temperature. Click on ‘Add Widget’ button and pick the widget Gauge.

Start the configuration of this widget by adding the variable to be displayed. Type the variable name that will be sent by the device as ‘temperature’, select the variable. Then, click Save, and your widget will be ready!

You can continue to add more widgets to visualize the rest of the sensors from SensorTag. Here is one example of how your dashboard may look like when you add more widgets like gauge, dial, and chart.

Also, you can create scripts to perform more advanced operations and add actions to send email for notifications or reports.