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.

Upgrading Our Internet

After spending a full month on the road in the RV, and returning home to a broken park internet, it because clear that we needed a more robust internet solution.

Our Current Setup

For this trip we had been using:

  1. Verizon 75G phone plans on both our iPhones (each with 30 GB hotspot)
  2. Verizon Jetpack 15 GB hotspot as backup
  3. AT&T 100G plan on an old iPhone 6 (with 30 GB hotspot)
  4. Sprint/T-Mobile LinkZone 2 unlimited hotspot.

This provided us with a lot of data on multiple carriers, but was pretty labor intensive selecting which device(s) worked, monitoring the bandwidth, switching as we moved, etc. We also had to be very careful to not burn through all our data when watching TV, movies, etc. Since we had a lot more data available on our phone than via hotspot, we tried connecting our TV to the phones as an external display, but this made for a very frustrating experience. We ended up needing to reconnect and/or restart frequently, not to mention getting tangled up in the HDMI and power cables strung across the room.

New Hardware

So after doing a lot of research when we got home, I came to the conclusion that the absolute best solution for working remotely, full time RVers like us would be the MobileMustHave.com Ultimate Road Warrier package. This package includes a Pepwave Transit Duo mobile router and a Parsec 7-in-1 roof antenna. It is one of the most expensive packages, at around $1,500, but has an amazing set of capabilities.

The mobile router has 2 cellular receivers built in, with 2 SIM slots each (4 SIM slots total). This allows automatically selecting the carrier that works best, and failing over to another carrier when one isn’t working. It can also do some really fancy things like ‘bonding’ both receivers to double the cellular bandwidth for a single connection.

Best of all, a lot of things can be configured to happen automatically, such as limiting each SIM to a specified bandwidth and data cap, then rolling over to the next SIM. And the status, bandwidth, and data usage can be reviewed and modified in one place.

Both are 12v powered, so the entire setup will continue to work either parked or while moving down the road.

I can’t even begin to describe all that this setup can do, so I’ll just refer you to the MobileMustHave website. They have a lot of videos there and on their Youtube channel.

Data Plans

So having picked a dual cellular mobile router, I’d need a couple hotspot data plan SIMs. Searching for high capacity data plans took a lot of investigation also. The information available from the Mobile Internet Resource Center as well as MobileMustHave.com was very helpful, and helped steer me away from some “too good to be true” plans. I want fairly reliable plans so I don’t have to spend a lot of time interacting with support when the plans just stop working.

During our travels, both Verizon and AT&T had very good coverage. My Sprint/T-Mobile hotspot didn’t do as well. I believe their coverage is better up north, but this past trip was across the south. So I was leaning towards Verizon and AT&T.

Since we already have Verizon plans for our phones, a good choice for us is the hotspot add-on to our plans. For $15 we could get a separate 30 GB hotspot SIM. We had previously added a Jetpack on an older plan that gave us 15 GB for $10/month. So I upgraded it to the 30 GB for $15/month plan, and added a second one for our other line. So that gave me two SIMs providing 30 GB each.

I really wanted AT&T plans for the other 2 slots. At first look, the AT&T plans were quite expensive, and didn’t provide a lot of data. But then I came across their Prepaid plans. Wow. They offer 100 GB prepaid hotspot plans for $55/month. So I got two of those also.

So now I have 2 x 100 GB AT&T for my primary carrier, with 2 x 30 GB Verizon backup/rollover. These can both be configured using Peplink SpeedFusion to provide double the bandwidth if/when needed. I’ll be checking into that later, but for now I think my cellular capability is good.

Controlling Data Usage

As I mentioned above, one of the frustrating aspects of using cellular data is having to monitor our usage, and adjust things to avoid running out of data. The Pepwave router makes this very easy. It has provisions for monitoring usage, throttling bandwidth on a per device or user group basis, and turning off or rolling over to another service when a threshold is reached.

I’ve been experimenting with the amount of bandwidth needed for our TV, and have been surprised. Left in its default state, watching TV can consume way over 10 Mbps, which results in over 10 GB per day with as much video as we often stream in the evenings. So I used the Pepwave advanced settings to limit bandwidth to the TV to smaller and smaller bandwidths. I had expected that as I dropped below 8 Mbps the picture would noticeably deteriorate, and become unusable below about 5 Mbps.

