MQTT From scratch

I am looking at installing MQTT from scratch on a minimal install using emonhub, Pi Board and an EmonTX.

The instructions say to install the "MQTT message broker".  I think this has been as simple as apt-get install mosquitto. checking the service it seems to be running.  However, a test command I found mosquitto_sub -h localhost -v -t "\$SYS/#" does not work (mosquitto_sub: command not found).

However, the instructions seem to be for an init.d setup and as I understand it Jessie uses systemd (though I may be off base on this one).  I am unclear if there is a difference. Will these instructions work on Jessie?

Is there anything else to look for?

Brian.

dBC's picture

Re: MQTT From scratch

I think in most distros the broker is in the mosquitto package and the test clients (mosquitto_sub and mosquitto_pub) are in a separate package called mosquitto-clients.   So you could try:

apt-get install mosquitto-clients

Paul Reed's picture

Re: MQTT From scratch

The 'instructions' have been written with Jessie in mind, but compatible with Wheezy.

Paul

borpin123's picture

Re: MQTT From scratch

Spot on (install clients package).

Many thanks. Brian

borpin123's picture

Re: MQTT From scratch

Progress :)

The weather station data is being published by pywws and mosquitto is picking it up.  EmonCMS is detecting the node but not the values of the data.

The message looks like this (mosquitto_sub -v -t 'rx/20')

rx/20 {"rel_pressue": "29.5890", "wind_ave": "7.61", "rain": "0.6", "rainin": "0.023622", "hum_in": "60", "temp_in_f": "66.7", "dailyrainin": "0.413386", "wind_dir": "90", "temp_in_c": "19.3", "hum_out": "68", "dailyrain": "10.5", "wind_gust": "11.41", "idx": "2015-12-04 16:50:18", "temp_out_f": "51.4", "temp_out_c": "10.8"}

Is EmonCMS expecting the data in a specific format?  Specifically the time?  I have had issues with the JSON format before when passing the data via an API call.

Previously the format was;

{'time' : "seconds", 'json' : 'data'}

Is this the required format?

Cheers, Brian.

Paul Reed's picture

Re: MQTT From scratch

No, it accepts comma-delimited values only, such as rx/20 {24,48,764,88,436}
No labels! you add those in the emoncms inputs page.

Paul

borpin123's picture

Re: MQTT From scratch

Hi Paul, the issue is that the system I am using will not send on the payload unless it is valid JSON.

I've moved this to a new thread http://openenergymonitor.org/emon/node/11775

Cheers, Brian

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.