Setting up an MQTT broker

With all of the sensor and data generating projects that I’m working on, I figured that it would be worthwhile to get a centralized system setup for managing all of the data collected.  After some research, I found MQTT, a nifty little message brokering protocol that seemed to be particularly useful and very scale-able/extensible.  I also discovered that I could run an open source implementation of the broker called mosquitto using OpenWRT on a spare TP-Link TL-WR1043ND router I had.  I’m not sure what the previous firmware on the router was, so I’ll start by doing a fresh installation of the firmware, then setup the MQTT broker, then do a bit of testing.

Step 1: Clean OpenWRT Install

To begin, I downloaded the OpenWRT firmware for the specific router and reflashed my router.  All of the instructions and download information for this can typically be found on the OpenWRT site.  I had an additional challenge of already having DD-WRT installed, so I followed the instructions written by Sam Hobbs here.  These instructions worked flawlessly and I was able to quickly revert my router back to the factory firmware and then install OpenWRT with no trouble at all.

Step 2: Install Mosquitto

This was also fairly straightforward.  The web interface for the router has a list of available packages, one of which was mosquitto, so I installed it.  The version available only supports MQTT v3.1, so at some point I’ll have to get an updated version installed for MQTT 3.1.1 .

Step 3: Configure Mosquitto

For the test configuration, I followed the instructions written by petrevski here.

Step 4: A quick test

After finishing the configuration, I then installed the windows binary of mosqitto onto my computer and used the mosquitto_pub and mosquitto_sub to subscribe to all topics in one command window and publish from another.

The test went well, I was able to see the subscribed messages without any issue.  I was very impressed with how straightforward and quick this setup was.  I’ve now got to build some sensors that can publish and subscribe as needed.  I will also setup the router more permanently (not the quick benchtop jumble of wires) and merge it into the current wifi network I already have setup, ideally as an AP extender as well.


One thought on “Setting up an MQTT broker

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s