MQTT5 (community library)


Name Value
Name MQTT5
Version 1.0.1
Installs 1701
License MIT
Author Thomas Peroutka
Download .tar.gz
All Versions 1.0.1, 1.0.0

Example Build Testing

Device OS Version:

This table is generated from an automated build. Success only indicates that the code compiled successfully.

Library Read Me

This content is provided by the library maintainer and has not been validated or approved.

MQTT5 for Particle Device OS

A particle library for MQTT5. MQTT5 supports publish/subscribe and request/response pattern. The packet exchange happens asynchronous.


The following features are coverd by this library:

  • Publish/Subscribe messages
  • Quality of Service
  • Retained Messages
  • Keep Alive
  • Username/Password authentication
  • Last Will and Testament
  • Session and Message Expiry Intervals
  • Topic alias
  • Better error handling (negative ACKs)
  • Additional properties for Connect and Publish (Maximum Packet Size & Server Keep Alive, ...)

Not yet implemented:

  • Challenge-Response authentication
  • Request/Response messages
  • User Properties


This library builds heavily on TCPClient library from Particle Device OS. If you use Particle Device OS you are good to go.


See the examples folder.


Change packet size or get "Packet exceeds max packet size"?

Change the maximum packet size in the construct.

MQTT5 client; // Default max packet size
MQTT5 client(512); // 512 bytes max packet size

Message gets truncated

If you send binary data make sure you use the method where you can specify the length.

I get disconnected when publishing

Make sure your topic string contains only valid characters. Some servers disconnect immediately if they receive malformed packets.

I get disconnected after some time

Make sure you periodically call loop().

Something weird is happening

Make sure you are using the latest Device OS version. Make sure your flased Device OS version matches your building version.


To enable logging you have to declare a SerialLogHandler and start the serial port:

SerialLogHandler logHandler(LOG_LEVEL_NONE, {

void setup() {

To further increase the amount of logs you can add in MQTT5.h:

#define MQTT5_DEBUG


Feel free to open issues and pull requests.


Copyright 2020 Thomas Peroutka

Licensed under the MIT license

Browse Library Files