Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

using mosquitto client commands with io.adafruit.com
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

using mosquitto client commands with io.adafruit.com

by dutchfarmer on Mon Apr 11, 2016 6:19 pm

Hi Folks,

Doing a quick evaluation of the adafruit service compared to mosquitto runing on my RPI. My preference is to use a cloud based mqtt server instead of having to host it in my home network.

With this in mind, I am trying to get the basic mosquitto client commands working with io.adafruit.com.

Here are some of my variables:

username: dutchfarmer
password (AIO Key) : xxxxxxx1dba9dc3ac1f8d94fa948cc19bd8e67de
feed created: temperature

I have two command terminals up. One for subscribing and one for publishing. While I get no authentication errors, I can not get and data to pass from mosquitto_pub to mosquitto_sub. Here are the commands I am using:

mosquitto_sub -h io.adafruit.com -u dutchfarmer -P xxxxxxx1dba9dc3ac1f8d94fa948cc19bd8e67de -t /dutchfarmer/feeds/temperature/ -p 1883

mosquitto_pub -h io.adafruit.com -u dutchfarmer -P xxxxxxx1dba9dc3ac1f8d94fa948cc19bd8e67de -t /dutchfarmer/feeds/temperature/ -p 1883 -m "11.3"

A couple of questions:

1. Is it necessary to use the -i parameter to differentiate between the pub and sub sessions?
2. What is the format of the topic. The documentation at https://learn.adafruit.com/adafruit-io/arduino is extremely vague. There are references to /feeds/feed-name/ and Mosfet/feeds/Photocell. More clarity needs to be made in the documentation.

Any help is greatly appreciated. Over all, I like the way is structured. It is a bit more simple than the PubNub service but I would simply like to get the basic MQTT elements working.

Any tips are appreciated.

Thanks,

D-

dutchfarmer
 
Posts: 8
Joined: Mon Apr 11, 2016 3:25 pm

Re: using mosquitto client commands with io.adafruit.com

by grprado on Tue Apr 12, 2016 3:31 am

Hi,

You don't need the -i parameter,

Topic should be written as:
dutchfarmer/feeds/temperature

Try this
mosquitto_sub -h io.adafruit.com -u dutchfarmer -P xxxxxxx1dba9dc3ac1f8d94fa948cc19bd8e67de -t dutchfarmer/feeds/temperature -p 1883

and
mosquitto_pub -h io.adafruit.com -u dutchfarmer -P xxxxxxx1dba9dc3ac1f8d94fa948cc19bd8e67de -t dutchfarmer/feeds/temperature -p 1883 -m "11.3"

You may even add a 'Stream Block' on your IoT Dashboard and see the data passing by...

Best.

grprado
 
Posts: 3
Joined: Sat Nov 21, 2015 5:39 am

Re: using mosquitto client commands with io.adafruit.com

by dutchfarmer on Tue Apr 12, 2016 4:34 am

Thanks grprado for the quick reply.

I finally got it working. The confusion is in the Feeds definition. I was using the "key" value but it seems that the "name" value is required. Initially I configured the Name as a human readable title with spaces. I just made all of the Names the same as the keys. Just so I am clear, what purpose does the ID and key serve from an API perspective? It seems like something in the Ux that should be better clarified.

In summary, here is the solution to the Feed/Topic naming convention:

username/feeds/feed name

- there is no preceding slash in front of username
- feeds is a literal
- feed name actually maps to the Name of the feed. Not the Key.


D-

dutchfarmer
 
Posts: 8
Joined: Mon Apr 11, 2016 3:25 pm

Please be positive and constructive with your questions and comments.