But what I found was that the picture was still pretty good with the bandwidth limited to 3 Mbps.

Wifi as WAN

The icing on the cake for this device is the ability to connect to a park’s Wifi and use it as an input to the router. The Wifi at each new park we visit can be quickly configured and used instead of cellular if needed.

StarLink

I’m currently signed up to receive StarLink when it becomes available later this year, but I’m thinking I may not need it. Equipment is $499 up front and doesn’t appear RV friendly, monthly fees are $99, the service area is limited to a specific local “cell”.

Maybe in the future they will offer an RV friendly plan, but until then I’ll probably stick with cellular plus park Wifi.

Two Weeks in Tampa, Florida

Our two weeks in Tampa were wonderful. Our daughter Jackie helped us find an RV park that was close to her, and it was very nice. We were able to get together with Jackie every day.

Saturday we toured Ybor City, eating a Cuban sandwich and watching them make cigars.

On the return trip we stayed for a week at an RV park right on the Mississippi. There was a constant stream of tugboats pushing strings of barges up and down the river.

It was the oddest sensation hearing them going by. They sounded a lot like high speed trains going by, except they were only moving a few nautical mph.

Lunch Breaks with All the Amenities

Something we’ve learned after just a couple weeks into our month long Tampa trip is how wonderful the lunch breaks can be. Even with fairly short travel days, it is great to split the driving into two segments, with a lunch and nap break in the middle.

In the past when we’ve stopped driving for a break, we would confine ourselves to using the office/garage so we wouldn’t have to mess with pulling the slides out. The way our RV is built, you can’t really use the front 3/4ths of the RV without pulling the 3 slides out. This includes the kitchen, living room, bedroom, and main bathroom. But the office/garage is fully accessible with its own door, and includes a half bathroom, table, bed, and piano. So we’d sometimes pack a lunch and put it into the outside kitchen refrigerator along with a couple drinks, and then eat lunch in the office.

Well this past trip we pulled into a rest area, parking in the truck/bus/RV section as instructed. We noticed that these pull through spots are really wide, and in fact we could pull out the slides and still fit between the lines. So we did.

Fire up the generator, kick in the A/C, and bring out the slides, and we have our full home available for cooking or making lunch, and taking a nap afterwards in our own bed.

Stephen Foster Folk Culture Center

Saturday night we stayed at the Stephen Foster Folk Culture Center State Park in White Springs, FL. This was an amazing experience. The roads are small, so I was a bit nervous driving our big rig in the small, twisty turny roads. It was worth it though. Our site was fairly secluded, and the foliage so dense that it was like it was fenced. We were a bit sad that we only had one night here.

Meaher State Park

On our way to Tampa we stopped about half way at Meaher State Park in Alabama. It’s located across the bay from Mobile. We arrived here Sunday afternoon, then I worked from here for the week.

It’s a very nice park with a lot of space between sites. We also stayed here Saturday night on our return back from Tampa.

Living the Dream of Living On The Road

For over ten years now, it has been a dream of ours to be able to live and work in our RV from all over America. I’m delighted to say that the dream has finally become a reality.

Shelley and I have been living in an RV for about 12 years now, but the combination of finances, technology, and family responsibilities have limited our ability to be away from the Austin area. As a programmer, I can basically do my job anywhere as long as I have a good internet connection. But many RV parks have terrible Wifi, even if they advertise that they have it. And cellular plans with broad coverage and high data limits have been pretty expensive. But the cost of cellular plans continue to drop, and coverage areas are continuing to expand. So this past year I think things finally reached a point where we can afford to get good coverage just about anywhere in the US.

Our plan is to travel on weekends, then work Monday through Friday wherever we happen to be. Also, since this is going to be an ongoing thing, we’re not going to be driving long days when we travel. It’s one thing to put in a long driving day for an annual vacation or such, but totally different when we’re doing it every weekend. Driving and seeing new places is a lot of fun when it’s only a few hours a day. It stops being fun when those drives are over about 4 hours or so. So we’re trying to limit our driving to about 4 hours per day.

