Arduino Client for MQTT

This library provides a client for doing simple publish/subscribe messaging with a server that supports MQTT

For more information about MQTT, visit mqtt.org.

Download

The latest version of the library can be downloaded from GitHub.

Documentation

The library comes with a number of example sketches. See File > Examples > PubSubClient within the Arduino application.

Full API Documentation

Compatible Hardware

The library uses the Arduino Ethernet Client api for interacting with the underlying network hardware. This means it Just Works with a growing number of boards and shields, including:

  • Arduino Ethernet
  • Arduino Ethernet Shield
  • Arduino YUN – use the included YunClient in place of EthernetClient, and be sure to do a Bridge.begin() first
  • Arduino WiFi Shield - if you want to send packets greater than 90 bytes with this shield, enable the MQTT_MAX_TRANSFER_SIZE option in PubSubClient.h.
  • Sparkfun WiFly Shield – when used with this library
  • Intel Galileo/Edison
  • ESP8266
  • ESP32

The library cannot currently be used with hardware based on the ENC28J60 chip – such as the Nanode or the Nuelectronics Ethernet Shield. For those, there is an alternative library available.

Author

Nick O'Leary - @knolleary

License

This library is released under the MIT License.

Change History

The complete change history is available on GitHub.

2.7
  • Fix remaining-length handling to prevent buffer overrun
  • Add large-payload API - beginPublish/write/publish/endPublish
  • Add yield call to improve reliability on ESP
  • Add Clean Session flag to connect options
  • Add ESP32 support for functional callback signature
  • Various other fixes