Jump to content









Photo

Controlling Arduino from Carriots

Arduino MQTT

  • Please log in to reply
No replies to this topic

#1 NicMinnaar

NicMinnaar

    Newbie

  • 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!







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

2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users