MQTTPubSubClient_Generic Library

MQTTPubSubClient_Generic library GitHub release
How To Install Using Arduino Library Manager



Why do we need this Async MQTTPubSubClient_Generic library

This MQTTPubSubClient_Generic library is based on and modified from

to provide MQTT and MQTT over WebSoket Client support to many more boards besides ESP32/ESP8266, such as STM32F, Teensy 4.1, etc. boards. Those supported boards can be used with ESP8266/ESP32’s WiFi, LAN8742A/LAN8720 Ethernet, Teensy 4.1 QNEthernet, W5x00 Ethernet, etc.


Features

  • MQTT 3.1.1
  • publish and subscribe message
  • wildcard support for topic
  • qos 0/1/2
  • retain
  • will
  • keep alive (interval and timeout)
  • clean session
  • MQTT over WebSocket by using with WebSockets_Generic library
  • Multiple callback per topic (no need to write if-else in callback)
  • Various boards support which has Arduino's Client class

Currently supported Boards

This MQTTPubSubClient_Generic library currently supports these following boards:

  1. nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.

  2. SAMD21

  • Arduino SAMD21: ZERO, MKRs, NANO_33_IOT, etc.
  • Adafruit SAMD21 (M0): ItsyBitsy M0, Feather M0, Feather M0 Express, Metro M0 Express, Circuit Playground Express, Trinket M0, PIRkey, Hallowing M0, Crickit M0, etc.
  • Seeeduino: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, etc.
  1. SAMD51
  • Adafruit SAMD51 (M4): Metro M4, Grand Central M4, ItsyBitsy M4, Feather M4 Express, Trellis M4, Metro M4 AirLift Lite, MONSTER M4SK Express, Hallowing M4, etc.
  • Seeeduino: Wio Terminal, Grove UI Wireless
  1. Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0)

  2. ESP32

  • ESP32 boards, such as ESP32_DEV, etc.
  • ESP32_S2-based boards, such as ESP32S2_DEV, ESP32_S2 Saola, etc.
  • ESP32_C3-based boards, such as ESP32C3_DEV, etc. New
  • ESP32_S3 (ESP32S3_DEV, ESP32_S3_BOX, UM TINYS3, UM PROS3, UM FEATHERS3, etc.) New
  1. ESP8266

  2. RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core or Earle Philhower's arduino-pico core.

  3. WT32_ETH01 boards using ESP32-based boards and LAN8720 Ethernet

  4. STM32 boards with built-in Ethernet LAN8742A such as :

  1. STM32F/L/H/G/WB/MP1 boards (with 32+K Flash) running W5x00 or ENC28J60 shields)

    • Nucleo-144
    • Nucleo-64
    • Discovery
    • Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7 (with 64+K Flash): x8 and up
    • STM32L0, STM32L1, STM32L4
    • STM32G0, STM32G4
    • STM32H7
    • STM32WB
    • STM32MP1
    • LoRa boards
    • 3-D printer boards
    • Generic Flight Controllers
    • Midatronics boards
  2. STM32 boards using Ethernet LAN8720 such as :

  • Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG)
  • Discovery (DISCO_F746NG)
  • STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)

Currently supported WiFi shields/modules

  1. WiFiNINA using WiFiNINA_Generic library
  2. WiFi101 using WiFi101 library v0.16.1+
  3. U-Blox W101, W102 using WiFiNINA_Generic library
  4. ESP8266-AT command using WiFiEspAT library
  5. ESP8266/ESP32-AT command using ESP_AT_Lib library and ESP8266_AT_WebServer
  6. ESP32 and ESP8266 WiFi

Currently supported Ethernet shields/modules

  1. W5x00 using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 library
  2. ENC28J60 using EthernetENC or UIPEthernet library
  3. LAN8720 Ethernet used in WT32_ETH01 (ESP32 + LAN8720) boards
  4. Teensy 4.1 built-in Ethernet using NativeEthernet library
  5. Teensy 4.1 built-in Ethernet using QNEthernet library
  6. LAN8742A and LAN8720 using STM32Ethernet and LwIP libraries.


Changelog

Initial Releases v1.0.0

  1. Initial porting and coding to support nRF52, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based boards, besides ESP8266, ESP32 (ESP32, ESP32_S2, ESP32_S3 and ESP32_C3) and WT32_ETH01. Spporting Ethernet shields W5100, W5200, W5500, ENC28J60, Teensy 4.1 NativeEthernet/QNEthernet.


Debug Terminal Output Samples

1. MQTToverWebSocket_QNEthernet on TEENSY 4.1

This is terminal debug output when running MQTToverWebSocket_QNEthernet on TEENSY 4.1 with QNEthernet connecting to test.mosquitto.org MQTT server to demo MQTT over WebSocket by using with WebSockets_Generic library.

Start MQTToverWebSocket_QNEthernet on TEENSY 4.1
MQTTPubSubClient_Generic v1.0.0
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using static IP => Connected! IP address:192.168.2.222
Connecting to WebSockets Server @ test.mosquitto.org
Connecting to mqtt broker.... connected!
MQTT received: /mqttPubSub - Hello from TEENSY 4.1 using QNEthernet
Subcribed to /mqttPubSub => Hello from TEENSY 4.1 using QNEthernet

2. EtherMQTToverWebSocket on MBED RASPBERRY_PI_PICO

This is terminal debug output when running EtherMQTToverWebSocket on MBED RASPBERRY_PI_PICO with W5500 Ethernet connecting to test.mosquitto.org MQTT server to demo MQTT over WebSocket by using with WebSockets_Generic library.

Start EtherMQTToverWebSocket on MBED RASPBERRY_PI_PICO
EthernetWebServer v2.0.2
MQTTPubSubClient_Generic v1.0.0
[EWS] =========== USE_ETHERNET_LARGE ===========
[EWS] Default SPI pinout:
[EWS] MOSI: 19
[EWS] MISO: 16
[EWS] SCK: 18
[EWS] SS: 17
[EWS] =========================
[EWS] RPIPICO setCsPin: 17
_pinCS = 0
W5100 init, using SS_PIN_DEFAULT = 17, new ss_pin = 10, W5100Class::ss_pin = 17
W5100::init: W5500, SSIZE =8192
=========================
Currently Used SPI pinout:
MOSI:19
MISO:16
SCK:18
SS:17
=========================
Using mac index = 17
Connected! IP address: 192.168.2.103
Connecting to WebSockets Server @ test.mosquitto.org
Connecting to mqtt broker...Done connected!
MQTT received: /mqttPubSub - Hello from MBED RASPBERRY_PI_PICO
Subcribed to /mqttPubSub => Hello from MBED RASPBERRY_PI_PICO
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.