MQTT driver for ESP32 target

MQTT blockset for Waijung 2 (ESP32 target) contains three blocks for connecting, subscribing and publishing with MQTT broker.
897 Downloads
Updated 9 Apr 2022

View License

MQTT blockset for Waijung 2 contains three blocks for connecting, subscribing and publishing with MQTT brokers. To use this blockset, user must first download and install Waijung 2 (https://www.aimagin.com/en/waijung-2-for-esp32.html) as Embedded Coder for ESP32 target. This blockset wraps the C API of ESP-MQTT libray using MATLAB System Object.
The preparation steps are as follows:
1. extract 7z file using 7zip application, avoid to use path with space and special characters.
2. run MATLAB and change working folder to Waijung 2.
3. run install_waijung2.m to install and set path.
4. create a Simulink model, then add Waijung 2 Target Setup block.
5. configure board (flash memory size and COM port)
6. select Embedded Coder app to show C CODE tab.
7. click Build to build application.
To use this blockset, the model should follow the following guideline.
1. Use WiFi Setup block from Waijung 2 blockset to connect with available a WiFi network.
2. Use the output port of WiFi Setup block to trigger the <MQTT connect> block.
3. Put <MQTT subscribe> and <MQTT publish>blocks inside Enabled Subsystem block to be enabled by <MQTT connect> block.
At version 0.1x, only MQTT over TCP and WebSocket is supported. Future improvement is to support other secure connections.

Cite As

Supachai Vorapojpisut (2026). MQTT driver for ESP32 target (https://nl.mathworks.com/matlabcentral/fileexchange/100571-mqtt-driver-for-esp32-target), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022a
Compatible with R2019b to R2022a
Platform Compatibility
Windows macOS Linux
Version Published Release Notes
0.13

Update code to Waijung 2 version 22.2c

0.12

Rename title, add preview image for the example model, and fix some explanation.

0.11

Add example to show how to echo subscribed messages.

0.1