06-17-2021, 12:27 PM
(This post was last modified: 06-24-2021, 09:25 AM by CounterPillow.
Edit Reason: list of price, more explanations, etc.
)
I've discovered gpio-fan, which allowed me to use four GPIO pins on the ROCK64 to send a four bit signal to an external Arduino. The Arduino (a ATmega32U4 pro micro clone, you can get them for $3) is at 5V, so it first goes through a level shifter. Its job is to interpret the 4 bits of data as 2^4 (=16) PWM levels, and soft-PWM out a 25 kHz signal for the fan. This all works pretty well!
You can find the dts changes I needed to make in this gist, simply apply it to a kernel tree and run make dtbs, then copy the resulting rock64 DTB somewhere into /boot/dtbs and use it in your bootloader. The arduino sketch can be found in the same gist. If you are using a different fan, you may have to adjust the RPM values, but they're really only for show since the ROCK64 has no way of knowing how fast the fan is really running. Noctua's PWM to RPM relation is almost linear, so I went with a linear conversion here. The fan starts at 1000 RPMs because that's the minimum it can do according to Noctua.
The 3.3V to 5V level shifter I'm using is from SparkFun (but you can easily find cheaper clones of it all over eBay), simply wire the 5V side to the HV pins, and the 3.3V (ROCK64) side to the LV pins. The Arduino can be powered from the ROCK64 5V pin. Make sure to also run a ground between the Arduino and the ROCK64.
The whole thing can be improved for sure, e.g. changes to the hysteresis and the threshold at which the fan turns on, and obviously getting the whole thing on something that's not a breadboard would be ideal. But for now, I'm quite happy with the results. And yes, using 4 GPIO pins for this is very silly, especially without more fine-grained fan levels in the device tree, but if I've got a 4 channel logic level converter I might as well go full silly.
I've also oriented the fan around the other way so that it now blows onto the heatsink.
Overall cost of project:
You can find the dts changes I needed to make in this gist, simply apply it to a kernel tree and run make dtbs, then copy the resulting rock64 DTB somewhere into /boot/dtbs and use it in your bootloader. The arduino sketch can be found in the same gist. If you are using a different fan, you may have to adjust the RPM values, but they're really only for show since the ROCK64 has no way of knowing how fast the fan is really running. Noctua's PWM to RPM relation is almost linear, so I went with a linear conversion here. The fan starts at 1000 RPMs because that's the minimum it can do according to Noctua.
The 3.3V to 5V level shifter I'm using is from SparkFun (but you can easily find cheaper clones of it all over eBay), simply wire the 5V side to the HV pins, and the 3.3V (ROCK64) side to the LV pins. The Arduino can be powered from the ROCK64 5V pin. Make sure to also run a ground between the Arduino and the ROCK64.
The whole thing can be improved for sure, e.g. changes to the hysteresis and the threshold at which the fan turns on, and obviously getting the whole thing on something that's not a breadboard would be ideal. But for now, I'm quite happy with the results. And yes, using 4 GPIO pins for this is very silly, especially without more fine-grained fan levels in the device tree, but if I've got a 4 channel logic level converter I might as well go full silly.
I've also oriented the fan around the other way so that it now blows onto the heatsink.
Overall cost of project:
- 1x Arduino clone, 5V: ~$3
- 1x level shifter: ~$1
- 1x Noctua 5V PWM fan (or similar 5V fan): $10 to $20
- 3d printer filament: negligible (<$1)
- jumper wires, breadboards, pin header rows: I assume you already have this, but <~$10 if you don't
Occasional Linux Kernel Contributor, Avid Wiki Updater, Ask Me About Quartz64
Open Hardware Quartz64 Model A TOSLink Adapter
Pi-bus GPIO Extender For ROCKPro64 And Quartz64 Model A
Plebian GNU/Linux