We started gradually, testing out the idea of working using just cellular connections by making short trips to nearby state parks without Wifi: McKinney Falls, about 30 minutes away, and then Inks Lake, less than an hour away. These worked out just great.

Office on Inks Lake
My Office (and assistant) on Inks Lake

So now we’re in the process of testing being away for a whole month. We’re traveling to Tampa, FL to spend a couple weeks visiting with our daughter Jackie. Sticking with our “4 hours per day” plan, we’re planning on driving from Austin to Meaher State Park in Alabama over the weekend of April 23-25, then staying and working from there for a week. Then we’ll drive from there to Tampa FL over the weekend arriving on May 2nd. We’ll stay and work there for 2 weeks. And we’ll see how it goes, and learn and make adjustments as we go.

Home Automation with Alexa Needs Internet

If you’ve been following my home automation activities, then you know that I’ve been fairly invested in using Alexa. Even though I live in an RV which basically has only 3 rooms, I am using 4 (sometimes 5) Echo devices. These provide a very rich voice control experience and I’ve been very happy with them.

A problem with using Alexa, at least from the perspective of one living in an RV, is the requirement of having an internet connection. Without a live internet connection Alexa is dumb as a box of rocks.

However, Alexa doesn’t need a fast connection. So I’ve setup my networking to connect my router to a Verizon Jetpack while I’m on the road. Since I’m a Verizon unlimited customer already, adding a Jetpack only costs about $10/month. It provides 15 gig of high speed bandwidth then throttles down to 600k, which is actually enough for Alexa and for communicating with all my IoT devices. So it continues to work even if I’ve used up the high speed bandwidth.

Home Automation Fun

It’s been a fun year playing with creating home automation software, but totally unproductive. I had decided to write my own Mac Mini, Swift based programming to control all my IoT devices. I did this, and then ran into lots of issues trying to interface with all my IoT devices. To make matters worse, the things I was trying to interface with kept changing (eg. new Samsung Smartthings APIs, programming language, etc). So while I think I came up with a pretty powerful code base for automating my home, I hadn’t actually automated anything in the past year. So I’m going to call that a fun learning experience, but I need to change direction if I actually want to automate my RV home.

Home Assistant v0.91

I experimented with using Home Assistant. For me, it actually made things much more complicated. There are no off-the-shelf solutions for automating the 12v lighting system of an RV. So I have to create my own IoT solutions, and integrating that into another system like Home Assistant just adds another layer of complexity.

Rolling My Own

So having experimented with using Home Assistant, SmartThings, and Homekit, I eventually ended up using the Alexa skills I wrote awhile back, along with Patriot custom Photon coding.

Like a Scene from The Big Bang

Ron and his desk lampOk, I feel extremely nerdy. Did you see the episode of The Big Bang where they program an IoT device to turn on a lamp by sending a signal all around the world before it gets back to the lamp to turn it on? Well, I was suddenly struck by the similarity when I got Alexa to turn on the Z-Wave light bulb in my desk lamp last night:

  • “Alexa, turn on desk lamp”
  • The voice command is picked up by the Alexa Show device on my desk and sent to Amazon cloud.
  • Alexa Smart Home converts the audio command to a “turn on desk lamp” intent and routes it to my Alexa Smart Home skill running in an Amazon Lambda in the cloud.
  • My Smart Home skill converts the intent and forwards a “turn on desk lamp” command to Particle.io.
  • Particle.io publishes the command to my Photon IoT controllers, one of which is acting as a bridge from particle.io to MQTT.
  • The Photon bridge reformats the command and publishes it to MQTT.
  • The MQTT broker is running on a Mac Mini, which then forwards it to all other devices subscribing to MQTT.
  • One of these MQTT subscribers is the smartthings-mqtt-bridge app running on the Mac Mini. It then receives the MQTT “turn on desk lamp” command, and forwards it to the Smartthings web hook over the internet.
  • (Should I mention the Wifi to router to … Nah).
  • The Smartthings server receives the command via web hook, routes it through a Groovy program running in Smartthings, and forwards the command to my Smartthings hub over the internet (and router to wifi, etc).
  • My Smartthings hub then transmits the “turn on” command over Z-Wave radio to my desk lamp light bulb.
  • And the light turns on.

Woohoo!