Week 7 Lab Tutorial Using ThingsBoard
Week 7 Lab Tutorial Using ThingsBoard
Apparatus
1. ThingsBoard
https://www.thingsboard.io/
2. Google Colab
https://colab.research.google.com/
1.1 ThingsBoard
A. What is ThingsBoard?
Procedures
In this part, you are expected to read information about ThingsBoard.
1. What is ThingsBoard?
https://thingsboard.io/docs/getting-started-guides/what-is-thingsboard/
2. Use Cases.
a. https://thingsboard.io/smart-energy/
b. https://thingsboard.io/smart-farming/
c. https://thingsboard.io/fleet-tracking/
d. https://thingsboard.io/smart-metering/
e. https://thingsboard.io/use-cases/environment-monitoring/
f. https://thingsboard.io/use-cases/smart-office/
g. https://thingsboard.io/use-cases/water-metering/
This is my “access token” for my device. Your “access token” must be different from mine.
eYo1rV9jKU2N4BB7W5XJ
Now you are ready to publish telemetry data on behalf of your device. We will use simple
commands to publish data over HTTP or MQTT in this example.
Once you have successfully published the “temperature” readings, you should immediately see
them in the Device Telemetry Tab:
● Click on the device row in the table to open device details
● Navigate to the telemetry tab.
Congratulations! You have added the first widget. Now you can send new telemetry reading and
it will immediately appear in the table.
Step 3.4 Add Chart Widget
To add the chart widget we need to select it from the widget library. Chart widget displays
multiple historical values of the same data key (“temperature” in our case). We should also
configure the time window to use the chart widget.
● Enter Edit mode.
● Click the "Add new widget" icon in the bottom right corner of the screen.
● Click the "Create new widget" icon.
● Select the "Charts" bundle. Scroll down and click on the "Timeseries - Flot" chart widget.
● Click the "Add Datasource" button.
● Select "MyDevice" Alias. Select the "temperature" key. Click "Add".
● Drag and Drop your widget to the desired space. Resize the widget. Apply changes.
● Publish different telemetry values multiple times Step 2. Note that the widget displays
only one minute of data by default.
● Enter Edit mode. Open time selection window. Change the interval and aggregation
function. Update the time window and apply changes.
Congratulations! You have added an alarm widget. Now it’s time to configure alarm rules and
raise some alarms.
Step 4. Configure Alarm Rules
We will use the alarm rules feature to raise alarm when the temperature reading is greater than
25 degrees. For this purpose, we should edit the device profile and add a new alarm rule. The
“My New Device” is using the “Default” device profile. We recommend creating dedicated device
profiles for each corresponding device type but will skip this step for simplicity.
● Navigate to the device profiles page.
● Click the default profile row. This will open device profile details.
● Select the "Alarm Rules" tab and toggle edit mode.
● Click "Add alarm rule".
● Specify alarm type and click the "+" icon to add alarm rule condition.
High Temperature
● Click the "Add key filter" button to specify a condition.
● Select key type, input key name, select value type, and click "Add".
Timeseries, temperature, 123 Numeric
● Select operation and input threshold value. Click "Add".
Greater than 25
● Click "Save".
● Finally, click "Apply changes".
print (time.ctime())
time.sleep(10)
!curl -v -X POST -d "{\"temperature\": 22}"
https://demo.thingsboard.io/api/v1/eYo1rV9jKU2N4BB7W5XJ/telemetry --header
"Content-Type:application/json" &> /dev/null
print (time.ctime())
time.sleep(10)
!curl -v -X POST -d "{\"temperature\": 23}"
https://demo.thingsboard.io/api/v1/eYo1rV9jKU2N4BB7W5XJ/telemetry --header
"Content-Type:application/json" &> /dev/null
print (time.ctime())
time.sleep(10)
!curl -v -X POST -d "{\"temperature\": 24}"
https://demo.thingsboard.io/api/v1/eYo1rV9jKU2N4BB7W5XJ/telemetry --header
"Content-Type:application/json" &> /dev/null
print (time.ctime())
time.sleep(10)
!curl -v -X POST -d "{\"temperature\": 25}"
https://demo.thingsboard.io/api/v1/eYo1rV9jKU2N4BB7W5XJ/telemetry --header
"Content-Type:application/json" &> /dev/null
print (time.ctime())
time.sleep(10)
!curl -v -X POST -d "{\"temperature\": 26}"
https://demo.thingsboard.io/api/v1/eYo1rV9jKU2N4BB7W5XJ/telemetry --header
"Content-Type:application/json" &> /dev/null
print (time.ctime())
time.sleep(10)
!curl -v -X POST -d "{\"temperature\": 30}"
https://demo.thingsboard.io/api/v1/gwT6obBhTkoDKx8gbnpz/telemetry --header
"Content-Type:application/json" &> /dev/null
Reference
1. https://thingsboard.io/docs/getting-started-guides/what-is-thingsboard/
2. https://thingsboard.io/docs/getting-started-guides/helloworld/
3. https://thingsboard.io/docs/user-guide/dashboards/
4. https://thingsboard.io/docs/user-guide/rule-engine-2-0/re-getting-started/
5. https://thingsboard.io/docs/reference/http-api/
THE END