====== Raspberry Pi 4B ======
* https://www.raspberrypi.org/products/raspberry-pi-4-model-b/
===== Box =====
* https://www.prusaprinters.org/prints/4645-raspberry-pi-4b-box-noctua-fan-variable
* https://www.thingiverse.com/thing:3774560
===== FAN PWM Noctua NF-A4x10 5V =====
Source: https://www.domoticz.com/wiki/Raspberry_pi_fan_control_and_monitoring_with_bash
* N-channel MOSFET (e.g. 2N7000/BS170)
* https://www.tme.eu/cz/details/2n7000-dio/tranzistory-s-kanalem-n-tht/diotec-semiconductor/2n7000/
* https://www.tme.eu/cz/details/bs170d26z/tranzistory-s-kanalem-n-tht/on-semiconductor-fairchild/
* 0.1 uF electrolytic capacitor
* https://www.tme.eu/cz/details/rc1h104m04005vr/elektrolyticke-kondenzatory-smd-105degc/samwha/
* 10K resistor
* https://www.tme.eu/cz/details/1w-10k-1%25/metalizovane-rezistory-tht-1w/royal-ohm/mf01sff1002a10/
{{::rpi4b-fan-regulator-01.jpg?450|}}
{{::rpi4b-fan-regulator-02.jpg?450|}}
{{::pwm_driver_stripboard.png?450|}}
**PIN PWM:** BCM 18 (PWM 0) https://pinout.xyz/
**Specific fan speed and temperature breakpoints for Noctua NF-A4x10 5V**
#!/bin/bash
# Device references
dev_temp=/sys/class/thermal/thermal_zone0/temp
dev_pwm=/sys/class/pwm/pwmchip0/pwm0
dev_enable=$dev_pwm/enable
dev_duty=$dev_pwm/duty_cycle
dev_period=$dev_pwm/period
# Export pwm0 if it's not available
if [ ! -e $dev_pwm ]; then
echo 0 > /sys/class/pwm/pwmchip0/export
sleep 2
fi
# PWM frequency (nanoseconds)
period=1000000
# temperature breakpoints (millidegrees)
off_low=45000
low_off=40000
low_high=52000
high_low=48000
# fan-speed (nanoseconds)
low=930000
high=999999
# on/off values
off=0
on=1
# update interval (seconds)
interval=10
# initialise the fan
next=($off $low)
echo $period > $dev_period
echo ${next[0]} > $dev_enable
echo ${next[1]} > $dev_duty
update_status() {
if [[ $(cat $dev_enable) == 1 ]]; then
if [[ $(cat $dev_duty) == $high ]]; then
nvalue=3
svalue="High"
else
nvalue=2
svalue="Low"
fi
else
nvalue=1
svalue="Off"
fi
logger "Fan $svalue"
}
while [ : ]
do
temp=$(cat $dev_temp)
current=($(cat $dev_enable) $(cat $dev_duty))
if [ $temp -gt $off_low ]; then
next[0]=$on
if [ $temp -gt $low_high ]; then
next[1]=$high
elif [ $temp -lt $high_low ]; then
next[1]=$low
fi
elif [ $temp -lt $low_off ]; then
next[0]=$off
fi
if [ "${next[*]}" != "${current[*]}" ]; then
echo ${next[1]} > $dev_duty
echo ${next[0]} > $dev_enable
update_status
fi
sleep $interval
done
===== FAN PWM =====
* https://www.instructables.com/id/PWM-Regulated-Fan-Based-on-CPU-Temperature-for-Ras/
* NPN transistor 2N2222A
* https://www.tme.eu/cz/details/2n2222a-dio/tranzistory-npn-tht/diotec-semiconductor/2n2222a/
* diode 1N4001
* https://www.tme.eu/cz/details/1n4001-dco/univerzalni-diody-tht/daco-semiconductor/1n4001/
* resistor 1K
* https://www.tme.eu/cz/details/1w-1k-1%25/metalizovane-rezistory-tht-1w/royal-ohm/mf01sff1001a10/
===== CPU Test =====
**Install sysbench**
shell# apt-get install sysbench
**CPU stress test**
shell# sysbench --test=cpu --cpu-max-prime=1000000 --num-threads=4 run
**Without Fan**
shell# vcgencmd measure_temp
shell# temp=78.0'C
**With Fan**
shell# vcgencmd measure_temp
shell# temp=54.0'C