pdf-icon

UIFlow - Connecting to Alibaba Cloud

Overview

This tutorial will explain how to program with the UIFlow platform to connect devices to the Alibaba Cloud platform for subscribing and publishing data.

Create a Product

Before connecting, you need to log in to the Alibaba Cloud Console . From the console homepage, navigate through Products & Services -> IoT Platform -> Public Instance

Click on Device Management -> Products -> Create Product, configure the product name and type, as well as the networking method. (The networking method used in this function on the UIFlow platform is "WIFI"). Click confirm to complete creation.

Create a Device

Once the product is created, the next step is to add actual devices under that product category. Click the device development option on the product page and click Add/Register Device

Enter the device name (this name will be used for configuration in subsequent UIFlow programming) and complete the creation.

After the device is created, it can be found in the device list. There are several key pieces of information to note: ProductKey, DeviceSecret, DeviceName, which will be used in subsequent programming.

Firmware Flashing

Flash your device with UIFlow firmware (requires version v1.8.0 and above). Click the link below for detailed flashing steps.

UIFlow Firmware Flashing Steps

Write the Program

Add the Aliyun connection initialization block to the UIFlow workspace, fill in the ProductKey, DeviceSecret, DeviceName created in the steps above. Note: region id should be selected according to the service instance's location, which will be displayed in the Alibaba Cloud Console.

Subscribe and Publish Messages

UIFlow currently provides three types of topic subscriptions for uplink and downlink: user, raw, shadow update. Different topic subscriptions will have different roles and display methods in the Alibaba Cloud console, for example, user can be used for general data interaction, shadow update is mainly used for device status synchronization, raw type topic data allows users to configure custom scripts in the Alibaba Cloud Console to process the data. For more details, please see the Alibaba Cloud IoT documentation page . This tutorial only demonstrates basic log viewing and data uplink and downlink operations.

Add corresponding callbacks for the above three types of topic subscriptions in UIFlow and add display programs for them. Add topic publishing programs in the main loop and insert the temperature and humidity values into them. Click the run button in the upper right corner of the UIFlow page to execute the program.

<img src=" https://static-cdn.m5stack.com/resource/docs

/static/image/iotcloud/aliyun/aliyun_example.webp" width="100%">

View Logs

Click Monitoring & Maintenance -> Log Service. If the device communication is normal, logs will continuously output information. Click to view the data to get the temperature, humidity, and pressure values at a certain moment.

Publish Information

Enter the device details page, click Topic List -> Publish Information (user)

Update Device Shadow

Enter the device details page, click Device Shadow -> Update Shadow

RAW Data Processing

Enter the product details page of the device, click Data Parsing, and edit custom scripts to process input and output data.

On This Page