Sunday, May 17, 2026

Controlling an Air Handler with Home Assistant.

In a previous post <Link>, I described how I put together a 'thermostat' using the EspBuilder integration in Home Assistant. That project was fun, but it relied on my old thermostat from years back that was actually wired into the Air Handler. Since I still have ties to actual code, and was familiar with Zigbee, I thought I'd put together a controller that directly wired into the actual Air Handler and lived on top of it up in the attic and out in the garage using the Arduino IDE. I saw this as a fun Zigbee project that I could tailor over time.

Sadly, that didn't work out. I started by creating a Zigbee device with one control, the fan. That worked well on the second try. I had the usual problem with setting it low instead of high. Then I added the reversing switch, that worked also. As I added things reporting and being controlled, I hit the magic number of seven. It seems the Arduino IDE Zigbee interface to the Esp Zigbee library had trouble with more than seven endpoints on a single device. That kind of sucks because to finish my plans for this new device I needed more than that. 

I thought about combining sensors by sending data encoded in numbers and such because text is a real pain using zigbee. Then I thought about my experience with EspBuilder. Maybe that would work...

There I was deep into YAML again, dropping into  lambdas of C code where necessary and spending hours looking for the exact right indentation needed to make this idea real. Coming from C originally, putting up with having indentation be the determining factor for nesting really is a space alien concept, but with the help of AI, I stumbled through it. 

I took a XIAO ESP32C6, another of those little expansion boards and a cheap four relay board and slapped them together.



I've learned that actually mounting things keeps the wires from one piece to another safer. I got really tired of hooking things back up and trying to keep track of pieces when prototyping. Now, all I had to do was wire up the relays, and using the EspBuilder code I had created, test this thing until I was comfortable that it might do the job.

So after some time with EspBuilder, I trotted this out to my garage where the Air Handler lives and used some sophisticated mounting devices to place it in actual operation.

Yes, duct tape

I just drilled a hole in the top of the Air Handler cabinet and stuck the device on top. It lived there for over a week taped down and actually doing its new job while I converted that AC unit over. I changed the device assignments in Home Assistant and disconnected the old DIY thermostat completely. Here's my previous thermostat that actually did everything resting in it's new retirement area:


That long USB cable was part of the actual installation. I would pull that out and plug it into my laptop to make code changes, then put it back inside the wall for next time. Notice the Arduino stack upper left? The model A Arduino, then the next layer is the ethernet board, then double stacked to allow for the ethernet plug to a board that held a buck converter to convert 24vac from the Air Handler to 5vdc for everything, and all the wires for the display, control buttons, and even the temperature sensor. 

Ah, the good old days ...

Of course there was wiring that had to be done inside the Air Handler. Have you ever looked inside one of those? They're a nicely laid out area where the factory put things together, then the place I needed to get to to connect my controls. On simple AC units, without fancy variable speed motors, semi intelligent control systems and such that we're starting to see, it's pretty basic. There are three controls, the fan, compressor and reversing switch. The reversing switch is what switches from heating to cooling by controlling which expansion valve is active, the one inside, or the one outside. Air conditioning is really simple until you get into the refrigerant handling. This is the wire bundle that leads out to the compressor beside the house:


The compressor and reversing wires are in there somewhere, "refer to schematic." Yeah, right, the schematic was wrapped around one of the covers and hard to follow, so I took pictures of each part, 




and then used paint.net to combine them, adding notes after I pondered each line to try and get the right ones hooked in:


My note boxes and complete schematic are now immortalized on Google Photos forever. When I get back into this thing in a year or two, at least I have some idea what I did last time. However, the actual Air Handler doesn't look anything like that. 


And, under the cover where the schematic wrapped around are the actual places that I need to hook to.



After a bit of following wires and installing connectors, I had it all wired up and tested with the prototype duct taped to the top of the box. I want folks to notice how I powered this device. 


Yes, it's a cellphone charger. I use these a lot for 5vdc projects. As I described in other posts, it's only a buck and will work just fine with 240vac input. Love these little things. Now, how to protect the boards and wiring. 


This is what I came up with. Yes, I ordered a new roll of white filament for the printer. I used plugs for both ends and kept the USB C connector as the power input. That way I can plug a laptop into that side to make changes if I need to do that. The other side is a Phoenix plug. I discovered Phoenix plugs mostly by accident prowling around for plugs on Amazon. You can put wires directly into both the fixed socket and the plug itself. Using plugs like this is really nice for environments where there is a small amount of vibration for a long time; plus it allows me to remove the entire assembly and bring it to a workbench for some work if needed. This is specifically what I used:


