As i mentioned in the introduction i am waiting for parts to arrive. Meanwhile i started to set up my MQTT infrastructure.


My initial plan was to use the sandboxed MQTT Broker available at at port 1883. Then i decided to explore more about the MQTT Broker and wanted to run one locally on my PC and use it as the MQTT gateway for all my needs. Since the Mosquitto broker allows bridging, it should be possible for me to selectively choose “topics” to forward to one or more of sandboxes available on the internet.



The sandboxed MQTT broker above is running the Open Source Mosquitto broker in its version 1.3.1. So i got the broker for windows downloaded from and installed. After the installation is complete, I could see the Mosquitto Broker services in the control panel. I found that the service is not started by default so i started the service.

I also went ahead and installed the Mosquitto broker on my Mac. This way i can test the bridge functionalities locally. In addition this allows me to make my PCs as MQTT Publishers and subscribers. The audio elements in my project will run from my Mac or PC by subscribing to the appropriate MQTT topic.

When i get my Arduino Yun, it should be possible for me to run the Mosquitto broker on the Yun as well since a OpenWrt version is available at the same download url.


Verifying the Install

In the install directory, there were two handy utilities that were available.

  • mosquitto_sub  — A command line utility for subscribing to Topics
  • mosquitto_pub  — A command line utility for publishing simple messages one at a time


On Mac these were available at:



On PC these were available at:

C:\Program Files (x86)\mosquitto


Running mosquitto_sub


First i ran the mosquitto_sub with the wild card “#” for the topic name in one terminal window. This allowed me to watch every message that is being sent to my gateway. This will be very useful if i run into issues later in the project and need to debug.

mosquitto_sub -h localhost -v -t "#"

-v is for making the output verbose. This will print the Topic name as well along with the actual message payload.


Running mosquitto_pub

Then i opened another terminal window and ran the mosquitto_pub to send some test messages out.

mosquitto_pub -t WiFiTree/RGB -m "210,230,0"

mosquitto_pub -t WiFiTree/RGB -m "0,0,0"

mosquitto_pub -t WiFiTree/Sound -m "0.2"

I could see that the setup is working correctly when the outputs started appearing in the subscriber window. Here are the screen shots for both Subscriber and publisher.








Setting up the Bridge on Mac to forward certain topics to MQTT Bridge on PC


Before setting up the bridge to sandbox brokers on the net, i wanted to set up the bridge between my broker on Mac and PC. This would allow me to bring these machines also in to my holiday project infrastructure to play sound and other things that i have not thought of yet. There isn’t any specific need for me to run multiple brokers. But i just wanted to test out the capability because some day it might come handy.


So on Mac i modified the well documented mosquitto configuration file at



and added the following:

connection mywindowsmqttbroker
topic WiFiTree/ForWindowsPC/Test


This configuration should enable the MQTT broker on Mac to forward only the MQTT messages with the topic  "WiFiTree/ForWindowsPC/Test” to my windows PC.


After the configuration change I restarted my mosquito demon and sent out some test messages from my mac:

mosquitto_pub -t WiFiTree/ForWindowsPC/Test -m "Test MQTT bridge message for Windows From Mac"


Success!!!. i was able to see that my Windows PC was receiving only those topics from mac.



Now that my MQTT brokers are set up the way i want, each of the modules of my WiFi Christmas Tree project can be individually tested and put together.


Some thought for future exploration


As many of you might have already done, the routers can be modified to run OpenWrt. Since a openWrt version of MQTT broker is available, the router might be the right place to run a home specific MQTT broker. I hope someday router manufacturers by default will put a MQTT broker on their products making it easier for deploying connected devices. My router is not modified to run openWrt. One day i will get around to do that.


Document Links