Penta Sata Hat Top Fan not working as it should on Raspi 5

Hy there, after installing the top fan on the penta sata hat, I installed the software as well

I have increase the temperature to start the fan earliest at 60°C in the /etc/rockpi-penta.conf.
After systemctl restart rockpi-penta.service and/or rebbot the fan is off(CPU temp below 50°C), but every 3 seconds my fan starts for some few turns and stops. Repeating all over again. This can´t be right. Any solutions? Maybe depending as well on the i2cdetect -y 1 resulting in a 3c in line 30?
Help would be appreciated, thanks.

… You might have noticed as well that sometimes suddenly the fan starts spinnig for a fraction of a second without any reason. …

maybe that could help

Hallo Michael, great, tausend Dank!
After some searching around, I found the fan.py in folder /bin/rockpi-penta and could adjust it to your proposal, reboot and voilà!
It worked. I tested with different temperatures of the CPU, a great success, the fan spinning a fraction was gone!
Still I am related to the CPU temperature and try to adjust this to the harddrive temperatur. I couldn´t find details, where to adjust this parameter. I have 4 sata SSD’s on the penta hat and one reading value of one of the SSD’s would be enough.
Can you give me (beginner level) an idea, where to find the parameter to adjust as you did already?
I guess something needs here to be adjusted in fan.py:
def read_temp()

With sudo smartctl -a /dev/sda | grep “Temperature” I get at least values, here 33°C:
190 Airflow_Temperature_Cel 0x0032 067 051 000 Old_age Always - 33

Your solution with the additional sensor seems to be total different.

the smart values may differ per drive
my SSDs and HDDs show on value id 194 the needed temperature
194 Temperature_Celsius 0x0002 063 053 000 Old_age Always

I needed the external sensors in my Pi4 setup
With Pi5 I managed to not need them any longer
the script is basically the same - you just modify instead reading w1 temps now reading drive temps with smartctl using misc.check_output()

Thanks Michael.
The exact Temperature to work with I get with
smartctl -a /dev/sdb | grep “Temperature” | cut -c 88-90
Returns for example
45
meaning 45°C.
First thing solved and now I stuck in the middle of somewhere.
Withoput programming knowledge I tried to modify misc.py and fan.py to adjust in someway to my reading value. But I don´t know how to do it. Got errors on the fan, display off, full fan and mixtures of all conditions :wink: tried and tried…and now I brought it back to original code.

My original code in fan.py:
def read_temp():
with open(’/sys/class/thermal/thermal_zone0/temp’) as f: >>results for example 59000 for the CPU
t = int(f.read().strip()) / 1000.0 >>results then 59
return t >>results 59

I guess I need to bring the reading of smartctl -a /dev/sdb | grep “Temperature” | cut -c 88-90 >>which is resulting in 2 figures for example 45
into return t
But how?

Following code did it, as first try with chatGPT test:
import subprocess

def read_temp():
# Befehl ausführen und Ausgabe einlesen
result = subprocess.run(
[“smartctl”, “-a”, “/dev/sdb”],
capture_output=True,
text=True
)

# Nach der Temperatur suchen
for line in result.stdout.splitlines():
    if "Temperature" in line:
        # Temperatur extrahieren
        temp_str = line[87:90].strip()  # Hier wird der relevante Teil der Zeile extrahiert
        return float(temp_str)

return None  # Falls die Temperatur nicht gefunden wurde

Thanks Michael, you helped me a lot and the thing is solved! :slight_smile:

Thank you for your feedback, I’m happy to help.

One more hint:
I was facing randomly disconnects of all disks.
There was no upfront indication in dmesg or journalctl, dmesg just stated

AHCI controller unavailable

This happend after some minutes, after some hours, after a day.
On a Debian image installation and on a DietPi installation as well.
As there was no pattern visible (e.g. time, load, temperature) I assumed it is a race condition between smartd (which comes with installation of smartmontools) and ongoing smartctl.
So I stopped and disabled smartd and since then it never happened again.

Thank you Michael, good to know. At the moment I perform tests with Raspi5, penta sata hat+top board, RaspiOS light64 and OMV to see how it works compared to my old fritznas.
If I run in trouble…as now, I think of your smartctl issues…
On Windows 11 I crashed in the last few hours 2 times the Raspi/OMV at 10GB data transfer tests…and needed to restart the Raspi with its button, due to no connection anymore with smb or on the local IP’s. Now I’ll try to figure out, if this happens only on Windows (at 150-250 MB/s with 2,5Gbit Realtek adapter). Windows is great on smb speed, compared to Linux (only 100 MB/s could be reached with 2.5Gbit setup).