Okay, first off this is a helper for me to remember what I did to get rolling with Mosquitto. If you find it useful great and if not great. This info is based off a few Mosquitto articles on the web that I put together as what worked best for me. I did most of this research originally for my Raspberry Pi but this works well with the ODROID-C1 as well. I will post all my reference links at the bottom of this article.
Let me also state that I personally prefer to have packages that are updated by a repository that I don’t have to compile over and over every time there is an update. If you would rather have the control and compile your own version, scroll down past the instructions and click on the xAppsSoftware Blog link.
If you’re better with video tutorials follow this one from Ben with Bruh Automation:
YouTube MQTT Install
With all that said let’s get started.
To begin open your Linux Terminal.
Grab the Mosquitto.org repo key:
Add the Mosquitto.org repo key to your ODRIOD-C1:
sudo apt-key add mosquitto-repo.gpg.key
Go to your apt sources.list.d folder:
Download the Mosquitto.org repo list for apt sources use:
# Old way
#sudo wget http://repo.mosquitto.org/debian/mosquitto-repo.list
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
Update your apt sources:
sudo apt update
Finally, the reason you made it this far …
sudo apt install -y libwebsockets8 mosquitto mosquitto-clients
Note: If using Python MQTT you will want to install “paho-mqtt” through pip. e.g. pip install paho-mqtt
So it might be a good idea to test all this right?!?
In your current Terminal type the following to begin your test:
mosquitto_sub -h 127.0.0.1 -t '#'
Open a second / new Terminal and type the following to see if your test worked!
mosquitto_pub -h 127.0.0.1 -t testTopic -m "Testing 1. 2. 3."
Want to add username / password to your MQTT Broker? Here is an example of my mosquitto.conf file:
port 1883 localhost
listener 8883 localhost
Password file example:
So the password file is hashed. Here is a nice tutorial on how to hash your Mosquitto passwords. (Just don’t run the hash command twice, like I did! It will do a second hash on your hashed password!)
Reference Material a.k.a. where the real info above originated from!
xAppsSoftware Blog – Mosquitto Tutorial
Hardware Hacks Blog