0% found this document useful (0 votes)
194 views29 pages

Hcia-Iot Huawei Certified ICT Associate-Internet of Things Lab Guide

Uploaded by

Simbisai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views29 pages

Hcia-Iot Huawei Certified ICT Associate-Internet of Things Lab Guide

Uploaded by

Simbisai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Huawei IoT Certification Training

HCIA-IoT

Huawei Certified ICT


Associate-Internet of Things

Lab Guide
ISSUE: 2.5

Huawei Technologies Co., Ltd.


Copyright © Huawei Technologies Co., Ltd. 2020. All rights reserved.
No part of this document may be reproduced or transmitted in any form or by any
means without prior written consent of Huawei Technologies Co., Ltd.

Trademarks and Permissions

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.

Huawei Technologies Co., Ltd.


Address: Huawei Industrial Base Bantian, Longgang Shenzhen 518129
People's Republic of China
Website: http://e.huawei.com

Huawei Proprietary and Confidential


Copyright © Huawei Technologies Co,Ltd
Huawei IoT Certification Training Lab Guide Page 1

Huawei Certification System


Huawei Certification follows the "platform + ecosystem" development strategy,
which is a new collaborative architecture of ICT infrastructure based on "Cloud-Pipe-
Terminal". Huawei has set up a complete certification system consisting of three
categories: ICT infrastructure certification, Platform and Service certification and ICT
vertical certification. Huawei certification is the only all-range technical certification in
the industry. Huawei offers three levels of certification: Huawei Certified ICT Associate
(HCIA), Huawei Certified ICT Professional (HCIP), and Huawei Certified ICT Expert
(HCIE). The certification covers all ICT fields and complies with the industry trend of ICT
convergence. With its leading talent development system and certification standards,
Huawei is committed to fostering new ICT talent in the digital era and building a sound
ICT talent ecosystem.
Huawei Certified ICT Associate-Internet of Things (HCIA-IoT) is designed for field
engineers from Huawei and representative offices or anyone who wants to learn how
to use Huawei IoT product technologies (university students or IoT practitioners). The
HCIA-IoT certification covers the HUAWEI CLOUD IoT platform, Huawei LiteOS, and IoT
communication technologies (wireless communication and IoT gateway).
Stay on the cutting edge with Huawei certification.
Huawei IoT Certification Training Lab Guide Page 2
Huawei IoT Certification Training Lab Guide Page 3

About This Document

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.

Background Knowledge Required


This course is specifically designed for the HCIA-IoT certification. To complete this course,
you need to:
 Have basic C language programming ability

Lab Environment Overview


Device Introduction
To meet exercise requirements, the following environment configurations are
recommended:
The following table lists the devices required.

Device Name Model

BearPi development board suite:


IoT development 1. BearPi-IoT motherboard
board suite 2. Communications expansion board: Wi-Fi
3. Case expansion boards: smart agriculture, smart smoke
Huawei IoT Certification Training Lab Guide Page 4

Device Name Model


detector, smart logistics, and smart street lamp

MQTT Broker EMQ X Broker 4.2.0

Exercise Environment Preparation


Device Check
Before the exercise, each group of candidates should check whether the devices are
ready. The following table lists the exercise devices.

Device Name Quantity Remarks

The device can access the


Laptop One for each candidate
public network.

IoT development board


One set for each group BearPi development suite
suite

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 Huawei LiteOS Exercise

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.

Step 2 Open the project.


Open the installed LiteOS Studio.
Huawei IoT Certification Training Lab Guide Page 6

Choose File > Open Folder in the upper left corner and select the LiteOS_Lab_HCIA
folder.

1.2.2 Running the HelloWorld Task


Step 1 Open hello_world_demo.c.
Choose LiteOS_Lab_HCIA > targets > STM32L431_BearPi >
Demos > hello_world_demo > hello_world_demo.c.
Huawei IoT Certification Training Lab Guide Page 7

Step 2 Configure the project.

Click on the toolbar.

Select STM32L431RC as the target board and click Confirm.


Huawei IoT Certification Training Lab Guide Page 8

Choose Compiler, click on the right of Makefile Script, and click Confirm.
Huawei IoT Certification Training Lab Guide Page 9

Choose Burner, set Burning Mode to OpenOCD, and click Confirm.


Huawei IoT Certification Training Lab Guide Page 10

Click to exit project configuration.

Step 3 Compile the program.

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

Click on the toolbar. Set Burn Files to


LiteOS_Lab_HCIA\targets\STM32L431_BearPi\GCC\build\Huawei_LiteOS.bin.

Step 4 Configure the development board.


Set the switch of the serial port mode to the AT<->MCU mode (indicating that the NB-
IoT module is connected to the MCU).
Connect the development board to the PC using a USB cable.

