I connected the 4 pin fan to the sata connector, using this script to control the fan usage
#!/bin/sh
pin_num=8
sleep_time=5 #seconds
fan_time=30 #seconds
fan_temp_threshold=45
gpio_num=$((pin_num + 411))
echo $gpio_num > /sys/class/gpio/export
gpio_sys_path='/sys/class/gpio/gpio'
gpio_sys_path="${gpio_sys_path}${gpio_num}"
current_dir="`cat ${gpio_sys_path}/direction`"
if [ "$current_dir" = "in" ]; then
echo out > "${gpio_sys_path}"/direction
fi
echo 0 > ${gpio_sys_path}/value
while [ true ]
do
temp=$((`cat /sys/class/thermal/thermal_zone0/temp`/1000))
if [ "$temp" -gt "$fan_temp_threshold" ]; then
echo 1 > ${gpio_sys_path}/value
sleep $fan_time
echo 0 > ${gpio_sys_path}/value
else
sleep $sleep_time
fi
done
You can also use GPIO8 to generate a 12v PWM signal. I have a script for that as well if anyone is interested. You only need 2 wires.