Abstract: This article is about the use of small bear development board simulation vending machine, based on the engineering code provided by the forum, through cloud development and equipment terminal development, terminal data display in Huawei cloud platform.

This paper describes the simulation of vending machine with the Bear Development board, based on the engineering code provided by the forum, through cloud development and equipment terminal development, terminal data display in Huawei cloud platform. Through practical operation and learning, I have improved Huawei cloud application ability and iot related skills. This paper also applies to IoT development full stack growth plan, the third stage of learning exchange. Thank you for your criticism!

The experiment resources

Cloud platform: Huawei cloud Iot device access service

Communication protocol: MQTT

Communication mode: WiFi

Development environment: VSCode

Project code: Huawei_LiteOS_Lab_AIoT download links: bbs.huaweicloud.com/blogs/17461…

The model file: AIoT123_Model download links: bbs.huaweicloud.com/blogs/17461…

Simulation equipment: Little Bear Development Board (STM32)

The experimental steps

I. Cloud development

Prerequisites: Register with huawei cloud and pass real-name authentication

  • Create a product

Huawei Cloud Tail Iot devices connected to IoTDA

Product tail created products, as shown below:

As shown below:

Owning space: Select a resource at random

Product Name (custom) : AIOT

Protocol type: MQTT

Data format: JSON

Vendor Name (custom) : 123

Device Type (custom) : 123

  • Add a model

Open the product tail upload model file you just created. As shown below:

Step 3 Click ok to download aiOT123_model.zip

Click confirm to display successful uploads. As shown below:

  • Increase the equipment

Click on Devices animator to register devices

As shown below:

Owning Resource space: This parameter is consistent with the product selection.

Product (just created) : AIOT.

Device Identifier (custom) : 456789123.

Device name (custom) : AIOT_123.

Device authentication type: key.

Key (custom), do not forget to set the password, to use later.

After clicking OK, the device is created successfully, as shown in the following figure. Grab a notepad and save the device ID and password for later use.

2. Terminal development

About development tool VSCode and IoTLink plugin to download and install, please refer to the bbs.huaweicloud.com/forum/threa…

  • Import the project

Download the Huawei_LiteOS_Lab_AIoT project file (see the beginning of this article for the download link) and decompress it. Open the VSCode import project, as shown below:

As shown below:

Project directory: D:iotHuawei_LiteOS_Lab_AIoTtargetsSTM32L431_BearPi

Makefile: D:iotHuawei_LiteOS_Lab_AIoTtargetsSTM32L431_BearPiGCC, select the makefile file

Hardware platform: STM32L431

Click ok

  • The configuration of engineering

Modify the demosoc_MQTT_demooc_MQTT_vending_machine. c file, replace XXXXXX 98 and 99 respectively with device ID and password of cloud platform (previously saved in notepad).

As shown below:

Change the wifi account and password, and find a nearby wifi account and password that can access the Internet frequently. There are two things that need to be modified. The first one is the. Config file. The second is the iot_config.h file. As shown below:

  • Compile the project

After modifying the file, save it. Click Build, as shown below:

  • Download to the development board

Connect the little Bear development board, switch the AT switch to MCU, and click Download. As shown below:

As shown in the following figure: After downloading successfully, the product name will be displayed on the screen. Operation F1 (Select) and F2(CONFIRM) buttons, randomly select a commodity, and then select Submit, F2 order.

Cloud platform to receive display data

Huawei Cloud tail Equipment connected to IoTDA tail Equipment can be seen to have data coming up, as shown in the picture below:

Open the device shadow to view the detailed data, as shown below:

This article is shared from Huawei cloud community “Hand in hand to teach you _ Based on bear PI STM32 development board simulation vending machine _ Connect Huawei cloud IOT Platform”, original author: MJJ13.

Click to follow, the first time to learn about Huawei cloud fresh technology ~