Arduino Client for MQTT
This library provides a client for doing simple publish/subscribe messaging with a server that supports MQTT.
- It can publish QoS 0/1/2 messages and subscribe at QoS 0 or QoS 1.
- Can join session on connect without cleaning it (cleanSession=false). Which means that network issues (causing disconnects) are not a problem to receive the unread messages.
- The maximum message size, including header, is 512 bytes by default. This
is configurable via
- The keepalive interval is set to 15 seconds by default. This is configurable
- The client uses MQTT 3.1.1 by default. It can be changed to use MQTT 3.1 by
changing value of
The library comes with a number of example sketches. See File > Examples > PubSubClient within the Arduino application.
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
YunClientin place of
EthernetClient, and be sure to do a
- Arduino WiFi Shield - if you want to send packets > 90 bytes with this shield,
- Sparkfun WiFly Shield – library
- TI CC3000 WiFi - library
- Intel Galileo/Edison
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.
This code is released under the MIT License.