It looks like it's two parts, but it's actually three, One part mounts to the enclosure, and then the top piece snaps into that forming the socket. The plug part is one piece. I just put the wires from the Air Handler into the plug and the wires from the relays into the socket. It did take a bit of work on the enclosure to accommodate the mounting though. I put a recess in the enclosure using Fusion.


This worked really well, here's the test print I did to try it out



I was really proud of how well this worked. I printed up a lid for it that is just an inverted "C" that friction fits to hold it on since I wanted to get in there if something happened during extended testing and went live with it. 

It worked. 

Look, no more duct tape!

The "warm red glow" is the little lights on the relay board. Basically, I was done, so I just duplicated everything for the other AC unit on the north side of the house after this one proved itself for a week.

The last piece of this upgrade to my home controls is the remote temperature sensor, I'm still using the ancient ones I built up for the old system and waiting patiently for the Esp and Arduino developers to get past the bugs in their code. The last time I tried (about a month ago) two analog sensors wouldn't work in the Arduino IDE, one would show up in the other; I couldn't get two of them independently reporting. The ESP developers have promised EspBuilder would support Zigbee on the Xiao ESP32C6, but they encountered pretty serious problems with their build environment meshing with changes in Home Assistant. It is currently rumored that they blew off their first of the month deadline in favor of coming out with a 2026.6.0 release instead. So, both platforms are in flux and I'm currently stuck.

What I found though, was that EspBuilder under Home Assistant is really great for this kind of development. I can make changes, load them onto the device, and try them out from my recliner in the house. There is even a little web server on the interface board that I can get to.


There's a whole bunch of other features that make that development environment absolutely the best for home automation that fits it's requirements. 

Code? Sure, I will eventually put the code into github, when I feel a need to be punished learning yet another new thing.

Wednesday, May 6, 2026

A Real Use for the Cheap Yellow Display

 So. a friend told me about the CYD (Cheap Yellow Display). Basically a nice little color display that has a processor on the same board with some inputs and an ESP32 complete with wifi. At first, I kind of shrugged because ... well wifi. For me, in a rural area prone to power outages, wifi has been pretty much a pain in the bottom. Internet in general has sucked over the years because a WAN connection had to be by wire. Dial up, DSL and such were the rule because that was all that was available. 

But, over time, that changed. The power company FINALLY decided to actually supply (mostly) reliable power. Then the various internet providers started showing up. Wifi mesh networking systems became cheap enough to actually use in the home. We caught up (almost) with the 21st century. 

Heck, I think I'll get one of these things and see how they work.Wow! these little things are really great!!


Notice I got the 4 inch model? I wanted something I could actually see and interact with. It has a resistive touch screen, and a nice color display. 


Since I didn't want to scratch up the screen playing with it, I immediately made a faceplate for it and noticed a small annoyance: the screen is off center.


Notice how the left side is wider than the right? No, that isn't because I printed the faceplate that way, it really is off center to allow for the wifi antenna that the processor has.


Never mind, that's good enough to begin; I can adjust for that when I have something real developed. For now, let's play with this thing.....

Since this was my very first ESP32 journey into code, I loaded up the latest Arduino IDE, an installed the esp32 board support and tried it. I got "blink" to work, then advanced to "Hello World;" they both worked, but it was painful. The native code was full of various calls that I really didn't understand and just seemed way to complex for something that would have to maintain for years and years. 

I looked around, even sent an AI out to find a way to simplify developing something for this board that actually did something. My answer was right there in Home Assistant, ESPHome Device Builder. They tout it as "No Code," and to some people it might be, but not for anything that I want to actually do something; more on that later.

I created my first ESPBuilder device, "Hello World," and I was impressed. I mean really impressed. I managed to get a string on the display, in any color I wanted, and actually be able to read it without squinting. I spent some time playing with the backlight, fonts, various items from home assistant like drop down menus and circular gauges. It was totally fun watching things come up on the CYD that had been limited to laptops and phone in the past. 

What to do with this? MY THERMOSTATS !!

For a decade I had used the "Super Thermostat" <link> that I created many years back. Now was a good time to replace them with new hardware. They were already ethernet devices, and a wifi device like the CYD would be a good experiment to try out. Plus, I could put that dusty 3D printer to work for a custom enclosure. 

This was a bittersweet decision. I created those thermostats back in the medieval times of home automation, and they were quite a project. At first they were wifi, but wifi didn't work too well with the Arduino platform in those days, so I switched them to wired which was a lot of work. Then, I modified them to use remote temperature sensors <link> so I could sense the temperature right where the people were; that was also a big project because they were battery powered end devices on a Digi XBee network. Plus, there was a lot of custom changes to the combination of devices over the years that I would have to reproduce under the new digital environment. Did I really want to take this on???

