AsyncMQTT_ESP32
AsyncMQTT_ESP32 copied to clipboard
Arduino Library for ESP32/S2/S3/C3 asynchronous MQTT client implementation. This library, ported to support ESP32/S2/S3/C3, WT32_ETH01 (ESP32 + LAN8720), ESP32 using LwIP ENC28J60, W5500, W6100 or LAN...
AsyncMQTT_ESP32 Library
Table of Contents
-
Why do we need this AsyncMQTT_ESP32 library
- Features
- Why Async is better
- Currently supported Boards
- To-be-supported Boards
- Changelog
- Prerequisites
-
Installation
- Use Arduino Library Manager
- Manual Install
- VS Code & PlatformIO
-
HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)
- 1. ESP32 has 2 ADCs, named ADC1 and ADC2
- 2. ESP32 ADCs functions
- 3. ESP32 WiFi uses ADC2 for WiFi functions
- Basic Usage
- How to connect W5500, W6100 or ENC28J60 to ESP32_S2/S3/C3
-
Examples
-
1. For ESP32
- 1. FullyFeatured_ESP32
- 2. FullyFeaturedSSL_ESP32
-
2. For WT32_ETH01
- 1. FullyFeatured_WT32_ETH01
- 2. FullyFeaturedSSL_WT32_ETH01
-
3. For ESP32_ENC
- 1. FullyFeatured_ESP32_ENC
- 2. FullyFeaturedSSL_ESP32_ENC
-
4. For ESP32_W5500
- 1. FullyFeatured_ESP32_W5500
- 2. FullyFeaturedSSL_ESP32_W5500
-
5. For ESP32_SC_ENC
- 1. FullyFeatured_ESP32_SC_ENC
- 2. FullyFeaturedSSL_ESP32_SC_ENC
-
6. For ESP32_SC_W5500
- 1. FullyFeatured_ESP32_SC_W5500
- 2. FullyFeaturedSSL_ESP32_SC_W5500
-
7. For ESP32_W6100
- 1. FullyFeatured_ESP32_W6100
- 2. FullyFeaturedSSL_ESP32_W6100
-
8. For ESP32_SC_W6100
- 1. FullyFeatured_ESP32_SC_W6100
- 2. FullyFeaturedSSL_ESP32_SC_W6100
-
1. For ESP32
-
Example FullyFeaturedSSL_ESP32_SC_W5500
- 1. File FullyFeaturedSSL_ESP32_SC_W5500.ino
- 2. File defines.h
-
Debug Terminal Output Samples
- 1. FullyFeature_ESP32_SC_W5500 on ESP32S3_DEV with ESP32_S3_W5500
- 2. FullyFeatureSSL_ESP32_SC_W5500 on ESP32S3_DEV with ESP32_S3_W5500
- 3. FullyFeature_ESP32_SC_ENC on ESP32S3_DEV with ESP32_S3_ENC28J60
- 4. FullyFeatureSSL_ESP32_SC_ENC on ESP32S3_DEV with ESP32_S3_ENC28J60
- 5. FullyFeatureSSL_WT32_ETH01 on WT32-ETH01 with ETH_PHY_LAN8720
- 6. FullyFeatureSSL_ESP32_SC_W5500 on ESP32S2_DEV with ESP32_S2_W5500
- 7. FullyFeatureSSL_ESP32_SC_W5500 on ESP32C3_DEV with ESP32_C3_W5500
- 8. FullyFeatureSSL_ESP32_SC_ENC on ESP32C3_DEV with ESP32_C3_ENC28J60
- 9. FullyFeature_ESP32_W6100 on ESP32_DEV with ESP32_W6100
- 10. FullyFeatureSSL_ESP32_SC_W6100 on ESP32S3_DEV with ESP32_S3_W6100
- Debug
- Troubleshooting
- Issues
- TO DO
- DONE
- Contributions and Thanks
- Contributing
- License
- Copyright
Why do we need this AsyncMQTT_ESP32 library
Features
This AsyncMQTT_ESP32 library is based on and modified from Marvin Roger's async-mqtt-client Library, to provide support to ESP32/S2/S3/C3
boards using WiFi or LwIP W5500 / W6100 / ENC28J60 / LAN8720 Ethernet
Why Async is better
- Using asynchronous network means that you can handle more than one connection at the same time
- You are called once the request is ready and parsed
- When you send the response, you are immediately ready to handle other connections while the server is taking care of sending the response in the background
- Speed is OMG
- Easy to use API, HTTP Basic and Digest MD5 Authentication (default), ChunkedResponse
- Easily extensible to handle any type of content
- Supports Continue 100
- Async WebSocket plugin offering different locations without extra servers or ports
- Async EventSource (Server-Sent Events) plugin to send events to the browser
- URL Rewrite plugin for conditional and permanent url rewrites
- ServeStatic plugin that supports cache, Last-Modified, default index and more
- Simple template processing engine to handle templates
Currently Supported Boards
1. ESP32/S2/S3/C3 using WiFi
- ESP32 (ESP32-DEV, etc.)
2. ESP32 using LwIP ENC28J60, W5500, W6100 or LAN8720
- ESP32 (ESP32-DEV, etc.)
3. WT32_ETH01 using ESP32-based boards and LAN8720 Ethernet
4. ESP32S3 using LwIP W5500, W6100 or ENC28J60
- ESP32-S3 (ESP32S3_DEV, ESP32_S3_BOX, UM TINYS3, UM PROS3, UM FEATHERS3, etc.)
5. ESP32S2 using LwIP W5500, W6100 or ENC28J60
- ESP32-S2 (ESP32S2_DEV, etc.)
6. ESP32C3 using LwIP W5500, W6100 or ENC28J60
- ESP32-C3 (ESP32C3_DEV, etc.)
ESP32S3_DEV
ESP32S2_DEV
ESP32C3_DEV
W6100
FULL_DUPLEX, 100Mbps
W5500
FULL_DUPLEX, 100Mbps
ENC28J60
FULL_DUPLEX, 10Mbps
To-be Supported Boards
1. New ESP32 using LwIP W5500, W6100 or ENC28J60
Prerequisites
-
Arduino IDE 1.8.19+
for Arduino. -
ESP32 Core 2.0.6+
for ESP32-based boards. -
AsyncTCP v1.1.1+
for ESP32. To install manually for Arduno IDE -
AsyncTCP_SSL v1.3.1+
for ESP32. -
WebServer_WT32_ETH01 v1.5.1+
for ESP32-based WT32_ETH01 using either ESP32 core v2.0.0+ or v1.0.6-. -
WebServer_ESP32_ENC library v1.5.1+
if necessary to use ESP32 boards usingLwIP ENC28J60
Ethernet. To install, check -
WebServer_ESP32_W5500 library v1.5.2+
if necessary to use ESP32 boards usingLwIP W5500
Ethernet. To install, check -
WebServer_ESP32_SC_ENC library v1.2.0+
if necessary to useESP32_S2/S3/C3
boards usingLwIP ENC28J60
Ethernet. To install, check -
WebServer_ESP32_SC_W5500 library v1.2.1+
if necessary to useESP32_S2/S3/C3
boards usingLwIP W5500
Ethernet. To install, check -
WebServer_ESP32_W6100 library v1.5.2+
if necessary to use ESP32 boards usingLwIP W6100
Ethernet. To install, check -
WebServer_ESP32_SC_W6100 library v1.2.1+
if necessary to useESP32_S2/S3/C3
boards usingLwIP W6100
Ethernet. To install, check
Installation
Use Arduino Library Manager
The best and easiest way is to use Arduino Library Manager
. Search for AsyncMQTT_ESP32
, then select / install the latest version.
You can also use this link for more detailed instructions.
Manual Install
Another way to install is to:
- Navigate to AsyncMQTT_ESP32 page.
- Download the latest release
AsyncMQTT_ESP32-main.zip
. - Extract the zip file to
AsyncMQTT_ESP32-main
directory - Copy whole
AsyncMQTT_ESP32-main
folder to Arduino libraries' directory such as~/Arduino/libraries/
.
VS Code & PlatformIO:
- Install VS Code
- Install PlatformIO
- Install AsyncMQTT_ESP32 library by using Library Manager. Search for AsyncMQTT_ESP32 in Platform.io Author's Libraries
- Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File
HOWTO Use analogRead() with ESP32 running WiFi and/or BlueTooth (BT/BLE)
Please have a look at ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example to have more detailed description and solution of the issue.
1. ESP32 has 2 ADCs, named ADC1 and ADC2
2. ESP32 ADCs functions
-
ADC1
controlsADC
function for pins GPIO32-GPIO39 -
ADC2
controlsADC
function for pins GPIO0, 2, 4, 12-15, 25-27
3.. ESP32 WiFi uses ADC2 for WiFi functions
Look in file adc_common.c
In ADC2, there're two locks used for different cases:
lock shared with app and Wi-Fi: ESP32: When Wi-Fi using the ADC2, we assume it will never stop, so app checks the lock and returns immediately if failed. ESP32S2: The controller's control over the ADC is determined by the arbiter. There is no need to control by lock.
lock shared between tasks: when several tasks sharing the ADC2, we want to guarantee all the requests will be handled. Since conversions are short (about 31us), app returns the lock very soon, we use a spinlock to stand there waiting to do conversions one by one.
adc2_spinlock should be acquired first, then adc2_wifi_lock or rtc_spinlock.
- In order to use
ADC2
for other functions, we have to acquire complicated firmware locks and very difficult to do - So, it's not advisable to use
ADC2
with WiFi/BlueTooth (BT/BLE). - Use
ADC1
, and pins GPIO32-GPIO39 - If somehow it's a must to use those pins serviced by
ADC2
(GPIO0, 2, 4, 12, 13, 14, 15, 25, 26 and 27), use the fix mentioned at the end of ESP_WiFiManager Issue 39: Not able to read analog port when using the autoconnect example to work with ESP32 WiFi/BlueTooth (BT/BLE).
Basic Usage
Please check API documentation.
How to connect W5500, W6100 or ENC28J60 to ESP32_S2/S3/C3
W6100
FULL_DUPLEX, 100Mbps
W5500
FULL_DUPLEX, 100Mbps
ENC28J60
FULL_DUPLEX, 10Mbps
ESP32S3_DEV
You can change the INT
pin to another one. Default is GPIO4
// Must connect INT to GPIOxx or not working
#define INT_GPIO 4
W5500, W6100 or ENC28J60 | <---> | ESP32_S3 |
---|---|---|
MOSI | <---> | GPIO11 |
MISO | <---> | GPIO13 |
SCK | <---> | GPIO12 |
CS/SS | <---> | GPIO10 |
INT | <---> | GPIO4 |
RST | <---> | RST |
GND | <---> | GND |
3.3V | <---> | 3.3V |
ESP32S2_DEV
You can change the INT
pin to another one. Default is GPIO4
// Must connect INT to GPIOxx or not working
#define INT_GPIO 4
W5500, W6100 or ENC28J60 | <---> | ESP32_S2 |
---|---|---|
MOSI | <---> | GPIO35 |
MISO | <---> | GPIO37 |
SCK | <---> | GPIO36 |
CS/SS | <---> | GPIO34 |
INT | <---> | GPIO4 |
RST | <---> | RST |
GND | <---> | GND |
3.3V | <---> | 3.3V |
ESP32C3_DEV
You can change the INT
pin to another one. Default is GPIO4
// Must connect INT to GPIOxx or not working
#define INT_GPIO 10
W5500, W6100 or ENC28J60 | <---> | ESP32_C3 |
---|---|---|
MOSI | <---> | GPIO6 |
MISO | <---> | GPIO5 |
SCK | <---> | GPIO4 |
CS/SS | <---> | GPIO7 |
INT | <---> | GPIO10 |
RST | <---> | RST |
GND | <---> | GND |
3.3V | <---> | 3.3V |
Examples
1. For ESP32
- FullyFeatured_ESP32
- FullyFeaturedSSL_ESP32
2. For WT32_ETH01
- FullyFeatured_WT32_ETH01
- FullyFeaturedSSL_WT32_ETH01
3. For ESP32_ENC
- FullyFeatured_ESP32_ENC
- FullyFeaturedSSL_ESP32_ENC
4. For ESP32_W5500
- FullyFeatured_ESP32_W5500
- FullyFeaturedSSL_ESP32_W5500
5. For ESP32_SC_ENC
- FullyFeatured_ESP32_SC_ENC
- FullyFeaturedSSL_ESP32_SC_ENC
6. For ESP32_SC_W5500
- FullyFeatured_ESP32_SC_W5500
- FullyFeaturedSSL_ESP32_SC_W5500
7. For ESP32_W6100
- FullyFeatured_ESP32_W6100
- FullyFeaturedSSL_ESP32_W6100
8. For ESP32_SC_W6100
- FullyFeatured_ESP32_SC_W6100
- FullyFeaturedSSL_ESP32_SC_W6100
Example FullyFeaturedSSL_ESP32_SC_W5500
1. File FullyFeaturedSSL_ESP32_SC_W5500.ino
https://github.com/khoih-prog/AsyncMQTT_ESP32/blob/4a9f8bcdb04e6c0c329bda40896afd4d7d8e31c7/examples/ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500.ino#L14-L283
2. File defines.h
https://github.com/khoih-prog/AsyncMQTT_ESP32/blob/4a9f8bcdb04e6c0c329bda40896afd4d7d8e31c7/examples/ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500/defines.h#L13-L90
Debug Terminal Output Samples
1. FullyFeature_ESP32_SC_W5500 on ESP32S3_DEV with ESP32_S3_W5500
This is terminal debug output when running FullyFeatured_ESP32_SC_W5500 on ESP32S3_DEV with LwIP W5500
, connecting to broker.emqx.io
MQTT server.
Starting FullyFeature_ESP32_SC_W5500 on ESP32S3_DEV with ESP32_S3_W5500
WebServer_ESP32_SC_W5500 v1.2.1 for core v2.0.0+
AsyncMQTT_ESP32 v1.10.0 for ESP32 core v2.0.0+
ETH starting
ETH connected
ETH got IP
IP address: 192.168.2.108
Connecting to MQTT...
Connected to MQTT broker: broker.emqx.io, port: 1883
PubTopic: async-mqtt/ESP32_SC_W5500_Pub
************************************************
Session present: 0
Subscribing at QoS 2, packetId: 1
Publishing at QoS 0
Publishing at QoS 1, packetId: 2
Publishing at QoS 2, packetId: 3
************************************************
Subscribe acknowledged.
packetId: 1
qos: 2
Publish received.
topic: async-mqtt/ESP32_SC_W5500_Pub
qos: 0
dup: 0
retain: 0
len: 16
index: 0
total: 16
Publish acknowledged.
packetId: 2
Publish received.
topic: async-mqtt/ESP32_SC_W5500_Pub
qos: 1
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_SC_W5500_Pub
qos: 2
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish acknowledged.
packetId: 3
2. FullyFeatureSSL_ESP32_SC_W5500 on ESP32S3_DEV with ESP32_S3_W5500
This is terminal debug output when running FullyFeaturedSSL_ESP32_SC_W5500 on ESP32S3_DEV with LwIP W5500
, connecting to broker.emqx.io
secured MQTTS server (port 8883)
Starting FullyFeatureSSL_ESP32_SC_W5500 on ESP32S3_DEV with ESP32_S3_W5500
WebServer_ESP32_SC_W5500 v1.2.1 for core v2.0.0+
AsyncMQTT_ESP32 v1.10.0 for ESP32 core v2.0.0+
ETH starting
ETH connected
ETH got IP
IP address: 192.168.2.125
Connecting to MQTT...
Connected to MQTT broker: broker.emqx.io, port: 8883
PubTopic: async-mqtt/ESP32_W5500_SSL_Pub
************************************************
Session present: 0
Subscribing at QoS 2, packetId: 1
Publishing at QoS 0
Publishing at QoS 1, packetId: 2
Publishing at QoS 2, packetId: 3
************************************************
Subscribe acknowledged.
packetId: 1
qos: 2
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 0
dup: 0
retain: 0
len: 16
index: 0
total: 16
Publish acknowledged
packetId: 2
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 1
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 2
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish acknowledged
packetId: 3
3. FullyFeature_ESP32_SC_ENC on ESP32S3_DEV with ESP32_S3_ENC28J60
This is terminal debug output when running FullyFeatured_ESP32_SC_ENC on ESP32S3_DEV with LwIP ENC28J60
, connecting to broker.emqx.io
MQTT server.
Starting FullyFeature_ESP32_SC_ENC on ESP32S3_DEV with ESP32_S3_ENC28J60
WebServer_ESP32_SC_ENC v1.2.0 for core v2.0.0+
AsyncMQTT_ESP32 v1.10.0 for ESP32 core v2.0.0+
ETH starting
ETH connected
ETH got IP
IP address: 192.168.2.88
Connecting to MQTT...
Connected to MQTT broker: broker.emqx.io, port: 1883
PubTopic: async-mqtt/ESP32_SC_ENC_Pub
************************************************
Session present: 0
Subscribing at QoS 2, packetId: 1
Publishing at QoS 0
Publishing at QoS 1, packetId: 2
Publishing at QoS 2, packetId: 3
************************************************
Subscribe acknowledged.
packetId: 1
qos: 2
Publish received.
topic: async-mqtt/ESP32_SC_ENC_Pub
qos: 0
dup: 0
retain: 0
len: 14
index: 0
total: 14
Publish acknowledged.
packetId: 2
Publish received.
topic: async-mqtt/ESP32_SC_ENC_Pub
qos: 1
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_SC_ENC_Pub
qos: 2
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish acknowledged.
packetId: 3
4. FullyFeatureSSL_ESP32_SC_ENC on ESP32S3_DEV with ESP32_S3_ENC28J60
This is terminal debug output when running FullyFeaturedSSL_ESP32_SC_ENC on ESP32S3_DEV with LwIP ENC28J60
, connecting to broker.emqx.io
secured MQTTS server (port 8883)
Starting FullyFeatureSSL_ESP32_SC_ENC on ESP32S3_DEV with ESP32_S3_ENC28J60
WebServer_ESP32_SC_ENC v1.2.0 for core v2.0.0+
AsyncMQTT_ESP32 v1.10.0 for ESP32 core v2.0.0+
ETH starting
ETH connected
ETH got IP
IP address: 192.168.2.109
Connecting to MQTT...
Connected to MQTT broker: broker.emqx.io, port: 8883
PubTopic: async-mqtt/ESP32_SC_ENC_SSL_Pub
************************************************
Session present: 0
Subscribing at QoS 2, packetId: 1
Publishing at QoS 0
Publishing at QoS 1, packetId: 2
Publishing at QoS 2, packetId: 3
************************************************
Subscribe acknowledged.
packetId: 1
qos: 2
Publish received.
topic: async-mqtt/ESP32_SC_ENC_SSL_Pub
qos: 0
dup: 0
retain: 0
len: 17
index: 0
total: 17
Publish acknowledged
packetId: 2
Publish received.
topic: async-mqtt/ESP32_SC_ENC_SSL_Pub
qos: 1
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_SC_ENC_SSL_Pub
qos: 2
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish acknowledged
packetId: 3
5. FullyFeatureSSL_WT32_ETH01 on WT32-ETH01 with ETH_PHY_LAN8720
This is terminal debug output when running FullyFeaturedSSL_WT32_ETH01 on WT32-ETH01 connecting to broker.emqx.io
secured MQTT server (port 8883)
Starting FullyFeatureSSL_WT32_ETH01 on WT32-ETH01 with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.5.1 for core v2.0.0+
AsyncMQTT_ESP32 v1.10.0 for ESP32 core v2.0.0+
ETH starting
ETH connected
ETH got IP
IP address: 192.168.2.97
Connecting to MQTT...
Connected to MQTT broker: broker.emqx.io, port: 8883
PubTopic: async-mqtt/WT32_ETH01_SSL_Pub
************************************************
Session present: 0
Subscribing at QoS 2, packetId: 1
Publishing at QoS 0
Publishing at QoS 1, packetId: 2
Publishing at QoS 2, packetId: 3
************************************************
Subscribe acknowledged.
packetId: 1
qos: 2
Publish received.
topic: async-mqtt/WT32_ETH01_SSL_Pub
qos: 0
dup: 0
retain: 0
len: 15
index: 0
total: 15
Publish acknowledged
packetId: 2
Publish received.
topic: async-mqtt/WT32_ETH01_SSL_Pub
qos: 1
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/WT32_ETH01_SSL_Pub
qos: 2
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish acknowledged
packetId: 3
6. FullyFeatureSSL_ESP32_SC_W5500 on ESP32S2_DEV with ESP32_S2_W5500
This is terminal debug output when running FullyFeaturedSSL_ESP32_SC_W5500 on ESP32S2_DEV connecting to broker.emqx.io
secured MQTT server (port 8883)
Starting FullyFeatureSSL_ESP32_SC_W5500 on ESP32S2_DEV with ESP32_S2_W5500
WebServer_ESP32_SC_W5500 v1.2.1 for core v2.0.0+
AsyncMQTT_ESP32 v1.10.0 for ESP32 core v2.0.0+
Using built-in mac_eth = 7E:DF:A1:08:32:C9
ETH starting
ETH connected
ETH got IP
IP address: 192.168.2.133
Connecting to MQTT...
Connected to MQTT broker: broker.emqx.io, port: 8883
PubTopic: async-mqtt/ESP32_W5500_SSL_Pub
************************************************
Session present: 0
Subscribing at QoS 2, packetId: 1
Publishing at QoS 0
Publishing at QoS 1, packetId: 2
Publishing at QoS 2, packetId: 3
************************************************
Subscribe acknowledged.
packetId: 1
qos: 2
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 2
dup: 0
retain: 1
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 0
dup: 0
retain: 0
len: 16
index: 0
total: 16
Publish acknowledged
packetId: 2
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 1
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 2
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish acknowledged
packetId: 3
7. FullyFeatureSSL_ESP32_SC_W5500 on ESP32C3_DEV with ESP32_C3_W5500
This is terminal debug output when running FullyFeaturedSSL_ESP32_SC_W5500 on ESP32C3_DEV connecting to broker.emqx.io
secured MQTT server (port 8883)
Starting FullyFeatureSSL_ESP32_SC_W5500 on ESP32C3_DEV with ESP32_C3_W5500
WebServer_ESP32_SC_W5500 v1.2.1 for core v2.0.0+
AsyncMQTT_ESP32 v1.10.0 for ESP32 core v2.0.0+
Using built-in mac_eth = 7C:DF:A1:BC:BC:53
ETH starting
ETH connected
ETH got IP
IP address: 192.168.2.135
Connecting to MQTT...
Connected to MQTT broker: broker.emqx.io, port: 8883
PubTopic: async-mqtt/ESP32_W5500_SSL_Pub
************************************************
Session present: 0
Subscribing at QoS 2, packetId: 1
Publishing at QoS 0
Publishing at QoS 1, packetId: 2
Publishing at QoS 2, packetId: 3
************************************************
Subscribe acknowledged.
packetId: 1
qos: 2
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 2
dup: 0
retain: 1
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 0
dup: 0
retain: 0
len: 16
index: 0
total: 16
Publish acknowledged
packetId: 2
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 1
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_W5500_SSL_Pub
qos: 2
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish acknowledged
packetId: 3
8. FullyFeatureSSL_ESP32_SC_ENC on ESP32C3_DEV with ESP32_C3_ENC28J60
This is terminal debug output when running FullyFeaturedSSL_ESP32_SC_ENC on ESP32C3_DEV connecting to broker.emqx.io
secured MQTT server (port 8883)
Starting FullyFeatureSSL_ESP32_SC_ENC on ESP32C3_DEV with ESP32_C3_ENC28J60
WebServer_ESP32_SC_ENC v1.2.0 for core v2.0.0+
AsyncMQTT_ESP32 v1.10.0 for ESP32 core v2.0.0+
Using built-in mac_eth = 7C:DF:A1:DA:66:87
ETH starting
ETH connected
ETH got IP
IP address: 192.168.2.136
Connecting to MQTT...
Connected to MQTT broker: broker.emqx.io, port: 8883
PubTopic: async-mqtt/ESP32_SC_ENC_SSL_Pub
************************************************
Session present: 0
Subscribing at QoS 2, packetId: 1
Publishing at QoS 0
Publishing at QoS 1, packetId: 2
Publishing at QoS 2, packetId: 3
************************************************
Subscribe acknowledged.
packetId: 1
qos: 2
Publish received.
topic: async-mqtt/ESP32_SC_ENC_SSL_Pub
qos: 2
dup: 0
retain: 1
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_SC_ENC_SSL_Pub
qos: 0
dup: 0
retain: 0
len: 17
index: 0
total: 17
Publish acknowledged
packetId: 2
Publish received.
topic: async-mqtt/ESP32_SC_ENC_SSL_Pub
qos: 1
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_SC_ENC_SSL_Pub
qos: 2
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish acknowledged
packetId: 3
9. FullyFeature_ESP32_W6100 on ESP32_DEV with ESP32_W6100
This is terminal debug output when running FullyFeatured_ESP32_W6100 on ESP32_DEV connecting to broker.emqx.io
secured MQTT server (port 1883)
Starting FullyFeature_ESP32_W6100 on ESP32_DEV with ESP32_W6100
WebServer_ESP32_W6100 v1.5.2 for core v2.0.0+
AsyncMQTT_ESP32 v1.10.0 for ESP32 core v2.0.0+
ETH starting
ETH connected
ETH got IP
IP address: 192.168.2.158
Connecting to MQTT...
Connected to MQTT broker: broker.emqx.io, port: 1883
PubTopic: async-mqtt/ESP32_W6100_Pub
************************************************
Session present: 0
Subscribing at QoS 2, packetId: 1
Publishing at QoS 0
Publishing at QoS 1, packetId: 2
Publishing at QoS 2, packetId: 3
************************************************
Subscribe acknowledged.
packetId: 1
qos: 2
Publish received.
topic: async-mqtt/ESP32_W6100_Pub
qos: 0
dup: 0
retain: 0
len: 16
index: 0
total: 16
Publish acknowledged.
packetId: 2
Publish received.
topic: async-mqtt/ESP32_W6100_Pub
qos: 1
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_W6100_Pub
qos: 2
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish acknowledged.
packetId: 3
10. FullyFeatureSSL_ESP32_SC_W6100 on ESP32S3_DEV with ESP32_S3_W6100
This is terminal debug output when running FullyFeaturedSSL_ESP32_SC_W6100 on ESP32S3_DEV connecting to broker.emqx.io
secured MQTT server (port 8883)
Starting FullyFeatureSSL_ESP32_SC_W6100 on ESP32S3_DEV with ESP32_S3_W6100
WebServer_ESP32_SC_W6100 v1.2.1 for core v2.0.0+
AsyncMQTT_ESP32 v1.10.0 for ESP32 core v2.0.0+
ETH starting
ETH connected
ETH got IP
IP address: 192.168.2.92
Connecting to MQTT...
Connected to MQTT broker: broker.emqx.io, port: 8883
PubTopic: async-mqtt/ESP32_W6100_SSL_Pub
************************************************
Session present: 0
Subscribing at QoS 2, packetId: 1
Publishing at QoS 0
Publishing at QoS 1, packetId: 2
Publishing at QoS 2, packetId: 3
************************************************
Subscribe acknowledged.
packetId: 1
qos: 2
Publish received.
topic: async-mqtt/ESP32_W6100_SSL_Pub
qos: 2
dup: 0
retain: 1
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_W6100_SSL_Pub
qos: 0
dup: 0
retain: 0
len: 16
index: 0
total: 16
Publish acknowledged
packetId: 2
Publish received.
topic: async-mqtt/ESP32_W6100_SSL_Pub
qos: 1
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish received.
topic: async-mqtt/ESP32_W6100_SSL_Pub
qos: 2
dup: 0
retain: 0
len: 6
index: 0
total: 6
Publish acknowledged
packetId: 3
Debug
Debug is enabled by default on Serial. Debug Level from 0 to 4. To disable, change the MYSQL_LOGLEVEL to 0
#define ASYNC_MQTT_DEBUG_PORT Serial
// Debug Level from 0 to 4
#define _ASYNC_MQTT_LOGLEVEL_ 1
Troubleshooting
If you get compilation errors, more often than not, you may need to install a newer version of the core for Arduino boards.
Sometimes, the library will only work if you update the board core to the latest version because I am using newly added functions.
Issues
Submit issues to: AsyncMQTT_ESP32 issues
TO DO
- Bug fixing.
DONE
- Add support to any
ESP32/S2/S3/C3
boards using WiFi withSSL/TLS
- Add support to
ESP32
boards usingLwIP W5500 / ENC28J60 / LAN8720 Ethernet
withSSL/TLS
- Add support to
ESP32S3
boards usingLwIP W5500 / ENC28J60 / LAN8720 Ethernet
withSSL/TLS
- Add support to
ESP32S2
boards usingLwIP W5500 / ENC28J60 / LAN8720 Ethernet
withSSL/TLS
- Add support to
ESP32C3
boards usingLwIP W5500 / ENC28J60 / LAN8720 Ethernet
withSSL/TLS
- Add support to
ESP32
andESP32S2/S3/C3
boards usingLwIP W6100 Ethernet
withSSL/TLS
Contributions and Thanks
- Based on and modified from Marvin Roger's async-mqtt-client Library
![]() ⭐️ Marvin Roger |
Contributing
If you want to contribute to this project:
- Report bugs and errors
- Ask for enhancements
- Create issues and pull requests
- Tell other people about this library
License
-
Many of the credits go to original author Marvin Roger
-
The library is licensed under MIT
Copyright
- Copyright (c) 2017- Marvin Roger
- Copyright (c) 2022- Khoi Hoang