Tutorial: Querx and ThingSpeak

Sending measured data to ThingSpeak

The Querx range of sensors supports the cloud service ThingSpeak, which lets the devices send measured data directly to the cloud. There they can be viewed or visualized and are available via the ThingSpeak programming interface.

After completing this tutorial you will be able to retrieve your tracked data via ThingSpeak. This does not require any direct interaction with Querx itself. ThingSpeak further enables the visualization and further processing of data in other applications.

Configuring ThingSpeak

In order to use ThingSpeak, you will require a MathWorks account. Therefore, you need to register at https://thingspeak.com.

ThingSpeak arranges the data it receives in channels. An automatically generated Write API Key is required in order to write data into the channel.

First off, a channel on which Querx can communicate with ThingSpeak needs to be created.

Open the URL https://thingspeak.com/channels in your browser and click the button New Channel.

Enter a name and a description for your channel into the input fields Name 1 and Description 2 in the tab Channel Settings. Enter Temperature into Field 1 3. Place a check mark next to the field, in order to activate it.

You should also select the option Make Public 1. This will let you test the configuration simply by following the URL.

Notice: The option Make Public will allow anyone who knows the URL to view the channel’s data. Select Private View if you do not want your channel to be public.

All other settings are optional. The section Help provides additional information concerning their functionality.

Click the button Save Channel 2 in order to save your settings and create the channel.

 

Retrieving the Key for the API

The channel has been created, but as mentioned above, you will still require the Write API Key in order to send data to the channel.

Open the overview My Channels (https://thingspeak.com/channels) and click the tab API Keys.

 

The following page will display your random generated keys. The Write API Key 1 is required to write data to the channel. The Read API Key is required if you want to read the data out in other applications.

Your channel’s Write API Key and Channel ID 2 are required for the configuration of ThingSpeak in the Querx web interface.

Configuring ThingSpeak in the Querx web interface (from firmware version 6)

To send data to a cloud, two things are needed: The configuration settings for HTTP Push and a template file that defines the data format.

A template file for use with ThingSpeak can be downloaded here.

In the Querx web interface select the configuration page Maintenance / Firmware. Under the title Install Content click on Browse... 1. A file selection dialog appears. Navigate to the downloaded template and confirm your selection. The name of the template now appears in the File field.

Click Send 2 to transfer the file to the device. This takes only a fraction of a second. Afterwards the template appears in the content list 3.

Now switch to the configuration page Interfaces / Actions. Select HTTP Push 1 as action type and Time interval 2 as event type. Now create a new action by pressing the button Add 3.

First, select the name of the template from the list, in this case thingspeak.tpl 2. After the selection, some input fields will change. URL and HTTP method will get the value from the template. In the field API-Key or Variable 1 3 enter the Write API Key.

The Update rate field 4 determines how often Querx should send the current measurement value to ThingSpeak. Select in which interval (in minutes) the value should be updated. Enable the action with a click on Enable 1.

To evaluate the configuration, click on the Test button 5. Querx will then immediately send the current measurement values to ThingSpeak. When the data has been accepted by the other side, the button turns green.

The measured values can be observed directly in your browser at https://thingspeak.com/channels/channel_number, whereby you must replace channel_number with the Channel ID.

Configuring ThingSpeak in the Querx web interface (from firmware version 4)

To send data to a cloud, two things are needed: The configuration settings for HTTP Push and a template file that defines the data format.

A template file for use with ThingSpeak can be downloaded here.

In the Querx web interface select the configuration page Maintenance / Firmware. Under the title Install Content click on Browse... 1. A file selection dialog appears. Navigate to the downloaded template and confirm your selection. The name of the template now appears in the File field.

Click Send 2 to transfer the file to the device. This takes only a fraction of a second. Afterwards the template appears in the content list 3.

Now switch to the configuration page Interfaces / HTTP Push. First, check the box Enable 1. In the field Variable 1 2 enter the Write API Key. Select the name of the template from the list, in this case thingspeak.tpl 3.

The URL for data to ThingSpeak is api.thingspeak.com/update 4 and the method used is POST 5. The Update rate field 6 determines how often Querx should send the current measurement value to ThingSpeak. Select in which interval (in minutes) the value should be updated. Save your settings with a click on Save 7.

To evaluate the configuration, click on the Test button 8. Querx will then immediately send the current measurement values to ThingSpeak. When the data has been accepted by the other side, the button turns green.

The measured values can be observed directly in your browser at https://thingspeak.com/channels/channel_number, whereby you must replace channel_number with the Channel ID.

Configuring ThingSpeak in the Querx web interface (up to firmware version 3)

In the Querx web interface select the configuration page Interfaces / Cloud. First check the box Enable 1 to activate the ThingSpeak functionality and to allow input in the other fields. In the field API-Key 2 enter the Write API Key and for channel number 3 the Channel ID of your ThingSpeak channel. The field ID for temperature 4 determines in which of the 8 possible ThingSpeak fields Querx should write the temperature data, so you have to enter a number from 1-8 there. Since in this tutorial the first field was activated, enter 1 for field ID. The Update Rate 5 field determines how often Querx should send the current measurement value to ThingSpeak. Select in which interval (in minutes) the value should be updated. To evaluate the configuration, click on the Test button 6. Querx will then immediately send the current measurement values to ThingSpeak.

These readings can be viewed directly in your browser at https://thingspeak.com/channels/channel_number, after replacing the channel_number with the Channel ID.

After a successful test click on Save in the Querx web interface to make the settings permanent.

Querx now sends the current readings of the connected sensors to ThingSpeak in defined intervals.