 Today we're continuing our home automation tutorials. This is part of the series. I recommend watching the previous videos, or otherwise you're going to be lost because we're jumping into the middle of something here. And today we're going to be looking at thermostats. Now again, remember, I have no clue what I'm doing when it comes to electricity or really any type of hardware, so do this at your own risk, I recommend not. But hopefully we're going to learn something today, looking at my crooked little, cheap little thermostat here. And show you how to take a raspberry pi and turn it into a smart thermostat. Okay, I have this cheap, cheap little thermostat. It'd be nice if I had a smart thermostat, but those are like $150 to $200 on the low end. But the way the air conditioning units work is very basic. It's just three things. You've got your heat, your fan, and your cooling, and they're just on and off switches. So let's go ahead and have a look at the wiring here. The faceplate pops off real easy like that. It's just a computer board here. And this is all the smarts. This checks the temperature and sets it if it's at a certain temperature, turns things on or off. Now in here, we have different color wires. We have our red, which is our power. Our black, which is our ground. And then we have a green, yellow, and white in my case. And that seems pretty standard from what I've looked up online. Green is the indoor fan, I believe. Yellow is our cooling. And then white is our heat, which I live in Florida, which we turn on heat like twice a year. So I'm not going to worry too much about that. Today we're going to be hooking up to our fan and to our cooling system. Now I've got myself, my multimeter here. I'm going to set it here to DC 200. And I'm going to test out the voltage here. So I'm going to take my leads here and get this close enough. I'm going to touch to the red power, and I'll touch to the green here. And I'm getting 26 volts, which is right from what I've looked up. I think it should be between 24 and 26. Now if I do the cooling, I get the same thing, 26 volts. So now that I've checked with my multimeter to confirm these wires putting out the voltage that the manual that I've read online says that it should be, I'm going to try jumping two wires. I'm going to jump the red power line to the green line, which should be my indoor fan. So we'll start circulating here. I'm going to do that because I can definitely hear the fan when it comes on. I don't know if you'll hear it in the camera, but within a few seconds of connecting it, I should hear my fan and the air circulating through the vents. So that ends connected to the red. I'm going to connect this one to the green. And you probably didn't hear it in the camera, but the air is now circulating in my house. We're not cooling. We're just circulating. If I connected the power to the yellow line, we'd be cooling as well. But that's what we're going to do right now with our Raspberry Pi now that we know that we can turn things on and off just by jumping them, which is the same as a switch, which is the same as a relay, which is what we've been working with. I have my relays here and I'm going to hook them up with these alligator clips. So here I have my Raspberry Pi hooked to my network with a cheap little USB Wi-Fi dongle. Right now I'm powering it off of a battery, but you can also get yourself different power supplies such as this one here. This little power supply here, which is actually kind of a big power supply for this project. I got for a few dollars off of Amazon. I can probably get it cheaper other places. I've spliced a USB cable and connected it to here. But what this allows you to do is it works just like your wall charger for your Raspberry Pi or cell phone, except for I can feed wires directly into it, taking the normal 120 volts we have coming out of the wall here in the US and knocking it down to five volts. So if I was to do this project permanently and mount things in a panel on the wall, I can power the Raspberry Pi off the same wires that I'm powering whatever device I'm powering with using this. But for now, just for testing, I'm using this old $20 cell phone external USB battery. As we've done in previous videos, we're using GPIO pin four, which is this green wire here to turn on one of our devices. But since we have two devices to turn on and off, we're using a second GPIO pin, GPIO pin three, which is this yellow wire here. There's Google diagrams and follow previous videos I've done to get a look at what these wires are. The blue wire here is ground and the purple wire I'm using is our five volt. Really, if you're gonna do this as a permanent project, you may wanna color code these a little bit better, red being power, black being ground. But just for this, I grabbed whatever wires I had. Now I have them all connecting to a breadboard. This is really unnecessary, but although I've ordered female to female wire connectors, they have not come in yet. So I only have male to male and female to male. So I'm just using the breadboard as a little medium connection between my Raspberry Pi and our relay over here. But the breadboard is not needed at all. You can go directly to the relay board. I know the lighting isn't the best here. Now in the previous video, we used just a single relay. Here I have my eight relay board just because I only have the two. I have a single relay board and the eight relay board. We really only need, if you're really gonna set this up, you would need three because you would want, probably want heat as well. But I'm just using the first two relays, one for the fan and one for turning cooling on and off. And then so we have our wires coming here from our Raspberry Pi. Now to the far left here, they're marked very clearly on the board here. This is ground, so that's on the far left. The far right is our five volt power coming from our Raspberry Pi. And then we have our GPIO pins going to the first and second input, which control the first and second relay. Now each relay has three connectors, but you really only need to use two because we're just turning one thing on and off. So I'm gonna have one line going to the center pin of each relay. And then here I have one going to the third pin of each relay or you can go to the first, depending on whether you want the signal to turn it on or off. If you want to reverse it, you can reverse it in the code or reverse it here. Now I have those wires going up to the alligator clips. Now I have one of these is our fan, one of these is our cooler, or yeah, our cooling. And then here, since there's only one screw head to connect to with an alligator clip on the coming from the air conditioning unit, and I couldn't get two alligator clips on there. I'm just splitting one alligator clip up right there, but this is our connections here. Now obviously, in a final setup, you probably wouldn't even need this panel. You'd have something set up and directly connected to the relays instead of alligator clips. That would be a bad thing to have set up permanently. Again, I'm sorry about the lighting here. My hallway isn't the best lit, but we have our connections to our Raspberry Pi, Raspberry Pi, so it's my network. So if I did a port forward, I can access this anywhere in the world that I have internet access. And I have my web interface here, which is the same web interface I designed for the Cancun smart plug, the Cancun smart plug that I did videos on earlier. We've also used with our Raspberry Pi in the last two videos just as, because it's basically the same, I just change what connections I want to send outputs to. I added a second button to the web interface here so I can press each one and one will be cooling and another one will be the fan. So I press both of those and in the second here, the fan goes on. So that is how you can control your thermostat with a phone, but of course, you're not going to want to manually be turning your air on and off throughout the day. So what you would need to do is get yourself a temperature sensor of some sort, probably one that goes to GPIO pins, but you can also get USB ones. I don't know how accurate they are. I would think that they're fairly accurate. But then again, your Raspberry Pi is replacing this board right here that was in the wall. And all this does is checks the temperature and checks what you set it to. So if you set it to 73 and it gets below 73 and you have it set to cooling, the air comes on. So all you have to do is write a script that constantly monitors the input from your temperature sensor, which I think you can get those fairly cheap just for a few dollars. The USB ones are probably a little more expensive, but it just constantly monitors that. It doesn't even have to be like real time. It can have it check it every minute because an air conditioning unit who cares if it takes an extra minute or turns on, but that's up to you. You can have it check multiple times a second or you can have it check every minute. And if it's below a certain temperature, kick it on. When it gets above a certain temperature, kick everything off. You can also set times. So if you want to set it days of the week at certain times, it activates at a certain temperature, just like any smart plug. It's all in the coding. Our hardware is very simple set up. And another thing you could do is, for example, in my house, I have a thermostat over here. It's by the master bedroom. My office and the other end of the house towards the front where the sun beats in all day. So my office is a lot hotter than the rest of the house. So I could have a Raspberry Pi or some other device, such as I mentioned recently, it hasn't come out yet, but there's that new $9 chip computer, which hopefully is successful because it will knock down the price on something like this drastically. But with a network connection, I could get myself one of those USB temperature sensors, plug it into my desktop computer and have it send a signal every minute to my Raspberry Pi. And the Raspberry Pi can check at the temperature here or the temperature over there. And at any point, if either of them get above 80, which is pretty warm, it's gonna kick on the air. So even if my office gets hot first, the air will kick on. Now, the rest of the house might be a little bit cooler, but at least I can gauge the temperature over there, which is where I spend most of my day. But once you have the hardware set up the software is whatever you can imagine, which is great. So I hope you learned something. Again, from my understanding, from what I've read online and looked in manuals for different thermostats, it's pretty standard that the green line is your fan, the yellow line is cooling, white is heat. And then you have your black and red for your ground and your power. And again, with a relay, it's just like turning a switch on and off. Just like on this, you have a manual fan on, fan off. I can set fan to auto or fan on. Well, that's just what a relay is doing. Relay is doing this whenever you tell it to. So you can have it do that whenever you like for whatever reason. You're the programmer, you're in control. You decide. I thank you for watching. And as always, I hope that you have a great day. Please visit FilmsByChris.com, that's Chris Decay. There should be a link in the description. As well as some notes, you may want to check in the description to this project and other projects. Also, please think about supporting me on Patreon, patreon.com forward slash milx1000 again. Thank you for watching and I hope that you have a great day. Okay, this is an introduction to FilmsByChris.com. I'm Chris, that's Chris Decay. That's me right there. My daughter, Amber. And my wife, Jennifer. We pretty much live in the swamps of Florida. I'm a firefighter by day. As well as by night, we work long hours. But that's not why you're here. You're here about the videos I put up on YouTube. These videos are mainly about computers and programming, which means most of my videos look something like this. And if that's what you're interested in, great. If not, that's all right. I do videos on other topics too, such as video editing, special effects, photo editing, 3D design, and music creation. If you are one of my viewers and you enjoy my videos, my Patreon page is a place where you can go to help support my videos. So I ask that you take the time to go to my Patreon page and look at different levels of rewards you can receive for different levels of backing. There should be a link in the description of this video if you were watching it on YouTube. Otherwise, you can visit patreon.com forward slash milx1000. And I thank you for your time and your support. Have a great day.