How to send a stream using MQTT

This tutorial will show how to send data streams to Carriots with MQTT.

First, we need to know what we want to send and how to send it. Data is sent to Carriots REST API. You need:

  • A device in Carriots
  • A valid Apikey
  • Your data
  • A MQTT client

If you're registered in Carriots, you have a default device already created for you.
Check your control panel and see what it looks like.
Basically you need the device id_developer that might be something like defaultDevice@myusername.

Now, go to your control panel “My account menu” and check your Apikey.
Its a big alphanumeric token like 98346673a6377ef1fde2357eeaae0da582b150b00cabcd5a0d83045425407ab4.
Now we define our data. It will be a simple data set with temperature and humidity:

Finally we need a MQTT client. In this case we are going to use the Paho Python Client (http://www.eclipse.org/paho/clients/python/). Note that If you want to use SSL you must download a certificate, you can download it here.

Once you have installed the library on your system you can use this example:

Remember that, unlike the HTTP api, MQTT will not send back a response, you can go to the control panel and see the stream sent. You will find more examples and implementations of the Paho client here.