Tutorial: Querx and dweet.io

Sending measured data to dweet.io and visualizing it with freeboard.

With the release of firmware version 3.4, support for the cloud service dweet.io was added to the Querx range of sensors. This lets the devices send measured data directly to the cloud. The data is then available in the form of dweets, which can be easily retrieved as JSON objects, making it possible to process them in other applications or visualize them.

Querx Variants

The published data differs between the individual variants of Querx, as the models support different types of sensors. In this tutorial we will use a Querx THP which measures temperature, humidity and air pressure to exemplify the configuration. Nonetheless, the tutorial is valid for all variants.

Preparations

Before we can begin, the firmware needs to be updated to version 3.4 or later. Please see this tutorial for step-by-step instructions on updating your device’s firmware.

You will also need to know the IP address at which the Querx sensor that will be sending its data to the cloud can be accessed. The address can, for example, be determined by using our tool Device Discoverer. The application can be downloaded here.

Alternatively, you can use the name provided by mDNS. If you have not specified a different name, the default name will be querx000000.local. In this string 000000 is a placeholder for the last 6 digits of the MAC-address printed on the device’s casing.

Objective

After completing this tutorial you will be able to view all your measured data in a customizable dashboard at freeboard.io, or retrieve it in the JSON format to process it in other applications. This does not require any direct interaction with Querx itself.

Dweet-1
Configuring dweet.io in the Querx Web Interface

Enter your Querx sensor’s IP address or the name assigned by mDNS into your web browser’s address-bar, in order to access the Querx web interface. (See the section Preparations for more info on how to determine the sensor’s address and name.)

Dweet-2

If you have set up a password, click Login in the top right corner and enter your user data. If you have not set up a password, you can skip this step.

Dweet-3

Click Configuration (1) and then Cloud (2) in the menu Interfaces, in order to open the page that will let you configure the cloud services.

Dweet-4

The page lists several cloud services, but in this tutorial we will only be concerned with dweet.io.

Dweet-5

First, click the button Activate (1) to activate the dweet.io function and make it possible to enter data into the other input fields.

dweet.io merely uses unique names to identify devices sending data to the cloud. Hence, a unique name which no one else would use needs to be entered in the field Name (2) (e.g. “zaphod-beeblebrox”, “freezer42c” or “8tg6w-2b7q8”).

The field Update rate (3) determines how frequently Querx sends its data to dweet.io. Select the rate in minutes.

Click the button Test (4) to test the configuration. Querx will then send the current values to dweet.io.

These values can be viewed in your browser at the URL https://dweet.io/follow/devicename. In this link devicename is a placeholder for the unique name you gave your device.

Click Save (5) in the Querx web interface after a successful test, in order to save your configuration.

dweet.io

Dweet-6

Querx will now send the connected sensors’ current values to dweet.io in the specified interval. The values can be retrieved at https://dweet.io/follow/devicename. Values will already be displayed, if you clicked Test during the configuration. Otherwise they will appear after the next refresh.

Dweet-7

By clicking Raw, you can also view the raw JSON objects that are returned by the API.

Dweet-8

The most recent dweets can be retrieved as JSON objects in text format via the links Last 5 dweets and Last dweet on the Querx web interface’s configuration page.

Customizing Sensor Names

As the various models of Querx feature different types of sensors, the dweets will also include different data, depending on the device used. The names that are applied to the sensor data by dweet.io correspond to the names that are specified for the sensor types in the Querx web interface.

Dweet-9

In order to find out what names have been specified for sensors and to change the names, please open the configuration area of the Querx web interface and navigate to the different sensor types by clicking Sensors in the menu to the left.

Dweet-10

You can now specify a clear name in the input field Sensor name. After clicking Save, this name will then be used for messages to dweet.io.

The measured data will be available as the attribute content.sensorName of the JSON object. In this case, sensorName is a placeholder for the specified name.

freeboard.io

Creating a Custom Dashboard with freeboard

In addition to the basic display of measurements on dweet.io, freeboard can be used to generate a dashboard that displays the values in your preferred mode. freeboard uses the data saved by dweet.io.

Dweet-11

This requires an active freeboard.io account. You can register at https://freeboard.io/signup. The dashboards you create will automatically be assigned to your account.
(freeboard does also work without an account, but in this case the generated dashboards can not be customized.)

Dweet-12

Open the page https://dweet.io/follow/devicename once again, replacing the placeholder devicename with the name of your device as specified in the dweet.io settings.

Click Create a Custom Dashboard in the top right corner to automatically generate a dashboard from your sensor data. You will be forwarded to freeboard.io.

Dweet-13

The newly created dashboard is fully operational and is updated with the data that Querx sends to dweet.io.

If you would like to share the dashboard with anyone, just send them the URL displayed in your browser.

You can further customize your dashboard to make it suit your needs, by changing the way the data is visualized or adding alerts and notes.

freeboard.io offers an interactive demonstration which is accessible at https://freeboard.io/board/tutorial.

Retrieving Data via the API

All uploaded data can be retrieved via the dweet.io API once Querx has been configured for dweet.io.

The free version of dweet.io saves the last 5 dweets for up to 24 hours. The fee-based service dweetPro offers additional options.

If you wish to process the data uploaded to dweet.io, you will require a URL that the application can use. In JavaScript, for instance, this works by a fetch() instruction or an XMLHttpRequest.

The required URLs are constructed in the following way:
(Replace devicename with the name you gave Querx on the configuration page.)

Retrieving the Last dweet:

https://dweet.io/get/latest/dweet/for/gerätename

This API query only returns the most current dweet as a JSON object.

Exemplary answer for Querx THP:
{“this":"succeeded","by":"getting","the":"dweets","with":[{"thing":"kobold-werkstatt","created":"2017-05-18T15:28:00.719Z","content":{"Temperature":24,"Humidity":57,"Pressure":1002.6}}]}

Retrieving the Last 5 dweets:

https://dweet.io/get/dweets/for/gerätename

This API query will return a JSON object that contains the last 5 dweets. If you are using dweetPro to save and retrieve more than 5 dweets, more options for the retrieval of saved dweets are available.

Exemplary answer for Querx THP:
{"this":"succeeded","by":"getting","the":"dweets","with":[{"thing":"kobold-werkstatt","created":"2017-05-18T15:27:00.460Z","content":{"Temperature":24,"Humidity":57,"Pressure":1002.6}},{"thing":"kobold-werkstatt","created":"2017-05-18T15:26:01.203Z","content":{"Temperature":24,"Humidity":57,"Pressure":1002.6}},{"thing":"kobold-werkstatt","created":"2017-05-18T15:25:00.868Z","content":{"Temperature":24,"Humidity":57,"Pressure":1002.6}},{"thing":"kobold-werkstatt","created":"2017-05-18T15:24:00.572Z","content":{"Temperature":24,"Humidity":57,"Pressure":1002.6}},{"thing":"kobold-werkstatt","created":"2017-05-18T15:23:00.312Z","content":{"Temperature":24,"Humidity":57,"Pressure":1002.6}}]}