Jump to content


Controlling Arduino from Carriots

Arduino MQTT

  • Please log in to reply
3 replies to this topic

#1 NicMinnaar



  • Members
  • Pip
  • 1 posts

Posted 01 December 2017 - 12:10 PM

Hey guys!


I've got a project where I'm using multiple Arduino's and sensors to measure variables such as humidity, temperature and light sensitivity. These measured variables are then to be published to Carriots, and depending on certain thresholds and limits, will then send necessary data to another Arduino (let's call it the output Arduino), which will then control various servo motors, LED's etc. depending on the data received from Carriots. Essentially I want to control an Arduino using other Arduino's through Carriots instead of using conventinal I2C or other wiring methods.


I've been trying both MQTT as well as http protocols, both with varying success. 


1. With MQTT I can publish to the Carriots stream easily enough, but i would like to publish this data to a topic so my output arduino can subscribe to the topic and have access to that data. I have seen a lot of MQTT examples explaining how to publish to the "/stream" topic and thus publish data to the carriots stream, but nothing on how to publish to a topic from within Carriots (I assume you would use a listener and a rule similar to this post: http://forum.carriot...rigger#entry192 ). So my first question is: How do I publish to a topic from Carriots? Would I have to set up a topic using something like the Mosquito mqtt broker? Or can I use one of the Carriots built-in topics?

I can subscribe to a topic from my Arduino's so all I need is a way to publish to a topic using the SDK. This would be first prize for me since I'd prefer to complete the project with MQTT.


2. With http I've got the same problem; I can post data onto carriots from my arduino, but can't GET the data to control my output arduino.

I tried implementing the code used in this thread: { http://forum.carriot...ino/?hl=arduino } ,but I don't understand how this data is extracted and in what format it would be: will it be in JSON format or is there a library instance that I can call to just use the necessary values (something similar to the context.data used in the SDK perhaps?) 

I also tried the tips and code discussed here: { http://forum.carriot...rigger#entry192 }

and even though I can  see the "other device" (in my case the output arduino) receives something, the data only appears in the data stream, not on the actual output arduino. I know this because I implemented this code on two devices and linked them, and both posted to the stream so I know it's working. All I need now is a way to pull that data from the stream.


I can post the code I've been trying, along with serial outputs and what appears in my data stream, if anyone thinks it will help. 

Any help, suggestions or examples will be greatly appreciated!

#2 jpastor


    Development leader

  • Administrators
  • 181 posts

Posted 26 December 2017 - 11:35 AM

Hi NicMinnaar

Carriots provides two different MQTT brokers:
- mqtt.carriots.com -> To send data streams to Carriots platform, it is an alternative to HTTP. All the information you send using this broker enters the usual flow of Carriots, launching listeners, etc ...
more info: https://www.carriots...mentation/mqtt#

-mqttbroker.carriots.com -> A specific broker to share information as you need. All the information you send using this broker does not enter in the usual flow of Carriots. It is only used for your own requirements, like share information between devices.
This bloker is only available for payment accounts, but if you send an email to support, they usually activate it for evaluation
more info: https://www.carriots...ots-mqtt-broker

In my opinion you need to use the last one to share information between devices using MQTT.
To publish information from a Carriots Listener in this broker, you can use this library: https://www.carriots...lity_libraries#



Hope it helps!

#3 sreejith.nair



  • Members
  • Pip
  • 6 posts

Posted 25 February 2018 - 04:45 PM

Hi I am using Arduino with PubSubclient.h to connect to the carriots.

and i successfully connected and published the data to a stream topic. 

by using following call i am establishing a connection with carriots and after that i am publishing the data.

1. mqtt_client.setServer( mqtt.carriots.com, 1883 );



Now i tried with mqttbroker.carriots.com with the same port, but i am not able to establish a connection with carriots. 

It's returning a packet error. 

I am using a corporate account. 

My connect call is not returning success, Please guide me to solve it.

#4 sreejith.nair



  • Members
  • Pip
  • 6 posts

Posted 01 March 2018 - 09:29 AM

Hi ,

it's solved 

1. mqtt_client.setServer( "mqttbroker.carriots.com", 1883 );



user name and password should be used for mqttbroker.carriots.com instead of apikey and password 

Also tagged with one or more of these keywords: Arduino, MQTT

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users