Rock64 FAN Control?

Having issues with your DietPi installation or found a bug? Post it here.
Post Reply
NJNinja
Posts: 4
Joined: Sun Jun 20, 2021 9:30 pm

Rock64 FAN Control?

Post by NJNinja »

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.
User avatar
Joulinar
Posts: 5090
Joined: Sat Nov 16, 2019 12:49 am

Re: Rock64 FAN Control?

Post by Joulinar »

DietPi do not have a fan control at the moment. Pls can you linke the GitHub issue you are referring to.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
NJNinja
Posts: 4
Joined: Sun Jun 20, 2021 9:30 pm

Re: Rock64 FAN Control?

Post by NJNinja »

Ok,

I think I misunderstood this github entry:

https://github.com/MichaIng/DietPi/blob ... an_control


Regarding Rock64, maybe this is something I can add.

What is the underlying OS for the Rock64 version of Dietpi?
User avatar
Joulinar
Posts: 5090
Joined: Sat Nov 16, 2019 12:49 am

Re: Rock64 FAN Control?

Post by Joulinar »

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
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
NJNinja
Posts: 4
Joined: Sun Jun 20, 2021 9:30 pm

Re: Rock64 FAN Control?

Post by NJNinja »

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/Temp ... ol-Scripts
User avatar
Joulinar
Posts: 5090
Joined: Sat Nov 16, 2019 12:49 am

Re: Rock64 FAN Control?

Post by Joulinar »

well the main aim is to have a more generic fan control utility covering more platforms :)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 3088
Joined: Sat Nov 18, 2017 6:21 pm

Re: Rock64 FAN Control?

Post by MichaIng »

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/issu ... -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):

Code: Select all

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).
NJNinja
Posts: 4
Joined: Sun Jun 20, 2021 9:30 pm

Re: Rock64 FAN Control?

Post by NJNinja »

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.
User avatar
MichaIng
Site Admin
Posts: 3088
Joined: Sat Nov 18, 2017 6:21 pm

Re: Rock64 FAN Control?

Post by MichaIng »

The scripts do that already:
- https://github.com/Matei-Ciobotaru/Temp ... fan.py#L60
- https://github.com/Matei-Ciobotaru/Temp ... pwm.py#L93

Code: Select all

43636 milli degree Celsius / 1000 = 43.636 degree Celsius
Post Reply