Connect STM32/Linux to complete the design. qq:1948235981
Code:
https://download.csdn.net/download/cainiaofu/13973012
Alibaba Cloud lot Studio controls web development (the program has been simplified)
Share the process of using stm32f103c8t6 to connect the Alibaba Cloud IoT platform through the ESP_01 module to realize the process of uploading temperature and humidity and issuing control commands. The ability is limited, and the simplest method is used. If there is any error, please bear with me.
1. Achievement display (three-way data upload and two-way switch control)
2. Hardware selection
1. stm32f103c8t6
2. ESP_01 wifi module
3. Others
3. Hardware connection
WSP_01 | STM32F103C8T6 |
---|---|
RXD | PA2 |
TXD | PA3 |
RES | PA4 |
VCC | 3.3 |
GDN | GND |
The connection diagram is as follows:
4. Connection steps
1. Log in to the IoT platform and select: Device Management--Products--Create Product
2. Create a new product
Product name: write it casually
Category: smart life / home security / temperature and humidity acquisition unit
Other defaults can be
3. Set the function of the product
Function Definition - "Edit Draft"
Click: Add Custom Function - "Properties
Function Name (1): Current Temperature
Identifier: Write Anywhere Note: The identifier in this place can be written casually, but in the program, the
data must correspond to this identifier Type: int 32 Note: This data type determines the precision of the displayed data. In order to improve the precision, it can be set to float.
Range of values: 0-100
Step: 1
Unit: Celsius
Use a similar method to define another function—current Humidity
Define a function of command issuance (here, control the switch light as an example)
4. Under the newly created product, add a device
Device name: write whatever
you want. Note: it must be under the corresponding product
5. Copy the device certificate (important) - one of the 2 places that need to be modified
At this point, the product and equipment have been established. The status of the device is "Inactive".
6. Activate the device
Modify the program and activate it by burning the program to c8t6
Program change 1: mqtt.h (that is, add the device certificate just copied to the corresponding location)
#define PRODUCTKEY "a1kpb6iULSE" //产品ID
#define PRODUCTKEY_LEN strlen(PRODUCTKEY) //产品ID长度
#define DEVICENAME "A001" //设备名
#define DEVICENAME_LEN strlen(DEVICENAME) //设备名长度
#define DEVICESECRE "9gyc2OcDRamSN17bOdJrdWpmSgv8KqsN" //设备秘钥
#define DEVICESECRE_LEN strlen(DEVICESECRE)
#define S_TOPIC_NAME "/sys/a1kpb6iULSE/A001/thing/service/property/set" //需要订阅的主题
#define P_TOPIC_NAME "/sys/a1kpb6iULSE/A001/thing/event/property/post"
Program change 2: wifi.h (change to your own wifi name and password)
#define SSID "337" //路由器SSID名称
#define PASS "1234567890" //路由器密码
After the program is programmed, c8t6 controls the ESP_01 wifi module to connect to the server through AT commands.
At this point, the device displays online.
7. Create a web interface
8. Create a new blank project
Project name: write whatever you want
9. Associated products and equipment
At this point, the Wed application we created is associated with the products and devices we just created.
10. Design a visual interface (used to display data and issue instructions)
11. Interface design
Use the same method to design the other two interfaces.
V. Conclusion
The code is rough and will not be disclosed. Leave your email in the comment area and I will reply in time