[IoT] How to connect to Baidu IoT Cloud

related articles

1. "MQTT Protocol Analysis Summary (1)"
2. "MQTT Protocol Analysis Summary (2)"
3. "[IoT] How to Connect to Baidu IoT Cloud"
4. "[FreeRTOS] MQTT based on STM32 transplantation of LWIP 2.1.2 》

1. Overview of IoT Hub

Internet of Things (IoT Hub) is a fully managed cloud service for developers in the Internet of Things field, through mainstream Internet of Things protocols (such asMQTT) Communication can establish a secure two-way connection between smart devices and the cloud, and quickly realize IoT projects.

Object access is divided into two project types : equipment type (original object management) and data type. The device type is suitable for device-based IoT scenarios; the data type is suitable for data stream-based IoT scenarios.

Insert picture description here
The device side can realize device data reporting and counter-control by integrating Edge-SDK or open source MQTT client , connecting with its counterpart shadow, and sending and receiving messages.

At the same time, it can cooperate with other products of Tiangong to fulfill the requirements of storing and displaying historical data.

2. Billing strategy

Material access mainly adopts post-payment method, and real-time billing is based on your actual usage, that is, you only need to pay for the number of transmitted messages that have been used.

Tiered price:

Monthly usage: Number of messages N Price (yuan/million pieces)
N < 100万 free
1 million <N <100 million 1.2
100 million <N <1 billion 1.0
1 billion or more 0.8

Remarks: I am just learning and using it here. There are 1 million messages available, so I can use it with confidence.
Note: Please refer to the official website for details, I am here just for a brief understanding. Official website address: "Baidu Internet of Things Access IoT Hub. Billing Policy"

3. Create the project

You need to create a project for connecting things to access services, and each project will correspond to an endpoint for you. A project represents a complete material access service.

Log in to the console page, click "Create Project", fill in the name of the project that needs to create the IoT Hub service, select the project type device type (recommended) or data type, and submit it. Through the project, the equipment of different projects can be isolated and managed.

Object access to the console page: https://console.bce.baidu.com/iot2/hub/project/list

  • step one:
    Insert picture description here
  • Step two:
    Insert picture description here
  • Step three:
    Insert picture description here

After the project is created, you can see the three types of addresses provided by default for object access on the project list page. Choosing a different address means that you can connect to Baidu Smart Cloud Internet in different ways.

  • tcp://yourendpoint.mqtt.iot.gz.baiduce.com:1883, port 1883, does not support transmission data encryption, you can connect through the MQTT.fx client.
  • ssl://yourendpoint.mqtt.iot.gz.baiduce.com:1884, port 1884, support SSL/TLS encrypted transmission, MQTT.fx client connection.
  • wss://yourendpoint.mqtt.iot.gz.baidubce.com:8884, port 8884, supports Websockets connection, also includes SSL encryption, refer to Websockets Client.

4. Configure the project

The configuration items are mainly to create users , set identities, and set policies . The detailed steps are as follows:

  • step one:
    Insert picture description here
  • Step two:
    Insert picture description here
  • Step 3:
    Insert picture description here
    Next, we cansubscribe totopicsthrough MQTTHelloTest001 to test.

5. Use MQTT.fx to test

Configure the MQTT application client to quickly verify whether it can communicate with the IoT service to send or receive messages.

Log in to the official website of MQTT.fx , find a suitable version, download and install the MQTT.fx client.

The detailed steps are as follows:

  • Step 1: Open the settings page of the MQTT client and click the "+" button to create a new configuration file

Insert picture description here
Insert picture description here

(1) Fill in the relevant information of the Connection profile:

parameter name Description
profile name The name of the configuration file can be filled in at will
Broker Address Hostname returned after the project is created
Broker Port 1883
Client ID Client ID, supports "az", "0-9", "_", "-" characters, and cannot be larger than 128bytes, UTF8 encoding

(2) Select User Credential and enter the username/password returned by creating the IoT Hub service.
(3) Click the "Apply" button to complete the client configuration.

  • Step 2: Return to the MQTT client interface, select the newly created profile, and click the "connect" button to connect to the service.
    Insert picture description here
  • Step 3: After successfully connecting, you can start subscribing to news.
    Insert picture description here
  • Step 4: Publish the message
    Insert picture description here
  • Step Five: View the test results
    Insert picture description here

Guess you like

Origin blog.csdn.net/ZHONGCAI0901/article/details/111764513
Recommended