Raspberry Pi Controlled Laptop Cooling Pad. The Hardware Story. (Part I.)
Introduction
Somewhere last year I’ve got a cheap Amazon-purchased pad with five fans inside. And so no expectations then. Pretty soon both USB inputs started to act up and eventually the thing has stopped both cooling and being cool. Perhaps it has never been the latter. Anyhow, I decided to fix both.
Five fans inside the pad were powered up and controlled by a small circuit: two USB inputs, six 2-pin outs for fans (why tf it’s six if there’s only five fans?) one transistor, one capacitor, one resistor and one rheostat (which also serves as the on/off switch).
Theory behind that is quite simple: no power — no fans movement, once the thing is powered up, RPM is being controlled by a rheostat. The less resistance — the more voltage and vice versa. Not that much complicated, innit?
The Idea
So the idea is as simple as I would put some temperature sensors inside the pad and thus would control fans’ RPM based on the measurements. At this point I just purchased two DHT22 sensors and walked through the endless amount of articles on the internet about how to connect sensors and read their measurements.
The Discovery phase
Once I disassembled the entire thing, I decided to stick with the original circuit and simply to replicate it on breadboard. Pretty soon I realized it’s no way to go, but first things first.
And so the first thing was to at least find a way how to connect a fan to your RPi. It has been done a thousand times before, so 30 seconds of googling would lead you eventually to the RPi forum. Here are some pics, describing the idea:
As you can see here, the proposal is to power up the fan straight up from RPi and to control it then using RPi’s PWM pin via an open collector connection (NPN transistor, resistor and diode). Another way of depicting this is:
Idea is simple: once you have your electrons running towards the base of transistor, a fan chain is now opened and the fan is moving. So far so good. All I need then is to have my fans connected the parallel way. Sounds simple and suitable, but does it really?
It does not. When I plugged only two fans, I suddenly realize it will not work for me. Original fans from the pad are 5 Volts creatures with a current higher than RPi can provide you with(400mA vs required 700mA). As a result, having 100% PWM duty cycle, fans were barely moving, which won’t help much cooling my very-hot-due-to-a-docker-running laptop. Alright, moving on then. What else could I do, eh?
PWM is the answer!
After thinking it through, I realized that PWM-controlled fans might help. I purchased one small PWM fan to start experiments, did a research and found one thread on the RPi forum. The author raised a question how to connect PWM-controlled fan to RPi. There’s been multiple proposals which, based on comments, didn’t work, so here’s the most recent one which is supposedly a working one:
Heads-up: it didn’t work either. Eventually nothing did from the thread I am referring to. But we’re not up here to give up, are we?
Here I should mention that the PWM fan I’ve purchased was Noctua NF-A4x10, which comes with pretty good documentation. And the pretty good documentation says “in order to maintain the correct shape of PWM impulses we do not recommend to use open collector circuit”. Sweet. What they proposed is MOSFET. Nay, way too complicated for such a simple task — I’m going my way, so come what may.
The My way.
When I’d thought I was about to reach out my intellectual capacity, I decided to go simple. What did I know back then? Open collectors are bad and simply didn’t work for me. MOSFET is good, but I am up to do the task with whatever is in my desk’s drawer (and “the Rolls-Royce of fans” is the only exception).
And I went simple: just connected the fan straight up to RPi’s PWM pin via a resistor and it just worked. Yes, experts on the matter would probably say it’s a bloody nonsense and “noobism” to do it like this, but, unlike all the very pro tips, it freaking works. Later on I got more fans, connected them in a parallel and that still worked like a charm:
The Implementation Phase
As soon as I was able to make fans cooling to the extent I want them to cool, I started to think how to go beyond the prototype phase towards a real working device. Firstly, your RPi is not a power supply. And so it ain’t quite good idea to even think of your Pi as such. Which essentially means I needed an external power supply. Originally I was planning to re-use the original circuit, but very soon it turned out I had to come up with my own one by multiple reasons:
- I need to power up DHT22 sensor(s) and to wire up the signal pin(s)
- I need to power up 5 PWM fans and to wire up their PWM pins
- There is absolutely NO WAY you mess up with the electricity and there’re no lights involved
Having all that in mind, I come up with the idea I needed 3 circuits to have some control over things:
- main power supply board to essentially control the power and being able to switch the entire circuit on and off
- fans’ control board powered up by the main power board
- DHT22 sensors’ control board powered up by the main power board
DHT22 Sensors Circuit
I decided to use two of them to think of a temperature inside the pad as of the average of the two. Nothing special about wiring them up, just keep in mind you need to have a resistor between data and VCC pins. Most of the guides on the internet are saying it’s something between 4.7 and 10 KOhms.
So I needed two groups of inputs for sensors, output group to connect to RPi and power input. I also added a led right after each input group for debugging purposes:
PWM Fans Input Circuit
As I’ve mentioned above, Noctua whitepaper says it’s possible, but not really recommended to use Open Collector. Regardless of their take on it, all you need is just to add a resistor before wiring up with RPi’s PWM pin.
One more thing worth mentioning: Noctua PWM fans are 4-pinned creatures:
That essentially means you have the full control, i.e. not only are you in charge of PWM, but you’re able to calculate current fan RPM based on Speed Signal pin output reading as well. This is a good thing to have. That said, you can still calculate RPM based on PWM duty cycle without reading the green pin. So it’s not that I was lazy, but I was limited by a geometry: first and foremost, by the space left inside the pad in between fans, second, by the size of a pcb board I have.
And again nothing special, 5 fans are wired up with via a singe PWM bus through 1K Ohms resistors and powered up from an external 5 Volts power supply. Output led, like before, just to debug.
Power Supply Circuit
USB was the original source of power supply for the pad, so 5 Volts it is. But as I’ve stated above you don’t mess with an electricity unless there’re no lights involved. So I found these ones to be useful in my project:
They have been powered up by two 3.3V batteries. I am not using RPi to power’em up, I’m safe then and 2x3.3 is still less than 5, so even more safety. Yet there was something concerned me in terms of a current, but I will cover that later. Since it’s an input/output point of the entire thing, I also need to have outputs for fans’ PWM, two sensors and the RPi’s ground. And like before some debugging stuff: on/off switch and led.
Now, time to check If everything is fine.
It was fine, but only from the first glance. I’d left them on for some time and fried up my skin touching them when I was back. So the mistake I made was not to mind the difference between USB’s and 2x3.3V batteries’ current. I started to play with resistors on the ready-to-plug board. At some point I found the sweet spot, though I should have done it way before then.
The Assembly Phase
I slightly mentioned before, I was limited by the internal size of the pad. I also faced another problem: my brand new PWM-contolled fans did not fit. It’s not that I had a hope and blindly purchased $100 set of fans. I was prepared with tool and will.
I’ve got rid of all the original mounts, leaving all my hopes to the fact fan’s mount holes were fitting the background cell just perfect. There was another problem though. How to bloody mount the power board.
One of my ex-gfs used to say: “The God saves alcoholics and idiots, so you, Kirill, is fully covered.” Indeed, the board size fitted almost fine — it was a bit bigger than the original length was, but has easily been fixed by the FatMax and some hardcore superglue. But before then, trying to wire really everything up:
And after some hours of cooking this kind of spaghetti:
Almost done, innit? Something was still bothering me.. I was managed to do the entire thing, but I still wasn't in control of everything. The very attentive one might have noticed I have powered up the lights without really being able to control them. And also I had the space in between two boards.
Lights control circuit
I had already protected the lights’ current on the power board, so all I needed is to wire them up via Open Collector. It suits just perfect now. Adding some additional 1K Ohm protection is still welcomed though:
And the physical result is:
I just had to add some wire up. Adding it to what I had earlier:
In the next part I will cover how I am going to control it. Thank you so much, If you still with me, reaching this point.
Links used:
- https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=244194
- https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging/wiring
- https://www.instructables.com/PWM-Regulated-Fan-Based-on-CPU-Temperature-for-Ras/
- https://blog.driftking.tw/en/2019/11/Using-Raspberry-Pi-to-Control-a-PWM-Fan-and-Monitor-its-Speed/