Rock64 FAN Control?

Hello,

I have a Rock64 and would like to throttle the fan to only run when needed.

I saw that dietpi seems to have some fan control features on github, but I have no idea how to use them.

I have a regular fan and a transistor and resistor setup to drive it from a GPIO pin. I dont know where to begin on the software side though.

DietPi do not have a fan control at the moment. Pls can you linke the GitHub issue you are referring to.

Ok,

I think I misunderstood this github entry:

https://github.com/MichaIng/DietPi/blob/master/.meta/dietpi-fan_control


Regarding Rock64, maybe this is something I can add.

What is the underlying OS for the Rock64 version of Dietpi?

don’t think this is already working. This is basically the issue where all thinks around fan control are collected https://github.com/MichaIng/DietPi/issues/1818

Rock64 might be Armbian but I’m not 100% sure. Let’s ping the developer MichaIng

Ok, I reached out to him.

These scripts seem relevant. They detail a way using Armbian for driving a fan via GPIO with one script or PWM with a different script to drive fan for controlling temperature.

https://github.com/Matei-Ciobotaru/Temperature-Control-Scripts

well the main aim is to have a more generic fan control utility covering more platforms :slight_smile:

The dietpi-fan_control script controls the native PWM fan connector, if available, via native sysfs tunables, not a custom GPIO-attached setup. But that idea came up as well: https://github.com/MichaIng/DietPi/issues/1818#issuecomment-852926755

Yes the ROCK64 DietPi image is based on Armbian and basically Debian, of course. There is no device tree overlay required to enable the GPIO itself, but only such to enable I2C, SPI, UART, 1-Wire devices/interfaces on those pins.

The scripts you linked seem like a good starting point. An “R64.GPIO” (forked from RPi.GPIO) library is used to read and control the GPIO states. But the script reads the temperature from an Armbian file /etc/armbianmonitor/datasources/soctemp instead of directly from the kernel interface.
Check out these files, where at least one of them should provide the CPU temperature (or another one within those directories):

cat /sys/class/thermal/thermal_zone0/temp
cat /sys/class/hwmon/hwmon0/device/temp_label
cat /sys/class/hwmon/hwmon0/temp2_input

and replace /etc/armbianmonitor/datasources/soctemp in the respective Python script. The format should be the same (milli degree Celsius).

Hi,

Thanks for the insight!

/sys/class/thermal/thermal_zone0$ cat temp

returns a value like this:
43636

How do I decode that into temperature?

43.636 degrees Celsius?


I will see about using those scripts as a starting point.

The scripts do that already:

43636 milli degree Celsius / 1000 = 43.636 degree Celsius