Build a small PWM Hat for Raspberry Pi that allows you to easily connect a fan, LEDs, a motor or anything else you need to control with it! Introducing the PWM Mini-Hat by eMariete.
Following this tutorial, you will be able to build, with very few components, a small controller for the Raspberry Pi to control by PWM low and medium power loads, such as a fan.
Why a Mini Hat for Raspberry Pi?
I wanted to put a temperature-controlled fan on my Raspberry Pi 4, and I wanted it to work really well and be small and unobtrusive.
This PWM driver for Raspberry Pi does not differ much from other existing drivers. Its great advantage lies in its mounting formatwhich allows it to be installed easily, safely and discreetly.
What does this Mini Hat do?
The Raspberry Pi 4, by itself, is capable of delivering very little power on its pins.
When we want to connect something to the Raspberry Pi that consumes more than what its pins are capable of providing we need to a pusha circuit that increases that energy.
This PWM Mini Hat allows you to connect many devices to the Raspberry Pi that you would otherwise not be able to.
The Mini Hat PWM scheme
The circuit diagram is as follows:
It is the same as the one we already used in the article PWM driver with MOSFET transistor and which you can find here with all the details on how it works. I recommend you to read it!
Assembly of the PWM Mini Hat
Basically, what we are going to do is to assemble the circuit in a compact way, but without complicating our lives, over a perforated prototype plate (a Perf-board).
The important thing, and what makes it different, is that we are going to mount a DuPont female connector which will allow us to mount it directly on the 40-pin connector of the Raspberry Pi.
As we will see, once we close the box, you can hardly see that it is there.
The assembly is very simple. The only difficulty you may encounter is that the MOSFET is an SMD component and needs a bit of attention, pulse and holding your breath when soldering it. Nothing you can't do.
In this image you can see the approximate distribution of components that we want to achieve.
You don't have to make it exactly as it is here. In fact, you may get a better distribution of components.
If so, please leave a message in the comments telling us about your achievements.
PWM Mini Hat assembly video by eMariete
To make it easier for you, here is a video of the assembly of the Mini Hat PWM.
I hope that, between the video and the information in this article, you won't have any problems setting it up.
If you still encounter any difficulties or have any questions, leave a message in the comments and I'll try to solve them for you.
Making these videos takes a lot of work. If you like the video don't forget to "Like" and subscribe to the channel. That's will motivate me to keep making more videos like this one.
Use of the Mini Hat PWM
Although you can do a lot of things with this circuit, one of the most common uses is for connecting a fan to a Raspberry Pi.
Don't miss the following tutorial, where you have a great solutionwith a step-by-step explanation and all the necessary software to control the fan based on the CPU temperature:
I hope that something as simple as using a strip of cut pins will give you some ideas to use it in other similar cases. Many times, you don't need specific connectors (expensive and hard to get) to do interesting things.
Please note that this assembly, although it has turned out very well and is fully functional, is a first version, a first prototype. I'm sure the next one I build will be much better. For example, now I know how to cut the terminals of the components to use them to make the connections.
Here are some related articles that may be useful for you to go deeper into the subject: