Saturday, October 15, 2016

Internet of Things (IoT): Raspberry Pi + DS18B20 + Eclipse KURA + Mosquitto + Eclipse Paho MQTT—PART 3

Next to complete our environment, we set up an MQTT message broker: Eclipse Mosquitto, on a our development machine or even on a separate machine. There are some publicly available message brokers as well, for example, there is one instance of Mosquitto by Eclipse. IBM Bluemix also includes an instance of MQTT broker.

So Eclipse Kura running on Raspberry Pi, will read the temperature from DS18B20 and sends the data as MQTT message to the broker , MQTT clients, which have subscribed for the topic of the message, will receive the data. Following link describes MQTT and provides a good basic understanding.


MQTT primarily belongs Machine to Machine communication and was specifically developed for the purpose, its reliable and resource efficient. I found following resource about the preference of MQTT for Internet of Things (IoT) projects:


Since I am working on Ubuntu I just had to do sudo apt-get install mosquitto to install Mosquitto, that’s it!! There are installers for other OSes here: https://mosquitto.org/download/

In my case on Ubuntu, I created a password file under /etc/mosquitto/ using following command:

sudo mosquito_passwd -c mosquito.pwd user_name

This user is used to configure Eclipse Kura

I also set ‘Protocol’ in /etc/mosquitto/mosquitto.conf as following:

protocol mqtt

Try to run Mosquitto using the following comment:

mosquito -c /etc/mosquitto/mosquitto.conf

If it runs fine, you should a similar output as following:

1476551631: mosquitto version 1.4.8 (build date Fri, 19 Feb 2016 12:03:16 +0100) starting
1476551631: Config loaded from mosquitto.conf.
1476551631: Opening ipv4 listen socket on port 9001.
1476551631: Opening ipv6 listen socket on port 9001.
1476551631: Opening ipv4 listen socket on port 1883.
1476551631: Opening ipv6 listen socket on port 1883.

Next we need to configure Eclipse Kura with Mosquitto, instructions for doing so can be found on the following link:

No comments: