https://github.com/knolleary/pubsubclient
A client library for the Arduino Ethernet Shield that provides support for MQTT.
https://github.com/knolleary/pubsubclient
Last synced: 5 days ago
JSON representation
A client library for the Arduino Ethernet Shield that provides support for MQTT.
- Host: GitHub
- URL: https://github.com/knolleary/pubsubclient
- Owner: knolleary
- License: mit
- Created: 2009-02-02T11:07:58.000Z (over 17 years ago)
- Default Branch: master
- Last Pushed: 2026-06-10T11:54:58.000Z (5 months ago)
- Last Synced: 2026-09-22T18:25:43.587Z (about 1 month ago)
- Language: C++
- Homepage: http://pubsubclient.knolleary.net/
- Size: 280 KB
- Stars: 4,015
- Watchers: 204
- Forks: 1,503
- Open Issues: 567
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.txt
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-cpp - knolleary/pubsubclient - A client library for the Arduino Ethernet Shield that provides support for MQTT. (Other / Scientific Computing)
- awesome-mqtt - pubsubclient - A client library for the Arduino Ethernet Shield that provides support for MQTT. (Interfaces / Makers)
- Awesome-arduino - pubsubclient - A client library for the Arduino Ethernet Shield that provides support for MQTT (Libraries)
- awesome-arduino - pubsubclient - A client library for the Arduino Ethernet Shield that provides support for MQTT (Libraries)
- awesome-iot - PubSub Client ★ 684 ⧗ 0 - A client library for the Arduino Ethernet Shield that provides support for MQTT. (Protocol Library / MQTT)
- awesome_iot - PubSub Client ★ 684 ⧗ 0 - A client library for the Arduino Ethernet Shield that provides support for MQTT. (Protocol Library / MQTT)
- awesome-arduino - pubsubclient - A client library for the Arduino Ethernet Shield that provides support for MQTT (Libraries)
README
> [!CAUTION]
> This library is not maintained. It was my first 'popular' Open Source project, and brought MQTT
> to the Arduino platform just as both were gaining popularity.
>
> But times have changed, and I haven't needed to use it for a long time now. This means I simply
> don't have the setup locally to properly develop, test and maintain the library.
> Alternative libraries exist and I urge you to pick one that is actively maintained.
>
> So Long and Thanks For All The PUBACKs
>
> Nick
> 2026
# Arduino Client for MQTT
This library provides a client for doing simple publish/subscribe messaging with
a server that supports MQTT.
## Examples
The library comes with a number of example sketches. See File > Examples > PubSubClient
within the Arduino application.
Full API documentation is available here: https://pubsubclient.knolleary.net
## Limitations
- It can only publish QoS 0 messages. It can subscribe at QoS 0 or QoS 1.
- The maximum message size, including header, is **256 bytes** by default. This
is configurable via `MQTT_MAX_PACKET_SIZE` in `PubSubClient.h` or can be changed
by calling `PubSubClient::setBufferSize(size)`.
- The keepalive interval is set to 15 seconds by default. This is configurable
via `MQTT_KEEPALIVE` in `PubSubClient.h` or can be changed by calling
`PubSubClient::setKeepAlive(keepAlive)`.
- The client uses MQTT 3.1.1 by default. It can be changed to use MQTT 3.1 by
changing value of `MQTT_VERSION` in `PubSubClient.h`.
## 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 > 90 bytes with this shield,
enable the `MQTT_MAX_TRANSFER_SIZE` define in `PubSubClient.h`.
- Sparkfun WiFly Shield – [library](https://github.com/dpslwk/WiFly)
- TI CC3000 WiFi - [library](https://github.com/sparkfun/SFE_CC3000_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](https://github.com/njh/NanodeMQTT) available.
## License
This code is released under the MIT License.