The goal of this tutorial is to demonstrate the basic usage of the most popular ThingsBoard features. You will learn how to:
The tutorial is based on a popular facility monitoring use-case. We will show how to monitor temperature in a different parts of the building, raise alarms when temperature exceeds certain threshold and visualize collected data and alarms.
We recommend you to review the following video tutorial. All the resources used in this tutorial are listed below for your convenience.
If you don’t have access to a running ThingsBoard instance, use either Live Demo or Installation Guide to fix this.
In case you decided to install your own ThingsBoard server and loaded the demo data ( “–loadDemo” option, according to the installation guides), the list of default accounts (login/password) and device credentials is located here.
In order to simplify this guide, we will push data using HTTP, MQTT or CoAP protocol from your local PC. Please review connect your device guides for all available connectivity solutions and options and hardware samples to learn how to connect various hardware platforms to ThingsBoard.
Install preferred HTTP (cURL), MQTT (Mosquitto or MQTT.js) or CoAP (CoAP.js) client using following commands.
resources/curl-win.sh |
---|
|
resources/curl-macos.sh |
---|
|
resources/curl-ubuntu.sh |
---|
|
resources/node-mqtt.sh |
---|
|
resources/mosquitto-ubuntu.sh |
---|
|
resources/mosquitto-macos.sh |
---|
|
resources/node-coap.sh |
---|
|
This command works for Windows, Ubuntu and macOS, assuming that cURL tool is installed.
# Please replace $HOST_NAME and $ACCESS_TOKEN with corresponding values.
curl -v -X POST -d "{\"temperature\": 25}" $HOST_NAME/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:application/json"
# For example, $HOST_NAME in case of live demo server:
curl -v -X POST -d "{\"temperature\": 25}" https://demo.thingsboard.io/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:application/json"
# For example, $HOST_NAME in case of local installation:
curl -v -X POST -d "{\"temperature\": 25}" http://localhost:8080/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:application/json"
var msg = { temperature: +(Math.random()*5 + 25).toFixed(1)};
var metadata = {};
var msgType = "POST_TELEMETRY_REQUEST";
return { msg: msg, metadata: metadata, msgType: msgType };
Rule Engine overview - learn the Rule Engine basics and architecture.
Rule Engine guides - learn how to use ThingsBoard Rule Engine.
Use this guide to configure SendGrid or use any other SMTP server available.
Create some folder to store all necessary files for this tutorial. Download to this folder or create the following data files:
Please note that data in this files is basically in key-value format. You can use your own keys and values. See MQTT, CoAP or HTTP protocol reference for more details.
resources/attributes-data.json |
---|
|
resources/telemetry-data.json |
---|
|
Download the following files to previously created folder according to the preferred client:
If you are using a shell script (*.sh) make sure that it is executable:
chmod +x *.sh
Before executing script don’t forget to:
Finally, execute corresponding *.sh or *.bat script to push data to the server.
Below are tabs with the content of the scripts provided.
resources/mqtt-js.sh |
---|
|
resources/mqtt-js.bat |
---|
|
resources/publish.js |
---|
|
resources/mosquitto.sh |
---|
|
resources/coap-js.sh |
---|
|
resources/curl.sh |
---|
|
Installation guides - Learn how to setup ThingsBoard on various available operating systems.
Connect your device - Learn how to connect devices based on your connectivity technology or solution.
Data visualization - These guides contain instructions how to configure complex ThingsBoard dashboards.
Data processing & actions - Learn how to use ThingsBoard Rule Engine.
IoT Data analytics - Learn how to use rule engine to perform basic analytics tasks.
Hardware samples - Learn how to connect various hardware platforms to ThingsBoard.
Advanced features - Learn about advanced ThingsBoard features.
Contribution and Development - Learn about contribution and development in ThingsBoard.
Don’t hesitate to star ThingsBoard on github to help us spread the word. If you have some questions about this sample - post it on the forum.