For the Raspberry Pi, OpenCV project that I've done recently, and I'll put a link in the description and on the screen, I have printed this nice case for the camera. The only thing with it is that once I put it inside and pop this at the back. It makes this connector here just pop out of place and disconnect the camera from the actual PCB.
So what I'm going to do I'm going to use a little of hot glue, keep it inside probably remove this wings here and glue this at the back so that's, one thing with. The camera the other thing is that I ordered a fan since the Raspberry Pi, 4 tends to get really hot and uh. The thing is that I don't want to have the fan running constantly, so I'm going to write a program that is going to get the temperature of the core out of the OS. And then out of that make a decision if to switch it on or switch it off so let's go to work.
I remember there is a simple way of getting the temperature. And I was right it's this command, so I'll, put it in the terminal as you can see I'm. Getting the temperature, which is 45 degrees Celsius. Now what I did is just I the measure temperature, what it does, it just takes it, and then just trims everything out of it and returning it as a float.
And what I do in my loop is I just get the temperature making sure if it's over the threshold temperature, which is currently 50 I'm switching on the GPO, which is connected to a NPN transistor. And then in return operates the fan. And if the temperature is below, I just switch it to low, and there it. Switches off the fan and that's all those few prints here, and it worked just wonderful. So, uh, let's run it here, see it working, and I'll show you on the bench. So now all I need to do is to run through the python for the temp control by.
And you can see it measures every 30 seconds just send it to sleep for 30 seconds. So every 30 seconds there will be a measurement here. And if it will be over 50, which is this value, it will switch on the fan now let's concede on the back. So here is the setup there's.
A lot of wires and I'll explain this goes to 5, volt and ground that's. So we can actually power the fan. This goes to the GPO that is down here. Now, a GPO through a resistor switch on a NPNS 8050 resistors that that will give us the ground. And I switch on the LED and the phantom as well, and it's getting the 5 volt from here. Now, one important added thing is, of course, a fly back current diode here. So when the fan stops, we don't kill anything in our system.
So I'm going to change the temperature a little.A bit in the software, so it will make the fan run faster or earlier. And yes, I'll show you how it works. So I changed temperature threshold to be 45 degrees as you can see. Now the fan got switched on. And the LED is well, and my guess will be within 30 seconds, which is the time it takes to check the temperature again. It will switch it off because it's going to drop below 45 due to the fan cooling things down. So we're going to wait a little I'm going to make fast-forward.
And as you can see, it got switched. Off brilliant now, I have to solder all of this and think of a clever way to put it on top of here. And as I mentioned before, I've glued the camera, and I'm going to make some way of making a box, maybe a 3d print, something that will hold this. And this one on top of the other somewhere around here. So let's go solder done soldering. Now I decided to add one more feature, which is a switch.
And the reason for the switch is that I want to be able to turn on the fan without having to run the software. So I got. Two grounds one is connected directly to the ground if a knife connect is, you can see the fan is working and the same goes for the ground that comes out of the NPN.
And if I touch it since the software is running it's its, it runs the fan. Those two wires will go to a LED so that my next step is to create a box that will sit here and will be the base of this as well going to put it on the top, uh, well, let's go, try and mix up make a box for this brush out of the printer. I'll, take it out and see if it. Matches the PCB almost my printer isn't that great when it comes to scales and um tolerances.
So it doesn't fit in I need to add. I don't know, just a little more. And also I probably need to put support when I put it out because it's all messed up here. I need to have filament issues. So that could be it, but all in all it's exactly what I wanted. This will go here.
This will go inside this connects here with the fan up. I've checked the phone and then check that oh, goes wells inside brilliant and. Then this will be seated here, I'll probably just make two pegs that this will be. Okay.
It will sit on, or I'll just make two holes and or indent. I don't know, I'll make something here to mount it too. And then if I want to remove, I can always remove just the camera and leaving that base here.
Well back to fusion 360. This me fits just right. And you can see the mountains are just everything is perfect here. But I created two pegs those two little things those two little things. And when I snapped trying. To get this off the 3d printer and the other one when I snap this in and try to take it out.
So this won't work, and I'm now, just debating between just making a raised platform with this size, and then making two holes for a screw or just glue this like this here and get it over with I'll think about it. I have to print another one anyway, because I want to make it a little taller, and I have to make a cover for this and have a place for the switch. And the LED, wow, that was a hard one. I had. Endless problems with the printer, it kept failing, but I fixed it. And I finally managed to print the part it's about eight trials and kept on failing and stopping in the middle. Now I have extended the height here.
So I can have a cover with the switch in it without a touching anything inside a LED as well, probably use three millimeters another five millimeters. And as you can see, I made a raised platform here use two metal screws and attach the camera to the base. So I'm really happy with. This result, so yeah, now I need to create the cover that will go on top. It took a few trials as you can see to get the size of the hole just right for the switch and a LED here. Now what I'm going to do is I'm going to solder the LED to the board, and then I'm going to cut it to shape cut it into size, make sure it fits in.
And then I need to glue the switch into place, um solder the three wires that goes to it, and then I'll probably glue. The LED into place. Then I'll, probably just put a few drops of.
Hot glue in the bottom drop this in and have the cover on top of it. The cover should go like this. Well, soldering first done soldering it's a bit tight in there and uh, what I need to do now is, of course to run a test before I, um, close it in the box. So I'm going to connect everything up fire up the Raspberry Pi and test it. And if it's all fine I'm, just going to put in a bit of a hot glue in the bottom, push it. In the case holds tight against the box itself. Well, let's wire it up and start it up.
I like. When it happens while trying to work it out, everything just failed, and I think it's all to do with this, um honest, the pins inside here got loose. I added hot glue. And I guess they were not anyway. I need to rebuild this part.
And as you can see now, it's working, if I switch this on, and if I switch the software, this side is working as well, so I'm going to create a new honest for it. I think I might shorten this, but maybe later and uh, yeah, box it and get it to work all in place and working well. I've. Created a new harness for here.
Well, next step is as I said before is to put this into the box and glue it in all in place, working great I'm, super happy with the result. The last thing I need to do is to make sure that the python script runs on the load of the raspberry, so it will kick in automatically, and I'm done. So the last thing we have to do is just make adjustment to the RC local and add this line to the end of it, and this will automatically run the script.
I hope you enjoyed the video. And if. You haven't done it by now please subscribe give us a thumbs up or leave a comment see you next time you.