Treedix OfficialTreedix OfficialTreedix Official

Raspberry 4/4B Fan Hat Manual

1. Use of script
First, you need to install his GPIO access library on the Raspberry Pi by accessing the system with SSH or opening a terminal:

cd /tmp

wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb

Waiting to download and install WireingPi:

 sudo dpkg -i wiringpi-latest.deb

Check out Gpio:

 gpio -v

2. Create a text document
Then create a text document in your home directory and copy the contents of fan.sh:

  1.  #!/bin/bash
  2. #Define GPIO pin 18 as PWM
  3. gpio -g mode 18 pwm
  4. num=true
  5. while [ $num ];
  6. do
  7. # Print CPU temp
  8. temp=$(cat /sys/class/thermal/thermal_zone0/temp)
  9. temp=$(($temp/1000))
  10. clear
  11. printf "Temperature: $tempºC\nTurning on fan."
  12. # Variable temperature control
  13. if [ $temp -gt 40 ] && [ $temp -lt 69 ];
  14. then
  15. vartemp=$(echo $[ temp * 13 ])
  16. gpio -g pwm 18 $vartemp
  17. # Maximum fan RPM
  18. elif [ $temp -ge 69 ];
  19. then
  20. gpio -g pwm 18 1024
  21. # Switch off the fan
  22. else
  23. gpio -g pwm 18 0
  24. clear
  25. printf "Temperature: $tempºC\nFan off."
  26. sleep 60
  27. fi
  28. #Pause 1 second
  29. sleep 1
  30. done
  31. exit 0
 cd ~
 nano fan.sh

Paste the script and save it with CTRL+X. When we exit the editor, we'll give the script execution permissions with:

 sudo chmod +x fan.sh

Now the script is ready to be used. But we'll need run it manually every time the computer is started. To solve this we'll use a Linux daemon called Cron:

 crontab -e

Paste the next line at the end of the file where there is no #:

 @reboot /bin/bash /home/pi/fan.sh > /dev/null 2>&1

Save it with CTRL+X and exit.
Now the script is scheduled. To execute it we need to restart and it'll start running in the background.

 sudo reboot

 

Dimanche, Lundi, Mardi, Mercredi, Jeudi, Vendredi, Samedi
Janvier,Février,Mars,Avril,Mai,Juin,Juillet,Août,Septembre,Octobre,Novembre,Décembre
Articles en stock insuffisant. Plus que [max] en stock.
Ajouter à la liste d'enviesParcourir la liste d'enviesSupprimer la liste d'envies
Panier d'achat

Votre panier est vide.

Return To Shop

Ajouter un message à votre commande Editer la note de votre commande
Calculer les frais de port
Ajouter un code de réduction

Calculer les frais de port

Ajouter un code de réduction

Le code de réduction fonctionnera au moment du paiement