Skip to content

Contributed by wxlinus, curated by Ai-Thinker

I originally wanted to port an MQTT library. Halfway through the porting, I found that VSCode prompted "mqtt" when writing the calls — it turned out the example already had one. So this is a record of connecting the MQTT in the example to EMQX.

  1. Download and start EMQX

Operation Steps

1
./emqx/bin/emqx start

./emqx/bin/emqx start

2
EMQX port introduction

EMQX port introduction

3
Log in to EMQX and configure the MQTT client authorized account

Log in to EMQX and configure the MQTT client authorized account Access http://localhost:18083/ (localhost can be replaced with your actual IP address) through a browser to open the EMQX Dashboard management console for device connection and related metric monitoring.

Operation Steps (continued)

1
Default username and password

Default username and password

2
Username admin

Username admin

3
Password public

Password public

The mqtt account configuration will be needed for device-side development later.

Here I configured one:

Operation Steps (continued)

1
username: test

username: test

2
password: test

password: test

It's better to configure one more for publishing/subscribing in the background later.
3
Device-side development

Device-side development Change the configuration.

Modify the WiFi connection info and mqtt account info; they are hardcoded in the example for now.

4
Flash and then write

Flash and then write

You can see it has connected.

5
Let's test the remote light-on ceremony

Let’s test the remote light-on ceremony Publish a turn-on topic (the light is on by default when the board starts, so I turned it off first; otherwise it wouldn’t be a light-on ceremony )

You can see the serial port received the data and the light turned on.

Done, confetti! ✿✿ヽ(°▽°)ノ✿

Have questions?

For other questions, please visit the unified discussion area: Ai-Thinker Discussions

Released under the MIT License. Build Time 2026-09-11 14:52:23