Moving MQTT to the Raspberry Pi

One of the trouble spots with my RV home automation system has been the MQTT server. I know that should be a fairly simple component, but it seems that fairly frequently things will stop working, and the problem is that the MQTT server hung up, or rebooted and didn’t fully restart. I’m currently using an old Mac Mini mounted under my desk, and that’s the problem. Even after experimenting with settings and configuration, I continue to have problems. So I considered and prototyped a couple other options, but each had its own problems. So now I have switch to using a dedicated Raspberry Pi.

Let me clarify that I think that MQTT running on a Mac Mini is awesome, and a very good addition to a home automation system. It’s just that for my RV home automation where the power is constantly being turned on and off as I travel, it tends to be problematic. I’m hoping that a dedicated Raspberry Pi running off the 12 volt system, and doing nothing but running an MQTT broker will be much more robust.

With my recently upgraded cellular modem setup, my internet is pretty reliable and works even when I’m moving down the road. I depend on having a consistent internet connection in order to use Alexa. I’m going to power the Raspberry Pi with a 12v to 5v converter, so the MQTT broker should be always available.

Particle.io Cloud Limits

I would have loved to be able to just switch to using the particle.io cloud for all MQTT messaging, but the number of message permitted on the free plan is only 100k messages per month, which averages out to about 2 messages per minute across all devices. This isn’t enough because I also write timestamp, synchronization, and diagnostic logging messages over MQTT which can greatly exceed this.

Cloud MQTT

I looked at several cloud based MQTT brokers, and most would have some sort of small monthly fee associated with it. These include HiveMQ, Adafruit.io, and Google IoT. But using these didn’t really reduce the complexity of the system, which was a big reason for even exploring this.

Raspberry Pi Zero W

So I decided on using a Raspberry Pi Zero W, and ordered a CanaKit and a 12v to 5v converter for $45 off Amazon. This came with everything I needed, some of which won’t be used once all the software is loaded and configured.

Rapsberry Pi Zero W configured with Mosquitto MQTT broker

So after some simple configuration of the included NOOBs operating system included on the 16 gig SD card, I installed Mosquitto and now have a full-time, dedicated MQTT broker for under $50.

Leave a Reply

Your email address will not be published. Required fields are marked *