Cayenne MQTT Arduino Library
Clone or download
Latest commit 099fd57 Nov 14, 2018

Cayenne MQTT Arduino Library

The Cayenne MQTT Arduino Library provides functions to easily connect to the Cayenne IoT project builder. This library is designed to work with Arduino, ESP8266 and ESP32 devices. With it you can send data to and receive data from Cayenne.

alt text

Arduino Uno image by SparkFun is licensed under CC BY 2.0

alt text

Adafruit HUZZAH ESP8266 image by lady ada is licensed under CC BY-SA 3.0

alt text

SparkFun ESP32 Thing image by SparkFun is licensed under CC BY 2.0




Getting Started

Environment Setup

  1. Download and install the Arduino IDE.
  2. Install the CayenneMQTT library from Sketch -> Include Library -> Manage Libraries.
  3. If using an ESP module, install the Board Package.
    1. For ESP8266:
      1. Under File -> Preferences add to the Additional Boards Manager URLs field.
      2. Install the esp8266 platform from Tools -> Board -> Boards Manager.
    2. For ESP32, manually install the board package by following the instructions here:
  4. Connect your device to your computer using the appropriate USB cable or USB to Serial FTDI cable.
  5. Select your Arduino board or ESP module and and the correct port from the Tools menu.

Cayenne Setup

  1. Create your Cayenne account at
  2. Add a new device using the Add new... page MicroControllers or Bring Your Own Thing options.

Building Examples

  1. Open an included example connection sketch from File -> Examples -> CayenneMQTT -> Connections.
  2. Modify the included sketch with the Cayenne authentication info you received when adding your device.
  3. If using an ESP module or WiFi shield modify the sketch with your network info.
  4. Compile and upload the sketch to your device. For ESP devices uploading may require setting the device into bootload mode. For the Adafruit HUZZAH ESP8266 module this is done with the folowing steps:
    1. Hold down the GPIO0 button.
    2. Click the Reset button.
    3. Let go of the GPIO0 button.
    4. The red LED should light up, indicating the device is ready for uploading.
    5. Upload your sketch.
  5. Check the Cayenne dashboard to ensure it is receiving sample data from your device.


This library was tested with various Arduino boards including the Uno, Mega, Due, etc. as well as the Adafruit HUZZAH ESP8266 breakout module and an Espressif ESP32 development board. It should also work with other standard ESP8266 and ESP32 modules that are compatible with the Arduino IDE. Boards with very constrained memory like the Arduino Leonardo or Micro may have issues fitting this library alongside other libraries. For those boards you might try using a manually specified IP as shown in the ManualConnection example sketch in order to save space.


Cayenne MQTT Libraries

Additional libraries are available for connecting to Cayenne on other platforms and devices. These can be found at