Creating an IOT or MQTT Dashboard Using Thingsboard

Thingsboard is an open source IOT platform for data visualization.

It is available for download and installation on your own hardware or as an online service for demonstration purposes.

In this tutorial we will configure a simple Dashboard to display data from sensors using MQTT and Python.



There are two sensors, a main door sensor and a main light sensor. Our final demo dashboard will appear like this

thingsboard-dashboard-finished

The first step is to create your own demo account by signing up here.

Once you have an account and have verified it you can login to thingsboard here.

Process Overview

  • Create device or devices
  • Assign device to Widget
  • Assign Widget to Dashboard
  • Add new widgets and edit as necessary

The diagram below illustrates the process:

Thingsboard-Data-ModelDevices

The first thing you need to create is a device.

Go to devices and click on the add device circle in the lower right hand corner

tihngsboard-add-device

You will need to give the device a name and add a description. Leave the is gateway box un-checked.

add-new-device

Click ADD when done.

Now click on the device card to edit the device, and then click the tick icon to display and edit the device properties.

thingsboard-device-edit

Each device is assigned an access token which is used by the device to identify itself to the thingsboard platform.

You will need to copy this access token for use in your MQTT client. You can do this using the copy access token tab.

edit-device-thingsborad

Or by clicking on the manage credentials tab

device-credentials

The access token you will use as the username in MQTT. There is no password.

The actual physical device is responsible for sending data to thingsboard.

All data is sent to the following topic id:

v1/devices/me/telemetry

Note: A device need not be a single device like a sensor as devices publish data as a JSON object.

The device client attributes can be used to manage the device, but these must first be populated by the client. We will not be using device attributes in this tutorial.

The device is now usable and can receive data.

If you follow the introduction on the thingsboard website they use a Javascript client and Node.js to send data.

In this tutorial we will send data using MQTT and a Python client.

Configuring The Python Client

We need to configure the following:

username= access token
password=”” #not used
broker=demo.thngsboard.io
topic=v1/devices/me/telemetry

We also need to package the data in a dictionary object and then convert it to a JSON encoded string to output

Here is my demo script (partial) that simply simulates a light sensor and a door sensor.

python-demo-script-thingsboard

The light is either on or off, and the door is either open or closed.

When I run the script this is what I see on the console.

Running-Demo-Script

To view the results on the device in thingsboard go the device telemetry tab.

thingsboard-telemetry-data

To visualize data from this device we need to configure a dashboard and a display widget.

We start by adding the device to a widget.

To add this device to a widget click on the check box next to last update time

thingsboard-add-device-widget

Now select the widget type (cards) and then use the small circles to select the card type, and then click add to dashboard.

thingsboard-select-widget-type

You can now add the widget to an existing dashboard or create a new dashboard.

thingsboard-add-dashboard

If you tick the checkbox to open the dashboard, when you click ADD the dashboard will open and display the widget.

thingsboard--dashboard

Adding A new Widget to the Dashboard

To add a new widget or edit the dashboard click on the edit (pencil) icon in the lower right corner of the dashboard.

When adding a new widget you first need to select the type of widget.

thingsboard-add-new-widget-select

Now you need to select a data source for the Widget.

thingsboard-add-new-widget-datasourceNow configure the datasource. In the example below our datasource is called house which is the name of the device we configured earlier and we select the main-light property. The Main-door property we added to our first widget.

thingsboard-new-widget-datasource-config

Now you can edit the card settings and change colour and fonts etc.

thingsboard-new-widget-edit

When finished the new widget appears on the screen.

thingsboard-dashboard-finished

As long as the edit icons are showing you can rearrange and edit widgets on the dashboard.

When finished click on the tick icon.

thingsboard-dashboard-edit-icons

Making the Dashboard Public

You can also make the dashboard public which makes it visible to everyone.

thingsboard-dashboard-public

Video

I’ve also created a YouTube video covering the above which you can watch here.

Here is my demo test house dashboard that I created in the video tutorial. You can download the python scripts here.

References:

Related Tutorials:

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MQTT是一种轻量级的通信协议,特别适用于物联网(IoT)应用。它在设计上非常简洁、灵活,并具有以下几个优点: 1. 低带宽消耗:MQTT协议使用发布/订阅模式,只有在数据发送时才会进行网络通信,因此能够有效减少带宽的消耗。 2. 低功耗:由于MQTT协议采用了低功耗的设计原则,设备在空闲时可以进入休眠状态,以降低能耗。 3. 可靠性:MQTT协议使用QoS级别来确保消息的可靠传递,支持三种级别:QoS 0表示最多一次的传输,QoS 1表示至少一次的传输,QoS 2表示仅一次的传输。 4. 灵活性:MQTT协议支持动态的主题订阅和发布,可以根据应用需求自由定制数据传输的方式。 5. 易于实现:MQTT协议的实现相对简单,可以在各种平台上进行快速部署和开发。 在物联网实践中,使用MQTT协议可以有效地传输传感器数据、设备状态等信息。例如,通过使用STM32F103和ES8266,可以基于HAL库进行简单的物理模型数据上传到阿里云IoT平台。这样的实践方案可以通过在main.c中定义和修改相关参数来实现。同时,阿里云IoT还提供了MQTT3和MQTT5协议的一些关键设计和思考,包括连接复用、状态一致性、扩展增值能力设计等,以提高系统的稳定性与可扩展性。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [解密阿里云IoT物联网平台MQTT Access Server核心架构](https://blog.csdn.net/klandor2008/article/details/119307245)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [STM32F103 ES8266上阿里云IOT MQTT实践 基于HAL库](https://download.csdn.net/download/Rainhon/13202691)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值