OpenHarmony remotely controls Hongmeng car through MQTT

Abstract : This article introduces how to use the MQTT protocol to remotely control the OpenHarmony car, which can realize remote control of the OpenHarmony car.

Suitable group : suitable for Runhe Hi3861 development board

All code repositories in this article: https://gitee.com/qidiyun/hihope-3861-smart-home-kit

1 Introduction to the car

WiFi car based on Hongmeng system + Hi3861

First of all, we need to have a WiFi car kit, which is actually Hi3861 plus motor, tracking module, ultrasonic and other modules.

After the car is installed, it probably looks like this:
Insert image description here

The entire communication framework is as follows:
Insert image description here
Among them, we use the general MQTT cloud, address: test.mosquitto.org

2 How to use

(1) Download the MQTT software package

MQTT is currently the most mainstream IoT communication protocol and requires IoT cloud platforms. For example, Huawei Cloud, Alibaba Cloud, and Mobile OneNET all support mqtt. The Hi3861 is a chip specially built for IoT application scenarios. This section mainly talks about how to implement the MQTT protocol function in the Hongmeng system by transplanting the third-party software package paho mqtt. Finally, test verification will be given. Lay a solid foundation for subsequent IoT projects.

MQTT source code that has been transplanted: https://gitee.com/qidiyun/harmony_mqtt

Place the downloaded file under third_party and rename it to pahomqtt

(2) Enable PWM function

To use the pwm function, we need to modify

device/soc/hisilicon/hi3861v100/sdk_liteos/build/config/usr_config.mk

Add these two lines, here is to turn on the PWM function

CONFIG_PWM_SUPPORT=y

CONFIG_PWM_HOLD_AFTER_REBOOT=y

OpenHarmony lightweight system development【13】Hongmeng car development-Hongmeng HarmonyOS technology community

(3) Car hot spots

Note that the default SSID of the WiFi car firmware here is to connect to the hotspot:
OpenHarmony lightweight system development【13】Hongmeng car development-Hongmeng HarmonyOS technology community
you need to modify it to your own hotspot.

(3) PC download

The PC host computer is developed in C# and communicates using the MQTT protocol. The download address is https://gitee.com/qidiyun/hihope-3861-smart-home-kit/tree/master/car_mqtt

Guess you like

Origin blog.csdn.net/aa120515692/article/details/123262022