🛠 Refroidir le CM5 : ventilateur PWM sur le connecteur JST-SH et tachymétrie
Objectives
The CM5 delivers significantly more performance than the CM4 and generates more heat (throttling at 85 °C case temperature); the CM5IO Board provides a 4-pin JST-SH fan connector (5 V, Fan_PWM, tachometer, GND) and the firmware controls the PWM similarly to the Pi 5. This tutorial covers wiring the fan, reading the tachometer on Fan_Tacho (GPIO29), and understanding the documented pitfall: Fan_PWM stops at shutdown, but a fan powered separately with 5 V may continue to spin if the carrier board does not cut its power supply.
Hardware
- 1 × CM5 on a CM5IO Board (or a carrier board featuring the JST-SH connector, ref. JST BM04B-SRSS-TB on the board side)
- 1 × 5 V PWM 4-wire fan (Noctua NF-A4x10 PWM type or equivalent)
- The official IO case has a known v1 defect: it is impossible to mount both the CM5 Cooler and the pre-installed fan (fixed in v2)
sudo apt install -y python3-gpiozero
Complete Code
#!/usr/bin/env python3
# rpm-ventilateur.py — lit Fan_Tacho (GPIO29) du connecteur ventilateur CM5IO.
from gpiozero import DigitalInputDevice
from time import sleep
compte = 0
def tick(_):
global compte
compte += 1
tach = DigitalInputDevice(29, pull_up=True, bounce_time=0.0005)
tach.when_activated = tick
sleep(5)
rpm = compte / 5 / 2 * 60 # 5 s, 2 impulsions par tour (typique)
print(f"~ {rpm:.0f} tr/min")
tach.close
# Température et état de throttle pendant la montée en charge
vcgencmd measure_temp && vcgencmd get_throttled
sudo apt install -y stress-ng && stress-ng --cpu 4 --timeout 90 &
sleep 45; python3 rpm-ventilateur.py; vcgencmd measure_temp
Expected Verification
The script displays a stable speed (e.g., ~2000 RPM); under stress, the temperature rises and the firmware accelerates the fan (the displayed speed increases, get_throttled remains at 0x0). Upon shutdown (sudo systemctl poweroff), the fan connected to the IO Board connector must stop — if it is still spinning, your carrier board does not cut the 5 V supply to the fan.
Common Errors
- Fan spinning after shutdown: documented in the datasheet (§2.11) — share the VBUS_EN line or add a 74LVC1G07 buffer on the carrier board to cut the 5 V supply.
- IO case v1 + CM5 Cooler: the two do not fit together; remove the pre-installed fan or switch to the v2 case.
- Tachometer without pull-up: the open-collector signal of a fan remains floating without
pull_up=True— guaranteed zero count. - Swapping PWM and 5 V in the JST-SH connector: verify the pin order on the fan side before powering up.
Other tutorials for this board
- Alimenter un CM5 comme il faut : USB-C PD 5 V / 5 A et bouton d'alimentation
- La première RTC des Compute Modules : câbler et vérifier la VBAT du CM5
- Accès distant sans VPN : enregistrer un CM5 dans Raspberry Pi Connect
- GPIO du CM5 côté RP1 : force de conduite, budget 50 mA et broches pièges
- Deux ports USB 3.0 simultanés : le CM5 fait du stockage rapide, pas sur une carte CM4
- Démarrer le CM5 sur un SSD NVMe dans le socket M.2 de la CM5IO
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash