It’s been months since my last post. Life happens – and when it does, travel and blog posts get deprioritized. Not for long though – we’re getting ready for another road trip.
In the meantime, I’ve been messing around with a couple of technology-related projects. The first is a new version of my refrigerator fan controller. The original works fine. The controller runs the fans when there is no Internet, but my visibility into what it’s doing is dependent on having Wi-Fi and Internet. For Project #1 I decided to re-design the controller using a newer version of the Espressif microcontroller (an ESP32) that has built-in Bluetooth – so that I can gather data from the controller even when there is no Internet. It’s programmed, soldered up, tested, and ready to install – pending warmer weather.
Project #2 is to expose the data from the various gizmos that I’ve created without having to wake up a phone or tablet. Newer campers likely come with some sort of a touch-screen interface into the various systems installed in the camper, such as tank levels, water pump, lights, awning, battery voltage, etc. Ours is old enough that it’s all mechanical buttons and switches – good in a way, but that means that some of the basics are only visible by looking at switch positions or LED’s.
A commercial touch-screen interface isn’t retrofittable (I asked…), but that doesn’t mean I can’t build a ‘better than nothing’ visual interface into some of the systems in the camper.
For the visual interface, I chose a 7″ color, capacitive touch ‘smart’ display from Nextion. Their display has a GUI editor that lets you build widgets, text boxes, gauges and other GUI elements and transfer them to the display. The Nextion has enough intelligence built in that one can control & update the widgets by sending simple commands to its built-in serial port. For example, if I create a text widget called ‘t1’, and I want to display the text ‘Battery’ in the widget, I send the text ‘t1.txt=”Battery”‘ through the serial port to the display. Orders of magnitude simpler than other displays, and (for me) simpler that running a web server & web application in the camper.
To drive the display, I’m using another Espressif microcontroller (an ESP32) that has a serial interface, Bluetooth, and WiFi. The microcontroller accepts messages on behalf of the display (which has no WiFi or Bluetooth) and forwards them to the display via a serial interface, just like the serial interfaces that were on PC’s decades ago, prior to USB. The ESP32 acts as both a Bluetooth host, listening for commands and forwarding them to the display via its serial, and as a WiFi node, performing the same function.
In addition to Bluetooth, I’ve decided to establish a means to communicate between the various gizmos (a Raspberry Pi and the microcontrollers) using Wi-Fi. I’ve set up an MQTT broker on the Pi. The broker manages a message bus that is used to communicate between the devices using the Wi-Fi network (if available). It does that by allowing any device to publish a message with a particular topic and any other device to subscribe to messages tagged with that topic. It’s a publish-subscribe model, where you can dynamically create topics, then publish & subscribe to messages sent to that topic – across the network, of course. The MQTT broker tracks which clients are subscribed to each topic and stores each message until all subscribers of that topic have received that message.
For example, if a gizmo measures battery voltage every minute, the gizmo can publish a message to a topic called ‘camper/battery1/volts‘ with a value of ‘13.34’. Any other gizmo that happens to be subscribed to the topic ‘camper/battery1/volts‘ will get that message, and upon receipt, will know that ‘battery1’ has a voltage of ‘13.34’ volts. The topics can be anything you want, and the messages can be numbers, text or binary data. Because any device on the network can publish or subscribe to any topic, the device that measures the voltage publishes the voltage to that topic, and any device that wants to know battery voltage connects to the broker, subscribes to the ‘camper/battery1/volts‘ topic and waits for ‘volts’ messages to show up.
In my case, the ESP32 attached to the display publishes messages to the MQTT bus if its status changes or you touch any of the widgets, and subscribes to display-related topics (volts, temperatures, solar output) and forwards them to the display, where the display renders them in the appropriate widget.
I figure that ’cause some of my friends and relatives are engineer types, it’d be more interesting if I created some high technical, detailed engineering design documents for them.
Like this: 😁
Notice the cloud icons – can’t build IoT gizmos with a cloud icon. 😎
Right now it’s still at the ‘breadboard’ stage. I have the software (C++) in pretty good shape, a first pass at the GUI design, and both MQTT and Bluetooth interfaces coded and running.
I need to solder it up, figure out how and where in the camper to mount it – likely not until warmer weather – and tweak some of the software. But the data on the screen in the photo above is live from the camper as of 7pm tonight, updated every minute.
- The Nextion has a built-in real-time clock that I’m displaying in a widget.
- The gauges are a combination of Nextion widgets and PNG’s that I created & dynamically overlay/underlay the widgets.
- The volts, amps and temps on the display are being fed real-time via MQTT from the camper to the microcontroller located on the breadboard.
- The checkerboards turn green when I’m getting solar from the rooftop panels – zero watts at 7pm in winter.
- You can dim the display using the slider and put it to sleep using the ‘moon’ icon.
- You can swipe right to get another screen that lest you set the real-time clock (and eventually other parameters).
’tis getting close…
Enough nerd stuff. Next post will be for the start of a road trip – we hope.
Leave a Reply