Hcia-Iot Huawei Certified ICT Associate-Internet of Things Lab Guide
Hcia-Iot Huawei Certified ICT Associate-Internet of Things Lab Guide
HCIA-IoT
Lab Guide
ISSUE: 2.5
and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.
All other trademarks and trade names mentioned in this document are the property of
their respective holders.
Notice
The purchased products, services and features are stipulated by the contract made
between Huawei and the customer. All or part of the products, services and features
described in this document may not be within the purchase scope or the usage scope.
Unless otherwise specified in the contract, all statements, information, and
recommendations in this document are provided "AS IS" without warranties,
guarantees or representations of any kind, either express or implied.
The information in this document is subject to change without notice. Every effort has
been made in the preparation of this document to ensure accuracy of the contents, but
all statements, information, and recommendations in this document do not constitute
a warranty of any kind, express or implied.
Overview
This document is intended for candidates who are preparing for the HCIA-IoT exam or
anyone who wants to understand Huawei's full-stack IoT solution.
Description
This document consists of three parts: a basic Huawei LiteOS exercise, a case exercise of
reporting data to MQTT Broker, and a comprehensive exercise.
Exercise 1 is a device service exercise based on Huawei LiteOS. It helps you
understand the IoT operating system.
Exercise 2 is a device-cloud synergy exercise based on Wi-Fi for a smart agriculture
case. It helps you master smart agriculture development.
The comprehensive exercise aims to implement device-cloud synergy based on smart
smoke detectors, smart logistics, and smart street lamps. It helps you master LiteOS-
based device-cloud synergy development.
Network Check
Before the exercise, each group of candidates should check whether the Wi-Fi network
are stable and support 2.4GHz bands, it should be logged in using Wi-Fi name and
password. If the Wi-Fi network in your environment is unstable or it is not connected
using Wi-Fi name and password, mobile phone hotspot is recommanded.
Huawei IoT Certification Training Lab Guide Page 5
1.1 Introduction
1.1.1 About This Exercise
In the exercise, you will use LiteOS Studio to develop IoT devices and use LiteOS to
control the IoT development board.
1.1.2 Objectives
Master how to use LiteOS Studio.
Master how to execute LiteOS tasks.
Become familiar with the LCD.
Become familiar with the LED and buttons of the development board.
1.2 Tasks
1.2.1 Opening a LiteOS Project
Step 1 Decompress the downloaded project.
Decompress the LiteOS_Lab_HCIA.rar file to the root directory of any disk. Ensure that
the path does not contain Chinese characters or spaces.
Choose File > Open Folder in the upper left corner and select the LiteOS_Lab_HCIA
folder.
Choose Compiler, click on the right of Makefile Script, and click Confirm.
Huawei IoT Certification Training Lab Guide Page 9
Click on the toolbar and wait for the compilation to complete. A message is
displayed indicating that the Huawei_LiteOS.bin file is built.
Huawei IoT Certification Training Lab Guide Page 11
osal_task_create("task2",task2,NULL,0x400,NULL,2);
Step 3 Compile and burn the program and view the result.
Compile and burn the program, open the serial port terminal, and check the printed
information.
Hello World! This is BearPi! and This is Task2! are printed alternately.
Huawei IoT Certification Training Lab Guide Page 14
#include "lcd.h"
LCD_Clear(BLACK);
POINT_COLOR = GREEN;
LCD_ShowString(10, 10, 200, 16, 24, "Welcome to LiteOS");
Huawei IoT Certification Training Lab Guide Page 15
Step 4 Compile and burn the program and view the result.
Compile and burn the program, and check whether the LCD displays Welcome to
LiteOS.
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
while (1)
{
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET);
osal_task_sleep(1*1000);
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,GPIO_PIN_RESET);
osal_task_sleep(1*1000);
}
}
osal_task_create("led_task",led_task,NULL,0x400,NULL,2);
Huawei IoT Certification Training Lab Guide Page 17
Step 3 Compile and burn the program and view the result.
Compile and burn the program. The onboard LED blinks.
if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_2)==GPIO_PIN_RESET)//Query
keyKEY1Low level
{
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET);
}else
if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_3)==GPIO_PIN_RESET)//Query
keyKEY2Low level
{
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET);
}
Huawei IoT Certification Training Lab Guide Page 18
Step 3 Compile and burn the program and view the result.
Compile and burn the program. Press the F1 button in the lower right corner of the
development board to turn on the LED, and press the F2 button to turn it off.
1.3 Exercise
1.3.1 Changing the Task Priority to Print "This is Task2!" Prior to
"Hello World! This is BearPi!"
1.3.2 Creating a Multi-Line LCD Display
Huawei IoT Certification Training Lab Guide Page 19
2.1 Introduction
2.1.1 About This Exercise
In the exercise, you will use Wi-Fi to implement a smart agriculture case, which involves
collecting real-time data, responding to command delivery, and implementing device-
cloud synergy.
2.1.2 Objectives
Master how to configure the Wi-Fi communication mode.
Master how to develop smart agriculture cases.
2.2 Tasks
2.2.1 Configuring a Smart Agriculture Case
Step 1 Install the smart agriculture expansion board E53_IA1.
Insert the expansion board E53_IA1 into the BearPi development board.
Type in ipconfig to query the IP address. The IP address of the Broker is the IP address of
the PC. Ensure that the PC and the development board are in the same LAN.
Enable the Wi-Fi hotspot on the mobile phone and click to recompile the program.
Burn the program and check whether the device is online in EMQ Broker.
NOTE: Please ensure your computer and BearPi board are connected with the same Wi-Fi
network, or the experiment cannot be succeed.
Step 2 Run the Java program to deliver the command for turning on the LED.
Choose HCIA-IoTEN > src > app > Application.java.
Uncomment the command for turning on the LED and run the program again.
2.3 Exercise
2.3.1 Delivering All Light and Motor Commands
Huawei IoT Certification Training Lab Guide Page 25
3 Comprehensive Exercise
3.1 Introduction
3.1.1 About This Exercise
In the exercise, you will implement data reporting and command delivery based on
device-cloud synergy in the previous exercises.
3.1.2 Objectives
Master how to use the IoT platform and Huawei LiteOS to implement device-cloud
synergy in different cases.
3.2 Tasks
3.2.1 Wi-Fi-based Smart Smoke Detector Exercise
Step 1 Change the cases in .config and iot_config.h to oc_smoke_template.
Step 2 Modify the code in oc_smoke_template to use the MQTT protocol to report data
and process command responses.
4 Technical Consultation
Question 2: What if my BearPi board cannot be detected by the serial port terminal?
Answer 2: At first, you need to check if you have installed the ST-Link Driver. If not, you
need to install it first, then you can find the BearPi board at the Device Manager in your
computer. After the installing, if you find your computer still can not identify the board.
Please check Question 3 in detail.
Question 3: Why my computer cannot burn the file into the BearPi Board and shows ‘No
ST-LINK detected’ in the console?
Answer 3: If you have already installed the Driver and your computer can identify the
board, you can use the external serial port terminal ‘STM32 ST-LINK Utility’ to do the
experiment.
If your computer still connot identify the board but it can be detect as a drive in the
computer, you can find the ‘XXXXX.bin’ file in the folder after compiling, and put it to the
drive directly. In this way, ‘XXXXX.bin’ file can also burn into the board and the USB portal
only act as a power supply.
Question 4: The BearPi board’s screen shows “SD does not exist!”, will it influence the
experiment results?
Answer 4: SD card is not related ti the experiment, but the BearPi board will detect it.
And it will not influence the experiment.
Question 5: Why the receiving area in serial port terminal do not show me any message?
Answer 5: For this question, it has a lot of reasons. They are as follows:
(1) Please check your BearPi Board is connected and the port and baud rate is correct.
(2) Please check the switch on the BearPi board is at the <AT+MCU> position.
(3) Please ensure the switch of serial port terminal in LiteOS Studio is opening.
Huawei IoT Certification Training Lab Guide Page 27
Question 2: If my Wi-Fi network is not connected using Wi-Fi name and password, how
can I do the experiment?
Answer 2: In the experiment, the Wi-Fi communication module only support Wi-Fi
network which can be connected using Wi-Fi name and password. If you do not have the
environment with stable Wi-Fi network or that using Wi-Fi name and password to
connect, mobile phone hotspot is recommanded.
Question 3: Why my Wi-Fi communication module cannot connect with the network or
platform?
Answer 3: For this question, it has a lot of reasons. They are as follows:
(1) Please check about the computer configuration, the port 1883 may close in your
computer, so you cannot connect to the platform.
(2) Please check the demo name、Wi-Fi name and password in the .config and
iot_config.h files, they may have spelling mistakes.
(3) Please check the IP address in the oc_agriculture_template.c file is the same as your
own network.
(4) Please check the computer and BearPi board are connected with the same Wi-Fi
network.