This tutorial will take the building of temperature and humidity collection nodes as an example to demonstrate how to access the Tencent Cloud platform through the UIFlow programming device.
Before accessing, register and log in to
Tencent Cloud-IoT Development Platform
to fill in the project Name/Description->
The product can be understood as a collection of a certain type of equipment, and the user manages all the equipment under it through the product.
Click the item created in the previous step->
Enter the product development center->
Define your product->
Fill in the basic product information->
The basic product information settings are shown in the figure, where the name can be customized, and other suggestions are consistent.
The data template constructs its digital model by digitally describing the physical entity equipment. Defining data templates on the IoT development platform means defining product functions. After the function definition is completed, the system will automatically generate the data template of the product. Since we choose a custom product, there is no standard function. We need to define the function ourselves.
Click on the created product->
As shown in the figure below, define the temperature and humidity functions separately. In actual application, you can also add more function definitions according to your needs
Complete the function definition, click the above steps
Click New Device->
Fill in the device name->
Save. Click on the successfully created device to view the details page. (It will contain the key and device-related information needed for UIFlow connection)
Burn UIFlow firmware for your device (firmware requires v1.7.3 and above), click the corresponding document link below to view the detailed programming steps.
- Click to download the case program m5f file , open the file in UiFlow, or follow Drag and drop the code block in the figure below.
product id: Product ID, which can be viewed on the device information interface device name: device name, same as above device sceret: device secret key, same as above keepalive: heartbeat time 0 ~ 120 (seconds)
from IoTcloud.Tencent import Tencent //Initialize connection tencent = Tencent( product_id='XXXXXXXXXXX', device_name='XXXXXXX', username='XXXXXXXXXXXXXXXXXX;12010126;B335D;1702277766', password='e822dc0027a1b363f9ed1a23fb77860c0b707d7d;hmacsha1', port=1883, keepalive=30 ) //upload data tencent.publish_property_msg(temperature=temp,humidity=humid) //Downstream data callback def tencent_fun(property_data): print(property_data) //Subscribe to the platform to send messages tencent.subscribe_property_msg(tencent_fun)
The code block below is used to push data to the cloud platform, and the data is sent in the form of
key-value, where the
key value needs to be consistent with the
identifier in the custom function. When the device is running, the user can view the upstream data of the device in the device log.
Tencent Cloud Service is integrated and docked with the small program
Tencent Lianlian, and users can easily view the reported data of the device through the small program.
Device QR Code. (Open the WeChat applet
Tencent Lianlian, click on the
+ number to scan the code to bind the device).