This topic describes how to integrate IoT Platform with the Alibaba Cloud big data platform. This way, you can use the Alibaba Cloud big data platform to compute and analyze device data, collect the statistics of devices, and display device data, statistics, and analysis results in real time.

Prerequisites

  • The related Alibaba Cloud services are activated and the required instances and computing resources are purchased. When you use the Alibaba Cloud big data platform to process the device data of IoT Platform, you may need to use multiple Alibaba Cloud services, such as ApsaraDB RDS for MySQL and IoT Platform.
  • You are familiar with the configuration procedure and usage notes for the Alibaba Cloud services.

Background information

  • Scenario: Use a DataV dashboard to display the data of the devices of an IoT Platform product in real time.
  • Process:
    1. IoT Platform collects device data.
    2. IoT Platform forwards device data of a product to DataHub by using the rules engine.
    3. DataHub sends the device data to Realtime Compute for Apache Flink for processing and writes the processed data to ApsaraDB RDS for MySQL. If the device data does not need to be processed, you can synchronize the data from DataHub to ApsaraDB RDS for MySQL by using DataConnector.
    4. DataV uses an ApsaraDB RDS for MySQL database table as a data source and displays device data in the database table in real time.

Procedure

  1. Create an ApsaraDB RDS for MySQL database to store device data.
    For more information, see ApsaraDB RDS for MySQL.
    1. Log on to the ApsaraDB RDS console.
    2. On the Instances page, click Create Instance to purchase an ApsaraDB RDS for MySQL instance.
      Note The region where the ApsaraDB RDS for MySQL instance resides must be the same as the region where your IoT Platform devices and DataHub project reside.
    3. On the Instances page, find the purchased instance and click Manage in the Actions column.
    4. In the left-side navigation pane, click Accounts. On the Accounts page, click Create Account and configure the parameters.
    5. In the left-side navigation pane, click Databases. On the Databases page, click Create Database and configure the parameters.
    6. In the left-side navigation pane, click Data Security. On the Data Security page, click Create Whitelist to configure an IP address whitelist for the ApsaraDB RDS for MySQL instance. For more information, see Configure an IP address whitelist for an ApsaraDB RDS for MySQL instance.
    7. In the left-side navigation pane, click Basic Information to view the basic information about the instance.

      If you want to synchronize data to DataHub, DataV, or Realtime Compute for Apache Flink, the instance information is required.

    8. In the top navigation bar of the Basic Information page, click Log On to Database. In the Login instance dialog box, enter the information about an account to log on to the database.
    9. Tables are created in the databases. In this example, a database table named mytable is created. The database table contains two fields. The following table describes the fields.
      Table 1. mytable
      Field Type Description
      d_data varchar(32) The time.
      device_num int The number of active devices.
  2. In the IoT Platform console, create a product, a device, and a data forwarding rule.
    1. Log on to the IoT Platform console.
    2. On the Overview page, find the instance and click the instance name to go to the Instance Details page.
      Notice Enterprise Edition instances are available only in the China (shanghai) and Japan (Tokyo) region. If your IoT Platform is not activated in the China (shanghai) or Japan (Tokyo) region, skip this step.
      Overview
    3. In the left-side navigation pane, choose Devices > Products. On the Products page, click Create Product and configure the parameters. For more information, see Create a product.
    4. After you create the product, you can go to the Product Details page of the product and configure the product based on your business requirements. For example, you can create a topic category or define a Thing Specification Language (TSL) model. For more information, see What is a topic? or What is a TSL model?
    5. In the left-side navigation pane, choose Devices > Devices. On the Devices page, click Add Device and configure the parameters. For more information, see Create a device.
    6. In the left-side navigation pane, choose Rules > Data Forwarding. On the Data Forwarding page, click Create Rule and configure the parameters.
    7. On the Data Forwarding page, find the rule and click View in the Actions column.
    8. In the Data Processing section of the Data Forwarding Rule page, click Write SQL. In the Write SQL dialog box, write SQL statements for the rule. Then, debug the SQL statements. For more information, see SQL statements.
      Write an SQL statement
    9. In the Data Forwarding section, click Add Operation. In the Add Operation dialog box, configure the parameters. The operation is used to forward device data to a topic in DataHub. For more information, see Configure a data forwarding rule.
    10. After the configuration is complete, go to the Data Forwarding page. Find the rule and click Start in the Actions column to enable the rule.
    After you enable the rule, use a simulated device to send a message and check whether the message can be forwarded to DataHub. On the Device Log page, you can view the logs of the simulated device. On the DataHub console, you can view the changes in the data size of the shards of the topic to which device data is forwarded. You can also use the data sampling feature to view the message content in the shards.
  3. Configure a device and connect the device to IoT Platform.
    This example shows how to use Link SDK for Java to configure the device. Click Demo SDK for Java to download the sample code.

    After you develop the device SDK, install the device SDK on the physical device. After you power on the device and connect the device to IoT Platform, the device can report data to IoT Platform. IoT Platform forwards the data to DataHub by using the rules engine. After Realtime Compute for Apache Flink processes the data, the processed data is written to ApsaraDB RDS for MySQL.

  4. Perform a test. After the configuration is complete, the number of active devices is updated in real time on the dashboard each time a device connects to IoT Platform and sends messages.