This is what one looks like finished, running, and controlling the AC unit on the south side of the house.


Yes, it's green. There were two main reasons I used green filament to print it. 1, I already had a spool of green filament, and 2, the wall behind it was green. No, it was not to draw attention to them so people would ask about them; nope, not at all. The two patches cover up the holes from previous thermostat work that I absolutely will cover up and paint ... someday. 

It all works, The code has provisions for my power company "Peak Demand Period;" where the price of power goes through the roof. It's animated; the little fan is black and stationary for idle, red and turning for heating, and blue and turning for cooling. It even has drop down (or in this case up) menus for selections. 


If you use your imagination, you can see the fan spinning

I can change the mode with the simple press of a fingernail or a pen on the screen (remember, it's a RESISTIVE touch screen). Same thing with the fan. The temperature is displayed as both a circular gauge and numbers in fahrenheit. The temperature setting is controlled by both a slider and two buttons.Yes, I was showing off a bit, but I couldn't control myself. 

"But, wait, how did this thing control the air handler? It doesn't have any wires going into it?," you say. Well, I cheated. The old real thermostat was still running, catching commands from Home Assistant and feeding them through the wires to the air handler. Basically, this was just a fancy display that had bells and whistles that actually worked to send commands to Home Assistant which sent them on to the old thermostat that fed the wires. The idea was to stage my conversion to new hardware one bit at a time. First the CYD because it was cool and pretty, then something to replace the old thermostat that would actually control the air handler, then a remote temperature sensor that I could place appropriately. 

Yes, this was going to turn into a huge job with parts all over the house, but any one of the pieces could be updated independently as desired. There's buzz words for this like, "distributed processing", "isolated failure tolerance," or maybe "extendable architecture," but what it really was was staging the changes while I kept the AC working. That thing is my heating and cooling, and in my unpredictable climate ---necessary. So, While this screen looks like a thermostat, it's actually just the face of a much larger system—the real work happens in the old thermostat that is ancient. For now,but that is going to change.

Power comes in the back through a USB C connector hooked to a wall wart on the opposite side of the wall. That way there are no wires visible and only a small round hole in the actual wall. Why? Well, I had a lot of trouble with heat generated by various devices when I tried taking the 24vac down to 5vdc. Those little converters are cool, but run hot and that's not a good idea over time. I thought of this going into the project, and the device is upside down compared to other projects. 

The lid is actually the mounting point of the new thermostat and is held on by screws into wall anchors, then the CYD is mounted to the case with a hole in the bottom for the display and a friction fit to the wall mounted lid. The USB C cord comes through the lid, like this:


So, if I want to work on it, I just pull it off the wall, unplug the USB C connector, and walk off with it. Slick, and I wish I had thought of that technique much sooner. It makes taking pictures of the other half easy, like this:


See how I used a commonly available right angle adapter for the USB C connector? I try to keep projects as cheap and easy to find parts for as possible. Also, notice the dead space to the right? That's because the CYD display is off center as I mentioned earlier. It makes for a larger thermostat device, but it would drive me nuts over time looking at a screen that was off center every time I walked down the hall.

Which reminds me, How does this control the actual AC units? Well, ESPhome and Home Assistant thought of that for me. Each operation like changing mode: heat, cool, off, are handled by Home assistant. The thermostat is a "device", with "entities" that can be put in a dashboard. That way, I have menus on the laptop and cell phone as well as the thermostats on the wall. I basically stole the controls I already had for the old thermostat that was routed from old code and hooked this to that. This mess of stuff made for a cool display on Home Assistant:


If you've read any of the other posts on this blog, you already know I'm a sucker for graphs. They tell me at a glance if something is wrong, and I get a feel for the behavior of the various things around the house easily. I will eventually make that menu simpler for 'normal' people to use, but for now, it's my baby, I'll show it the way I want to.

So, after building two of them and working out how to share the common code between them, I had two new thermostat devices. That was really great for a few days, but then I thought to myself, "Self, why don't you move all that logic over to another device that is right on the AC air handler? That way you can get rid of the requirement of hooking into a wire that runs through the wall to control the AC. I could put all the control logic in there, and when necessary, adapt it to a different air handler. Plus I could do things at the air handler that are not as easy with a wired system. I could measure the air flow, temperature of the incoming air vs the outgoing air, maybe use the lower speed of the fan ,,,

I'll write about that project in the future, it was a bit harder, but fun.