Step 5 Burn the program.


Click on the toolbar and wait for the burning to complete.
Huawei IoT Certification Training Lab Guide Page 12

Step 6 View the result.


Start the serial port terminal, set the baud rate to 115200, and enable the serial port. The
following information is displayed in the receiving area:
Hello World! This is BearPi!

1.2.3 Creating a Cross-Printing Task


Step 1 Add the code of task2.
In hello_world_demo.c, add the code for executing task2.

static int task2()


{
while (1)
{
printf("This is Task2!\r\n");
osal_task_sleep(4*1000);
}
}
Huawei IoT Certification Training Lab Guide Page 13

Step 2 Create task2.

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

1.2.4 Enabling the Onboard LCD


Step 1 Import the header file of the LCD driver.

#include "lcd.h"

Step 2 Add the code for clearing the LCD.

LCD_Clear(BLACK);

Step 3 Add the code of the content to be shown on the LCD.

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.

1.2.5 Blinking the Onboard LED


Step 1 Add the LED blinking code.

static int led_task()


{
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
Huawei IoT Certification Training Lab Guide Page 16

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);
}
}

Step 2 Create an LED blinking task.

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.

1.2.6 Using the Onboard Buttons to Control the LED


Step 1 Comment out the LED blinking loop code.

Step 2 Add the button judgment code.

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 Wi-Fi-based Smart Agriculture Exercise

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.

Step 2 Modify the .config file.


Huawei IoT Certification Training Lab Guide Page 20

Choose targets > STM32L431_BearPi > .config.


Set CONFIG_USER_DEMO to oc_agriculture_template.
Uncomment the Wi-Fi part configuration code.
Set CONFIG_ESP8266_SSID to the Wi-Fi username.
Set CONFIG_ESP8266_PWD to the Wi-Fi password.
Uncomment the MQTT part configuration code.
Press Ctrl+S to save the .config file.

Step 3 Modify the iot_config.h file.


Choose targets > STM32L431_BearPi > iot_config.h.
Set CONFIG_USER_DEMO to oc_agriculture_template.
Uncomment the Wi-Fi part configuration code.
Set CONFIG_ESP8266_SSID to the Wi-Fi username.
Set CONFIG_ESP8266_PWD to the Wi-Fi password.
Uncomment the MQTT part configuration code.
Huawei IoT Certification Training Lab Guide Page 21

Press Ctrl+S to save the iot_config.h file.

2.2.2 Configuring the IP Address of the Broker


Step 1 Query the IP address of the Broker.
Press Win+R to open the Run Program, and type in cmd to open the Command
Window.
Huawei IoT Certification Training Lab Guide Page 22

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.

Step 2 Change the IP address in the code.


Set DEFAULT_SERVER_IPV4 to the queried IP address.
Huawei IoT Certification Training Lab Guide Page 23

2.2.3 Using Wi-Fi for Communication


Step 1 Compile and burn the program and view the result.

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.

2.2.4 Running Applications


Step 1 Run the Java program to view smart agriculture data.
Right-click HCIA-IoTEN and choose Run As > Java Application from the shortcut menu.
On the Broker page, the device is online.
Huawei IoT Certification Training Lab Guide Page 24

View the real-time data on the console.

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.

The LED on the development board is on.

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.

3.2.2 Wi-Fi-based Smart Logistics Exercise


Step 1 Change the cases in .config and iot_config.h to oc_track_template.
Step 2 Modify the code in oc_track_template.c to use the MQTT protocol to report data
and process command responses.

3.2.3 Wi-Fi-based Smart Street Lamp Exercise


Step 1 Change the cases in .config and iot_config.h to oc_streetlight_template.
Step 2 Modify the code in oc_streetlight_template.c to use the MQTT protocol to report
data and process command responses.
Huawei IoT Certification Training Lab Guide Page 26

4 Technical Consultation

4.1 Problems may occur in Exercise 1


Question 1: Does the experiments support the computer in Linux or MacOS operating
systems?
Answer 1: The experiments only support Windows system currently, but the Linux and
MacOS operating systems will be supported soon.

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

4.2 Problems may occur in Exercise 2


Question 1: Why I cannot access to the EMQ X Broker?
Answer 1: For this question, it has a lot of reasons. They are as follows:
(1) Please ensure you opened the Windows PowerShell and typed the correct command.
(2) Please check the path of your folder that you have accessed in PowerShell is correct.

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.

Question 4: The serial port terminal shows


“[DEBUG][6374][standard_app_demo_main:43] standard_app_demo_main:###please
implement app demo by yourself####”, and I cannot realize the experiment, how to fix
this problem?
Answer 4: This problem occurs when the demo name is not correct, please check about
the demo name in the configuration file. (.config and iot_config.h)

You might also like