| 2 |
raymond |
1 |
# Arduino Client for MQTT
|
|
|
2 |
|
|
|
3 |
This library provides a client for doing simple publish/subscribe messaging with
|
|
|
4 |
a server that supports MQTT.
|
|
|
5 |
|
|
|
6 |
## Examples
|
|
|
7 |
|
|
|
8 |
The library comes with a number of example sketches. See File > Examples > PubSubClient
|
|
|
9 |
within the Arduino application.
|
|
|
10 |
|
|
|
11 |
Full API documentation is available here: https://pubsubclient.knolleary.net
|
|
|
12 |
|
|
|
13 |
## Limitations
|
|
|
14 |
|
|
|
15 |
- It can only publish QoS 0 messages. It can subscribe at QoS 0 or QoS 1.
|
|
|
16 |
- The maximum message size, including header, is **256 bytes** by default. This
|
|
|
17 |
is configurable via `MQTT_MAX_PACKET_SIZE` in `PubSubClient.h` or can be changed
|
|
|
18 |
by calling `PubSubClient::setBufferSize(size)`.
|
|
|
19 |
- The keepalive interval is set to 15 seconds by default. This is configurable
|
|
|
20 |
via `MQTT_KEEPALIVE` in `PubSubClient.h` or can be changed by calling
|
|
|
21 |
`PubSubClient::setKeepAlive(keepAlive)`.
|
|
|
22 |
- The client uses MQTT 3.1.1 by default. It can be changed to use MQTT 3.1 by
|
|
|
23 |
changing value of `MQTT_VERSION` in `PubSubClient.h`.
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
## Compatible Hardware
|
|
|
27 |
|
|
|
28 |
The library uses the Arduino Ethernet Client api for interacting with the
|
|
|
29 |
underlying network hardware. This means it Just Works with a growing number of
|
|
|
30 |
boards and shields, including:
|
|
|
31 |
|
|
|
32 |
- Arduino Ethernet
|
|
|
33 |
- Arduino Ethernet Shield
|
|
|
34 |
- Arduino YUN – use the included `YunClient` in place of `EthernetClient`, and
|
|
|
35 |
be sure to do a `Bridge.begin()` first
|
|
|
36 |
- Arduino WiFi Shield - if you want to send packets > 90 bytes with this shield,
|
|
|
37 |
enable the `MQTT_MAX_TRANSFER_SIZE` define in `PubSubClient.h`.
|
|
|
38 |
- Sparkfun WiFly Shield – [library](https://github.com/dpslwk/WiFly)
|
|
|
39 |
- TI CC3000 WiFi - [library](https://github.com/sparkfun/SFE_CC3000_Library)
|
|
|
40 |
- Intel Galileo/Edison
|
|
|
41 |
- ESP8266
|
|
|
42 |
- ESP32
|
|
|
43 |
|
|
|
44 |
The library cannot currently be used with hardware based on the ENC28J60 chip –
|
|
|
45 |
such as the Nanode or the Nuelectronics Ethernet Shield. For those, there is an
|
|
|
46 |
[alternative library](https://github.com/njh/NanodeMQTT) available.
|
|
|
47 |
|
|
|
48 |
## License
|
|
|
49 |
|
|
|
50 |
This code is released under the MIT License.
|