ikram
Posts: 85
Joined: Fri May 20, 2016 10:37 am

Commande ventilateur 5v avec raspberey

Thu Jun 08, 2017 7:37 am

Bonjour
J'ai une ventilateur 5v que je veux la branché á une pin pour la commander par la suite avec un bouton (dans une autre pin)je pens que le probleme c'est que la sortie du pin est 3.3v donc il y a t-il des propositions pour convertir 3.3v a 5v ou bien avez vous d'autre solution?

Ernst
Posts: 388
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Commande ventilateur 5v avec raspberey

Thu Jun 08, 2017 10:01 am

As nobody has replied until now I will give you an answer in english because my french is worse then a google translation.

I am running a 5V fan (30mm x 30mm, 200mA) to provide cooling for the cpu on a Raspberry Pi 3B.
The fan is connected to pin 2 (5V) and a the D[rain](*3) of a 2N7000 MOSFET, the S[ource](*1) is connected to pin 6 (GND), and G[ain](*2) is connected to pin 12 (GPIO .1)
Image
For more information on 2N7000 see https://en.wikipedia.org/wiki/2N7000
To control the fan you can use a very simple shell script using gpio (see http://wiringpi.com/the-gpio-utility/

Code: Select all

gpio -g mode 18 output  # set output mode
gpio -g write 18 1           # fan on
gpio -g write 18 0           # fan off
Because the fan is very loud I did some experimenting and I now use a different way to control the fan:

Code: Select all

gpio -g mode 18 pwm   # set to pulse width modulation
gpio -g pwm 18 0          #  fan off
gpio -g pwm 18 840      # fan on very low speed
gpio -g pwm 18 ....        # a value calculated using 840 + (CPU temperature - 62) * 20
gpio -g pwm 18 1000    # fan on high speed
This is the complete script that runs in the background:

Code: Select all

#!/bin/bash
LIMIT0=62
START=840
STEP=20
SLEEP1=10
SLEEP2=30
GPIO='gpio -g'
PORT=18
sleep 30
# power fan on for 60 seconds to show that the script has started
$GPIO mode $PORT output
$GPIO write $PORT 1
sleep 60
$GPIO write $PORT 0
$GPIO mode $PORT pwm
$GPIO pwm $PORT 0
while true; do
  CPU=$(</sys/class/thermal/thermal_zone0/temp)
  CPU=$((CPU/1000))
  if [ $CPU -lt $LIMIT0 ]
  then
    PWM=0
    $GPIO pwm $PORT $PWM
    sleep $SLEEP1
  else
    PWM=$(((($CPU-$LIMIT0)*$STEP)+$START))
    $GPIO pwm $PORT $PWM
    sleep $SLEEP2
  fi
done
Please note that this fan is used on an overclocked Pi3 that is used to run processor intensive jobs, under normal conditions you do not need a fan, sometimes a small heatsink will be sufficient.
My first computer was an ICT1500

Return to “Français”

Who is online

Users browsing this forum: No registered users and 5 guests