Sometimes a project, despite being simple in application, is so elegant in it's execution that we simply have to feature it, from a point of finesse rather than function.
Fortunately, with this slick HMI device by Evan Wright, we've got both to fawn over!
What started out as a simple way to keep tabs on the power consumption of his home — through the readout of the KYZ contacts of his electrical utility meter — has evolved into a simply beautiful starting platform for any EPS32-based graphical HMI application.
With everyone's favorite Wi-Fi-enabled microcontroller at heart, the WROVER range of modules from Espressif make working with a complete ESP32 implementation as simple as soldering down the generously spaced contacts on the specific WROOM, WROVER or "other" module of choice.
With the MCU taken care of, let's quickly loop through and take a look at the rest of the design, picking out details where we can.
The KYZ communications is coming from a electrical utility meter, and as such, under an error condition, has the possibility to have line voltage present on it — should the meters own safety devices fail.
While that is incredibly unlikely to happen, there's no harm in an additional safety net, and Wright achieves this through the use of some opto-isolated DIP devices — a pair of H11L1Moptocouplers.
These devices incorporate a Schmitt trigger on the output, such that they provide a clean, well defined transition between the the input state of the device.
We can see a few (what appear to be) Polyfuses around the design — an extra safety precaution to be sure — but without a schematic, all I can suggest is that they are sat in-between the KYZ connector and the inputs of the H11L1M optocouplers, and the internally generated 12V that is applied to the Common terminal of the "Dry-Contact" KYZ switches.
Below, we can see a composite image, where I've traced out the path from the 12V boost converter, in order to validate my understanding of Wright's implementation.
Side note, it's a lot easier to reverse engineer a board with a liberal application of GIMP (other image editors are available...)
Beyond the KYZ switch signal sensing of this device, it's clear to see that Wright has a focus on sensing more than the mains utility usage.
With an ADS1015 from Texas Instruments plonked down on the board, this I2C-interfaced analog-to-digital converter features a programable gain amplifier, which can be used to amplify any of its four multiplexed inputs, before feeding that signal into the internal 12-bit sigma-delta ADC to be read out form registers using I2C communication.
In a fashion similar to how I've composited the layers to show the tracking of The 12V supply, we can see that the ADS1015 tracked out to keep tabs on four separate measurements.
We can see the aforementioned 12V rail, two other signals — one named CRG — that indicates voltage present at the terminals of the lithium ion battery and SYS, which is fairly self explanatory.
As for the mystery tracking that follows the 12V sense tracking, well... We see it goes to the "front" of the PCB, to a footprint that looks deceptively like a SMD tactile switch. Let's take a look at that in some closer detail.
With a test point marked "AMB," and with positioning that frankly doesn't match the rest of the elegance of this design. That's no reset switch, that's an ambient light sensor — a further refined touch that can help automatically adjust the brightness of the display, based on the surrounding light conditions.
With a little more CSI-level photoshop compositing later, we can see that everything lines up to support this theory.
With a focus the HMI application of this device, Wright has rightfully chosen to go for gold when specifying and implementing the display interface.
Starting with the basics, this is similar to many of the available LCD panels available. With a resolution of 480 x 320 pixels, this touch interface-enabled IPS display panel has looks to die for.
However, the detail in making such a high pixel count panel update smoothly, and slide swiftly through scrolling menu applications requires the display's internal ILI9488 controller to be interfaced to the ESP32 module with an 8-bit wide data bus.
There is a very good reason to take the time to implement such an interface, despite the fact that the ESP32 and the ILI9488 controller clearly both support SPI, which would take only three connections — four if there was any need to read back from the display.
It's all down to speed.
Wright has done due diligence in testing out the different interfaces of the ILI9488.
Similarly in how boy-racers add go faster stripes to slow cars — remaining slow, in the case of driving displays, throwing in a few extra lines over which to communicate actually makes a massive difference in performance!
In the GIF above, we can see two units. The top assembly is interfacing to the ILI9488, using the SPI interface of the ESP32. The bottom assembly — within the enclosure — is interfaced using the parallel scheme.
Despite the blazing fast 40MHz clock speed of the ESP32's SPI interface, drawing a screen's worth of pixels (all 153,600 of them!) takes roughly 100ms, which equates to 10 FPS. Far from smooth.
Moving to the 8-bit parallel interface results in a speed boost of update that are 2.5x faster, with a full screen update taking only 40ms, giving 25 FPS.
While the ILI9488 supports a massive, 16-bit wide parallel data interface also, the limited I/O present in this design means that Wright has only tested speeds offered by the extra 8-bits with a different host (the ESP32-S2), but that is 4.34x faster than SPI, offering update rates of 23ms / page, or, 43 FPS — that's buttery smooth.
As always, USB-C != USB 3.
There's nothing on this board operating at 5GBps, nor is the beautiful OSH Park After Dark board stack-up really rated for that sort of speed.
However, as many of us know, USB 3 will happily pass USB 2.0 signals over one of the single differential pairs that are found within the USB-C connector system.
Sitting on the other size of the USB-C connector is the ubiquitous USB to serial converter, the cheap and cheerful CP2102N from Silicon Labs — found on nearly every USB-connected, ESP-based device.
The final point of note is one that might go otherwise unnoticed by some, but it's very clever.
We can see that the PCB is held in place to the front half of the 3D-printed enclosure by four, self tapping screws, that are ferrous (steel), making them magnetic!
By cleverly co-locating some circular Neodymium magnets in the same locations as the screw heads within the rear face of the casing, it can simply snap together, without any additional fixings.
We can see this in action in this quick GIF below. It's a nice system, that is strong enough to work for lightly used handheld devices, and works perfectly for a wall mounted design — as was originally intended for this device.
I know he was quickly added to my Twitter "following" list — @KiddingMe32 — and I can't wait to see the next, well considered design that he feels is worthy of sharing with us!