by Jonah Wang, Solution Architect Alibaba Cloud Indonesia
An IoT Platform is an application or service that provides built-in tools and capabilities to connect and manage a wide variety of devices and sensors over the Internet, allowing them to communicate, collect data, and interact with each other on a centralized system.
In general, an IoT Platform should be able to support Data Hub, Edge Computing, Network Management, Device Identification, and Device Security.
In an IoT system, the IoT Platform plays a very important role in terms of development, management, scalability, and security. In a cloud computing environment (like Alibaba Cloud), the IoT Platform can greatly enhance the capabilities and efficiency of the IoT systems, together with the cost-effective, flexible, and O&M-free cloud-native infrastructure and services. The architecture diagram below demonstrates a typical example of how to integrate an IoT Platform with IoT edge devices and backend systems on Alibaba Cloud.
This article explains how to set up an IoT Platform on Alibaba Cloud.
ThingsBoard is an open-source IoT platform for data collection, processing, visualization, and device management. It provides an out-of-the-box IoT solution that will enable a server-side infrastructure for your IoT applications.
It enables device connectivity via industry-standard IoT protocols (MQTT, CoAP, and HTTP) and supports cloud and on-premises deployments with scalability, fault-tolerance, and performance.
ThingsBoard is licensed under the Apache 2.0 License. It is free for personal and commercial use.
Before we set up ThingsBoard, we will prepare the database for ThingsBoard. ThingsBoard database can be set up on the Alibaba Cloud RDS PostgreSQL database. Refer to the link below for instructions to create a database instance using RDS PostgreSQL:
After successfully creating the RDS instance, we will create the database in the RDS instance using the default name “thingsboard”, and then create a privileged account (ensure the user account has enough access to the database to load “thingsboard” schema and tables inside). Refer to the link below for instructions to create a database and user account in RDS instance.
ThingsBoard may be deployed on ECS servers or a K8s cluster on Alibaba Cloud. This example will provision an ECS instance on Alibaba Cloud for ThingsBoard server installation. The OS of the ECS instance can be Ubuntu 18.04 LTS / Ubuntu 20.04 LTS / Ubuntu 22.04 LTS.
1) Install Java 11 (OpenJDK)
sudo apt update sudo apt install openjdk-11-jdk
2) ThingsBoard Service Installation
wget https://github.com/thingsboard/thingsboard/releases/download/v3.4.1/thingsboard-3.4.1.deb sudo dpkg -i thingsboard-3.4.1.deb
3) ThingsBoard database configuration
At the ThingsBoard server, edit the configuration file “/etc/thingsboard/conf/thingsboard.conf” to add the configurations below, and the [database_address], [database_username], [database_password] are based on the database instance created in the previous section.
# DB Configuration export DATABASE_TS_TYPE=sql export SPRING_DATASOURCE_URL=jdbc:postgresql://<database_address>:5432/thingsboard export SPRING_DATASOURCE_USERNAME=<database_username> export SPRING_DATASOURCE_PASSWORD=<database_password> # Specify partitioning size for timestamp key-value storage. Allowed values: DAYS, MONTHS, YEARS, INDEFINITE. export SQL_POSTGRES_TS_KV_PARTITIONING=MONTHS
4) Load Base Data
Run the command below to load the base data.
sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
5) Start Service
Start the ThingsBoard service using the command below to load the ThingsBoard console this link:
This is the default login of the ThingsBoard console:
System Administrator: email@example.com / sysadmin
Tenant Administrator: firstname.lastname@example.org / tenant
Customer User: email@example.com / customer
sudo service thingsboard start
Log in to the ThingsBoard console as the tenant admin to start configuring the device for data collection.
1) Add the Device and Device Credentials in the module Menu -> Devices. The device is the endpoint to collect data from IoT devices.
2) Add Assets in the module Menu -> Assets. Asset stores the processed data from the device.
3) Link the device to the asset. After the pair of device and asset have been created, go to the device portal and click on the device to link with the corresponding asset. On the Device Details page, click the Relations tag and change Direction to To, which means the data sent to the device will be processed and forwarded to the asset. Click the + button to add the relation to the asset.
4) Rule Engine. Go to Menu -> Rule chains to configure the rule engine for the IoT platform. In the existing Root Rule Chain, add additional steps after the Save Timeseries. Save Timeseries is the step when the device data is saved to the database. We will add the post sub-flow:
Validation: A Filter / script to validate the content of the message received from the device and a return True if the message content fulfills the IoT data we expected
Extract: A Transformation / script to extract the data from the validated raw message
Change to Asset: A Transformation / change originator to forward the processed message to the asset linked to the device
Save: An Action / save timeseries to save the processed message to the asset to the database
Log: An Action / log to write the message to the log file in each step for debugging
The data forwarding process in the IoT Platform converts and transfers data to other external services for more complicated data integration and data analytics subprocesses.
ThingsBoard allows the received message to be forwarded to an external storage or message queue for external processing through the configuration of Rule Chain.
We take RabbitMQ as an example of data forwarding. Edit the Rule Chain and add the node (External -> rabbitmq):
Provide the RabbitMQ instance publishing information inside:
Once configured, the received message will be forwarded to the RabbitMQ and consumed by the consumer client application for further processing.
After the data is collected and processed into the database of the IoT Platform, we can use Alibaba Cloud Quick BI to visualize and analyze the data.
1) Data Source
Please refer to this blog for details on how to connect to the RDS database.
2) Data Set
In order to ensure the security control and data protection of the ThingsBoard IoT Platform, all network ports of the system shall be closed, except:
|22||DevOps PC||TCP||For setup and DevOps|
|1883||Device network||TCP||MQTT data collection from IoT devices|
|5683||Device network||UDP||CoAP data collection from IoT devices|
Alibaba Cloud provides a cloud-native IoT Platform with built-in high availability and O&M capabilities at minimal costs. Alibaba Cloud IoT Platform supports hundreds of millions of device connections and millions of concurrent messages and can help defend against DDoS attacks whose peak traffic reaches 600 Gbit/s at the access layer and provides an SLA of more than 99.95%.
After activating the IoT Platform on Alibaba Cloud, users can manage IoT device connectivity and data integration through the Alibaba Cloud console without worrying about server installation and database setup.
The procedure of connecting a device with the IoT Platform consists of three components: product, device, and topic.
On the IoT Platform, a product should be defined and created first. A product on the IoT Platform represents a hardware product model, which may consist of multiple devices of the same type.
In the product, topic categories are defined to indicate a set of topics for different devices in the same product. Devices can send and receive messages using topics to communicate with the IoT Platform.
The relationship between product, device, and topic is shown in the diagram below:
The data forwarding feature of the IoT Platform is a rule-engine allowing IoT developers to collect, compute, and store data efficiently. The targets of the data forwarding rules include a list of cloud-native services on Alibaba Cloud (such as RocketMQ, RDS, and Function Compute), which allows developers to develop end-to-end IoT data integration solutions easily based on the design of business applications without additional server management and DevOps work.
Deploying Internet of Things (IoT) solutions to collect and manage data from devices for new business models is a growing trend recognized by enterprises. Alibaba Cloud provides various solutions to help customers build a powerful IoT system with security, high availability, cost-effectiveness, and ease-of-use.
Alibaba Clouder - April 16, 2021
Alibaba Clouder - August 6, 2019
GXIC - November 2, 2018
Alibaba Cloud Indonesia - September 27, 2023
Alibaba Clouder - January 11, 2019
GXIC - February 25, 2019
A cloud solution for smart technology providers to quickly build stable, cost-efficient, and reliable ubiquitous platformsLearn More
An on-demand database hosting service for PostgreSQL with automated monitoring, backup and disaster recovery capabilitiesLearn More
Provides secure and reliable communication between devices and the IoT Platform which allows you to manage a large number of devices on a single IoT Platform.Learn More
More Posts by Alibaba Cloud Indonesia