Home >Product dynamics>Product dynamics
NB144 Serial Server Simulation Communication, Huawei Cloud MQTT Communication Protocol Access Guide

Huawei Cloud Platform provides powerful cloud services, including support for the MQTT protocol(Related article:Which version of the MQTT protocol is better to use?). MQTT is a lightweight communication protocol widely used in the Internet of Things (IoT) field to achieve reliable data transmission and communication between devices. This tutorial will step by step introduce how to use the MQTT service provided by Huawei Cloud, including key steps such as creating an MQTT instance, device access, message publishing, and subscription.

Popular Terms About : Communication protocol

protocol.jpg

1. Huawei Cloud activates MQTT service

First, complete registration and perform real-name authentication. Next, we enter the [Product] → [Internet of Things IoT] → [Device Access] page, select [Management Console], and then enter the Huawei Cloud IoT platform.

huawei cloud -1

huawei cloud -2

After entering the console, select the service package according to the actual situation under [IoTDA Instance]. Select [Open Free Unit] in the tutorial.

 huawei cloud -3

After the creation is successful, refresh the page and you will see that you can start creating devices under the [Device Access] column.

 huawei cloud -4

First, under [Overview], you can view [Access Information] and click to obtain the access address and port number for MQTT communication.

 huawei cloud -5

In [Related Documents] under [Access Information], you can directly and quickly access the relevant manuals of Huawei Cloud.


If you have any questions, you can check through [Related Documents].

Next, return to the device [Access Page], enter the [Product] page, click [Create Product] in the upper right corner to start creating information about the device to be accessed.

 huawei cloud -6

Here, select the resource space you just created as [Owning Resource Space]. Fill in the [product name] according to the actual situation, and you can set it arbitrarily. [Protocol Type] Select [MQTT]. Select [JSON] for [Data Format]. [Manufacturer name] and [Equipment type] can be filled in according to the actual situation.

Once completed, click Confirm.

 huawei cloud -7

Next, go to [Devices] → [All Devices] and click Register Device.

 huawei cloud -8

Select the option you just created in [Official Resource Space] and [Official Product]. Fill in any value in [Product Identification Code], just make sure it is not repeated within a product. In [Device Authentication Type], you can choose [Key] or [Certificate], choose according to the actual situation. In the tutorial, [Key] authentication was selected. After confirming that other information is correct, click OK. A successful creation prompt will appear next.

 huawei cloud -9

Please note that if it is an automatically generated key, be sure to save it. The key can only be viewed once.

After confirming that the key is saved successfully, click [Save and Close], and you will see that the product we just created has been successfully added to the device list. Click Details to enter the product details page.

 huawei cloud -10

On this page you can get product-related information.

At this point, we have successfully activated the MQTT service of Huawei Cloud and created the device.

2. Obtain MQTT communication elements

Before starting to simulate MQTT communication, you need to obtain several parameters required for communication. First, let's go to the product page we just created.

huawei cloud -11

Enter the ToPic management page.

huawei cloud -12

Here, we can find some [System Preset Topics] preset by Huawei Cloud. Just select the corresponding Topic according to your needs.

Next, we need to get the "Client ID", "Username" and "Password". A tool can be used to generate these parameters directly. In [Overview] → [Access Information] → [Related Documents/Resources], click [Pan-Protocol Access] to enter the help document.

 huawei cloud -13

In the document, select any instance to which the device is connected.

huawei cloud -14

huawei cloud -15

Find an online tool under [Connection Authentication] and just click on it. Fill in the [Device ID] and [Key] of the device we registered in the tool to generate the information required for the connection (ClientId, Username, Password).

huawei cloud -16

At this point, we have obtained all the parameters required for communication.

3. Product access uses MQTT to report data

In this tutorial, we use the serial server NB144 device to simulate actual communication scenarios. You can choose equipment according to the actual situation or use software to simulate. For how to use the product, please refer to the relevant video or consult the relevant manual. The required tools can be found in the product's associated software. 

NB144 4-Channel serial server.jpg

Now, we start to simulate the real communication process and open the host computer software of NB144.

First, change the [IP address type] in the product's network parameters to [Dynamic IP].

 huawei cloud -17

Enter the port 1 settings, change the working mode to [MQTT Client] mode, and select the standard [Huawei Cloud] as the platform.

Then fill in [Target IP], [Target Port], [Client ID], [Device name] and [Device secret] in order. Subscription and publishing are filled in based on actual conditions. In the tutorial, we select a system publishing topic for data transfer and leave the subscription topic blank.

 huawei cloud -18

After saving and restarting, wait for a while, and you will be able to see the device successfully connected in the background of the Huawei Cloud Platform.

 huawei cloud -19

At this point, we have successfully connected the product to Huawei Cloud through MQTT. Next, use any serial port debugging tool to simulate the device data reporting function.

In this tutorial, we use the XCOM tool, open the tool, confirm whether the serial port parameters are correct, and then [Open the serial port].

 huawei cloud -20

For rules on reporting data, please refer to the relevant manual. Due to space limitations, no further explanation will be given. Send the data report directly, and then under the [Device Shadow] page of the product, you can see the data just reported.

 huawei cloud -21

huawei cloud -22

At this point, we have successfully connected to Huawei Cloud's MQTT platform and implemented the data reporting function.


We are  a national high-tech enterprise specializing in the research and development of wireless modules and industrial IoT terminals. Independently developed and produced products include LoRa/WiFi Wireless Module/Bluetooth/ZigBee wireless modules, Ethernet modules, NB-IoT data transmission terminals, industrial IoT.



FREE TRIAL AT CDEBYTE

Explore Our Free trial and Evaluate More Discounts

new arrival.jpgMODEM SALE.jpg