AI Summary
Full Transcript
[00:00] This little thing I made might look kind of goofy, but it actually solved a pretty annoying problem for me, and it's not the only one. I ended up making a handful of smart home gadgets that all integrate with Home Assistant using some cheap microcontrollers and components.
[00:12] Now this might seem a little complicated, but it was surprisingly straightforward thanks to a really cool framework called ESP Home. Now I'm sure many of you watching this channel are probably familiar with ESP Home, it's not exactly newer or anything, but I've been meaning to try it out for quite a while now, and while I finally got around to building some of my own DIY IoT devices.
[00:30] So in this video, I'll walk you through how I designed, configured, and built a few of these little projects. Not only was this process pretty fun, but the end result actually made my life a little bit easier, so let's get started.
[00:51] This video really started the way most of my projects do. I had a problem that I wanted to solve. Well, actually I had a few different problems. The first one was my garage door. Now it works fine, but I have this bad habit of taking the remote from my life's car whenever I take our kid on bike rides, and sometimes I forget to put it back.
[01:07] I've also left it open overnight, a non-zero number of times. Another issue I have is that while I love Home Assistant, sometimes I hate having to pull up my phone just to do simple things like turning on a lamp, especially in the middle of the night when I don't have my glasses on.
[01:20] So I decided to tackle those problems and a few others by building some custom smart devices. There were definitely a few hiccups, but the whole process was surprisingly straightforward and made for a fun little project. So I figured I'd make a video showing how I built a 4-button remote to control Home Assistant, a smart garage door opener, and a simple little temperature sensor.
[01:37] Now if you're not familiar, ESP Home is an open-source system that lets you write simple Yamaha configurations to create smart home devices. Those configurations then get flashed onto ESP-based microcontrollers like the ESP-8266 or ESP-32.
[01:50] These are inexpensive little boards that you can sometimes grab for as little as like a three-box, and with ESP Home and a bit of tinkering, they can become buttons, sensors, lights, or pretty much anything else you want them to be. ESP Home integrates directly with Home Assistant, so once you flash a board, well it sort of just shows up there.
[02:06] And everything runs on your local network, so you don't have to worry about any cloud services or anything. Now behind the scenes, ESP Home compiles your Yamaha config into actual code and then builds a binary that gets flashed onto the board.
[02:18] So because of this, you don't really need to know how to code yourself. Honestly most of the configs I'll cover in this video were initially generated by ChatGPT, and then I just tweaked a few settings following the ESP home documentation. This gives you a lot of power to create devices that you want without making you feel like you need to know how to program.
[02:34] But maybe you do want to learn programming, and if so, you might have found that a lot of online courses are kind of boring. That's why the sponsor of this video, Boot.dev, is approaching back-and-development in a much smarter way, by actually making it fun.
[02:46] Back-and-development is the foundation of the modern web, hence what powers databases, APIs, and servers, basically all the behind-the-scenes logic that makes websites and apps work. Boot.dev teaches you exactly that, through practical hands-on lessons and Python and Go.
[02:59] Instead of just reading about how things work, you'll build working back-and-systems from the ground up. The courses makes real coding challenges, with just enough theory to keep things grounded. There's also an active Discord community, so you're never really going to be stuck alone.
[03:12] And with gamified learning, like XP, quests, and later boards, it stays engaging while still focusing on writing real, jaw-ready code. I found Boot.dev to be a great way to brush up on my Python skills, while also having a lot of fun.
[03:24] And personally, one thing I love about it is that the entire site is navigable by keyboard shortcuts, which makes blasting through courses feel so much faster. You can try out any course with a free demo, and there's a 30-day no questions asked refund policy. So if you're ready to start building the back-and-systems that power the web, head on over to Boot.dev and use my code, Hardware Haven,
[03:41] for 25% off your entire first year if you choose the annual plan. Now, before we get too far, I do want to be clear, I just started messing around with ESP home. I am not an expert, and I might get a thing or two wrong.
[03:53] I also won't be deep-diving into every parameter in the configs that I generate, but ESP home has solid documentation, and like I mentioned earlier, something like ChatGBT can get you most of the way there. When it comes to microcontrollers that work with ESP home, there are lots of options.
[04:07] You can go with something super cheap and low-powered, like this D1 Mini, which is based on the ESP 8266 chip, or you can use one of the Mini ESP 32 boards that have beefier specs, and more connectivity options.
[04:19] For the projects in this video, I ended up using two different types of controllers. First, that ESP 8266 based D1 Mini, and I used these because small they worked pretty well, but I also had a bunch of them from a previous project.
[04:31] It also helps that they're really cheap. The other one I used is this very tiny Seed Studio Jowl, I think I'm saying that right. The Jowl lineup comes in a few different flavors, but I picked up a three-pack of the ESP 32 C3 versions.
[04:43] Now when it comes to ESP 32 boards, there's different variants like C3 and S3. You can look up the different specs the C3 has a risk 5 core, but I mostly got it because it has USB-C, and it's just so dang tiny.
[04:55] Now these controllers don't really do much on their own, so you'll also need different components like buttons, switches, and sensors. If you're curious about trying out ESP home, you can usually find different Arduino kits or electronics bundles that include a bunch of reusable components for pretty cheap.
[05:08] Honestly, pretty much everything I used in this video came from different bundles that I'd bought in the past. Now to assemble everything, you'll probably need a few tools. A soldering iron is pretty much essential, and breadboards, jumper wires, and proto boards are super handy for prototyping and putting together the final project.
[05:24] If you want to build custom enclosures, a 3D printer definitely helps, but if you don't have one, you can pick up some small plastic project boxes for pretty cheap. Oh yeah, and I mentioned that these work with home assistant, so you'll probably want to be self-hosting home assistant.
[05:37] Now you can run the full home assistant operating system, or you can also just run home assistant core in a Docker container. Just note that when you're setting up ESP home devices, it's a little trickier when you're running core. The full operating system includes an add-on for the ESP home device builder, but core doesn't support add-ons.
[05:52] You'll either need to run the device builder in a separate Docker container, or if you're running proxmox like I am, it's really easy to use a community script to spin it up in an LXC container. Both options work pretty well, but there are some differences, so I'll make sure to show you both of those here in a bit.
[06:05] Now before diving into any specific projects, let me show you just how simple ESP home can be with a quick demo. Just for this video, I installed home assistant OS onto a Raspberry Pi 4, and then from there in the add-on store, I installed the ESP home device builder.
[06:19] Once that was set up, I could open the add-on, create a new device, and give it a name, and then enter my Wi-Fi credentials. Since I was going to be using the D1 Mini, I selected ESP 8266, and after that the config was generated,
[06:31] and it gives you this API key, but you can just skip that for now, you can always copy it later. I clicked edit to make one tweak to the YAML configuration, which was just to change the board type to the D1 Mini, and then I saved it. Now I personally like to hit validate before I download or install anything, but once it was all good, I clicked install.
[06:47] Now with the ESP home device builder, you can directly flash your controller from the web GUI, but I found that with the D1 Mini, it just didn't really work. I found that manually installing the binary worked best. So I selected the manual download option, which just compiled the dot-bin file.
[07:02] Now the D1 Mini is a little bit different from other boards. We have to short the D3 pin to ground before plugging it into flash it. Once it was plugged in, I used this node MCU ESP 8266 flashing software to flash the binary.
[07:14] And that's as simple as just selecting the dot-bin file, choosing the device, which in my case was COM6, and hitting flash. After that, I power-cycled the D1 Mini, and sure enough, it showed up in the Home Assistant Integrations tab.
[07:27] Now I didn't actually do anything yet, but that was to be expected. Back in the device builder, I hit edit to edit the config again, and this time I added a section for a binary sensor. Now once again, I'm not going to go into the details of how these configs work exactly.
[07:40] If you're curious, you can look up the ESP home documentation, and realistically chat GPT can get you most of the way there. Now one of the cool features of ESP home is that once you have ESP home actually installed on a device, you can edit the config, and then update the firmware wirelessly, which is pretty helpful.
[07:54] Once that was done, my device showed up in Home Assistant is now having a switch entity. I set up just a simple toggle switch between the pin that I defined in the config, and ground, and just like that, I had a simple switch.
[08:06] Now obviously this isn't the most useful device ever, but it does go to show just how easy it is to get started with ESP home. So now let's move on to solving some of my actual problems. I mentioned a few projects at the top of this video, but I decided to start with something a bit simpler,
[08:18] just a basic temperature sensor. For this, I used the D1 Mini again, along with an AM20302 temperature and humidity sensor that I picked up for really cheap on Amazon. Now you might think that you need to write some code to handle the logic or convert signals from
[08:32] this digital sensor, but with ESP home, it's really simple. There are a ton of devices that are supported right out of the gate, so all I had to do was wire up power, and then connect the data pin to whatever GPIO pin I set up in the config.
[08:44] Now this time, I used the device built with it by having running in an LXC container in Proxmox rather than using the Home Assistant add-on. This works pretty much the same except whenever you add the device to Home Assistant, you have to go manually copy that encryption key that's located in the YAML file.
[08:58] Once I flashed that to the D1 Mini, I had a working temperature and humidity sensor. It didn't really look great though, so I opened up on shape and used my basic CAD skills to throw together a simple enclosure. I used these heat set inserts, which you install with a soldering iron,
[09:11] so that then I could just use standard M2 screws to mount the sensor. Now this version of the D1 Mini doesn't have any mounting holes, so I just created this other hole for a little bracket that would hold it in place, but I definitely forgot to design that one second.
[09:26] Once the bracket was ready, I used one more screw to secure the board in place. I printed this mesh lid to allow for some airflow, and to my surprise, it actually just snapped into place perfectly. I'm a complete noob when it comes to CAD and stuff,
[09:38] but I think this turned out pretty well. And now I've got a little Wi-Fi temp sensor that I can drop anywhere, plus it's super easy to just make more of these in the future if I ever need them. Next step, I decided to move on to building a simple remote just to control some things
[09:50] in home assistant. This was mostly so that in the middle of the night, I could turn on our lamps and such, without having to like, fumble around with my glasses and try to get my phone out. For this one, rather than the D1 Mini, I decided to use that Seeds Studio Jaubord,
[10:02] not because I needed anything specific from the ESP32C3 chip. I really just liked that I had USB-C, and I figured that would be easier to move around my house between different chargers, and it's also just really tiny. The setup was pretty much the same as before, I selected the correct board type,
[10:16] but this time I also switched the framework from Arduino to ESP-IDF. I'm not exactly sure why I had to do this, but it ended up making things work correctly. Then I made a config with four binary sensors, each mapped to a physical button. Also, I should note that originally I used GPIO pins 8 and 9, but I later found out that those are
[10:32] what's called strapping pins, which might have caused some issues, so I changed them, so if you notice that wiring kind of switched to different points in the B-roll, that's why. Now for this one, I actually flashed the controller using the web GUI,
[10:44] but the device builder either requires you to be using HTTPS, or to have the microcontroller directly plugged into whatever is running home assistant, which can be tricky if you're running it in a virtual machine or in a container. So instead, what you can do is go to web.esphome.io, and then you can just upload your .bin file
[10:59] and flash it from there. This worked really well for the ESP32 board, but like I mentioned earlier with the D1 Mini, I had to use that standalone flashing software. Once everything was flashed, I added the device to home assistant, and then just using a little test button, I was able to confirm that all my button presses were
[11:13] showing up in home assistant, like they should. Back in on shape, I designed a little enclosure that fits the controller down at the bottom, and also supports 4MX style switches on top. Manning the switches was straightforward, but soldering everything together was, well,
[11:26] it was a little bit tricky, but eventually I got it done. This design also used HTTPS at inserts again to attach the top and bottom pieces with M2 screws. I also designed some keycaps, but I printed these out with two different colors of PLA for some contrast, and overall,
[11:39] I think the final design turned out looking pretty good. In home assistant, I created a single automation with four different triggers, each having a different ID for each button, and then I just assigned actions for each trigger ID. To test it out, I just had it control different
[11:51] settings for a lamp in my office, and it worked great. Well, kind of, I did make one damn mistake. These tiny little boards don't have a built-in Wi-Fi antenna. This probably should have been pretty obvious to do the fact that there's no Wi-Fi antenna on here, and there's also a little connector
[12:06] for a Wi-Fi antenna. So my signal integrity was pretty bad, and every now and then certain keystrokes would be delayed a little bit. I probably could modify this to have a little antenna on the back or something, but honestly if I were to do this again, I'd probably just do a redesign and use a D1 mini,
[12:22] although I'd probably try to find one that has USB-C. But still, even with a little bit of latency here in there, it works pretty well, and it's nice to just have a good old-fashioned button rather than trying to pull up an app or use a voice assistant or something. Now the last project was building that
[12:35] smart garage door opener, and I saved this for last because I knew it was going to be the most complicated. For this, I needed two things. A way to open and close the door, and a way to know whether the door was opened or closed. One thing I definitely wanted to avoid was messing with any of
[12:48] the existing wiring. So to control the door, my idea was to just wire up a relay to a wireless remote. It's not fancy, but it should get the job done. For detecting the door position, I could have used a read switch, like the ones that are common for Windows and alarm systems, but instead, I went with
[13:02] this goofy looking thing. This is an HC-SRO4 Ultrasonic sensor that I had from an old Arduino kit. My thinking here was that when the door is open, there's this big flat service at the top of the door that the sensor should be able to detect if I were to suspend it from this center rail in the garage.
[13:17] For this build, I went back to the D1 Mini. I hooked up a GPIO pin to a 5-volt relay, and then used two more pins for the Ultrasonic sensor. Then with just a little bit of help from ChatGPT, I built a config with four different components. First, there's a switch component,
[13:31] which is just for the relay, and this is set up as an internal so that it doesn't actually show up in Home Assistant. Next, there's a sensor component just for measuring the distance from the Ultrasonic sensor. Then there's a binary sensor which basically just states whether the door is opened or closed,
[13:43] and this is generated using a lambda function. Last is the cover component, which in Home Assistant shows the state of the door, and provides controls for opening and shutting the door. And here, the state is returned by this lambda function, which is just the state of the garage door open
[13:57] sensor above, and then the open close and stop actions would just trigger the relay. Once it was flashed, I had a cover component in Home Assistant, and I could either hit the open or shut the door button, which just triggered the relay. And the sensor was fairly accurate at attacking the
[14:10] distance, although I did have the logic backwards so the door was showing open when it should have been closed. But that was a pretty easy fix. I was originally going to use this cheaper note that I picked up on Amazon, but it basically just never worked, so I ended up just sacrificing this one from my car.
[14:25] I gave it a little test run in my garage, and being closer for this one was a bit more tricky, and I ended up going with two separate pieces. One to hold the controller and the relay, and another for the sensor. That way it would be
[14:40] pretty easy to adjust the position if needed. I wired up the controller and the relay to one proto board, and then the sensor to another. I didn't plan to have a long cable run between them, but to be safe, I ended up using some cat5e, just so I could have better signal integrity with the twisted
[14:54] pairs. After getting everything wired up, I mounted the boards into their respective cases with some more heat set inserts, and of course I soldered one of them to the wrong size board. Okay, once I got it soldered to the correct size board, I was able to get everything assembled
[15:08] and had this goofy looking contraption. I got it mounted above the garage door motor using some zip ties, and okay yeah it doesn't look great, but let's be honest, how often are you actually looking above someone's garage door? Anyway, once it was all installed, well it just worked.
[15:24] Pretty much perfectly. So far, it's been a few days and haven't had any issues with the sensors accuracy, and even if temperature or something throws it off down the line, I can pretty easily just tweak the parameters and then push an update over Wi-Fi. It's been great having another way to control
[15:37] the garage door, and now I also get alerts if it's left open. I can even automate it so that at a certain point in the night, if it's open for some reason, it'll automatically close, which is really helpful. Is it perfect? No. Is it pretty? Definitely no. But do I love it? Absolutely.
[15:53] At the end of the day, I managed to make some cool little gadgets that are actually useful, all powered by these tiny super affordable microcontrollers. Now, sure, it's not the cheapest project I've ever done, especially once you factor in the tools and extra components and everything,
[16:06] and you know, the fact that I sacrificed a perfectly good garage remote. But the upside is that I have a lot of extra components. Whenever you buy a lot of these components and microcontrollers, well, usually you end up buying them in packs of 4 or 10 or something. So I have extra components
[16:19] that I can use to build more devices if I want to, which is pretty cool. And everything here is running completely locally. There's no subscriptions, no cloud services, just my own devices running on my own network. So a massive shout out to the folks who helped develop ESP home, your way smarter than I
[16:33] am, and I appreciate it, because this tool made this entire process so much easier than it should have been. Also, I'm very much aware that what I made in this video was pretty basic. This was just a fun project for me, and I wanted to share with you guys how I pulled it off. I'm really just scratching
[16:47] the surface of what ESP home can do, and there are a lot of people out there doing really cool things, from automatic coffee bean roasters to car presence detectors, and more. Heck, I'm sure some of you guys have also had a lot of cool projects, so let me know what you've done with ESP home down in the
[17:00] comments below. I know this video was quite a bit different than some of the content I normally do, but I had a lot of fun, and I hope you did as well. If so, maybe consider liking, subscribing, or becoming a raid member for as little as a dollar a month. With that, you get early access to
[17:13] ad free videos, I think it's a pretty good deal. That's about it for this one though, so as always, thank you guys so much for watching, stay curious, and I really can't wait to see you in the next one.