Skip to main content

Cayenne MQTT Python Library

Project description

The Cayenne MQTT Python Library provides functions to easily connect to the Cayenne IoT project builder. With it you can send data to and receive data from Cayenne.


Getting Started


This library can be installed using pip:

pip install cayenne-mqtt

It can also be installed from the repository:

git clone
cd Cayenne-MQTT-Python
python install

Cayenne Setup

  1. Create your Cayenne account at
  2. Add a new device using the Bring Your Own Thing API selection.


Simple examples are available in the repository here:

Below is an example of a simple client that publishes some sample data and receives data from Cayenne in a message callback. The Cayenne authentication variables must be modified with the authentication info you received when adding a new device in Cayenne:

import cayenne.client
import time

# Cayenne authentication info. This should be obtained from the Cayenne Dashboard.

# The callback for when a message is received from Cayenne.
def on_message(message):
  print("message received: " + str(message))
  # If there is an error processing the message return an error string, otherwise return nothing.

client = cayenne.client.CayenneMQTTClient()
client.on_message = on_message
# For a secure connection use port 8883 when calling client.begin:

timestamp = 0

while True:

  if (time.time() > timestamp + 10):
    client.celsiusWrite(1, i)
    client.luxWrite(2, i*10)
    client.hectoPascalWrite(3, i+800)
    timestamp = time.time()
    i = i+1


For more detailed info about the Cayenne client API you can use pydoc.

pydoc cayenne.client

Additional Cayenne MQTT Libraries

Additional libraries are available for connecting to Cayenne with other languages. These can be found at

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cayenne-mqtt, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size cayenne-mqtt-1.1.0.tar.gz (5.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page