Это видео недоступно.
Сожалеем об этом.

Raspberry Pi Fan Temperature Control [Howto]

Поделиться
HTML-код
  • Опубликовано: 17 июн 2020
  • How to control a Raspberry Pi cooling fan based on processor temperature. Uses bash script and cron to activate fan when temperature is over a certain threshold.
    Buy EZ Fan 2 (new version): www.tindie.com...
    New version for 2021: • Raspberry Pi OS Fan Te...
    Supporting files on GitHub if you'd like to make your own: github.com/Jer...
    Raspberry Pi Cooling solutions tests: www.arrow.com/...
    Raspberry Pi logo is trademark of the Raspberry Pi Foundation: www.raspberrypi...
    www.raspberryp...

Комментарии • 86

  • @AndrewHelgeCox
    @AndrewHelgeCox 4 года назад +1

    I always hear your name as Jeremy _ass_ Cook when Max introduces you on the podcast. And I always think it sounds really cool 😅

    • @JeremyCook
      @JeremyCook  4 года назад +1

      Lol, well thanks for letting me know!
      FWIW, I've started putting the old 'casts up on RUclips here: ruclips.net/channel/UC300jnYJu7u66EQX9S0SUZA with the plan to eventually catch up with our current episodes. You can be sub #5 there if you want 😄

    • @AndrewHelgeCox
      @AndrewHelgeCox 4 года назад +1

      @@JeremyCook Okay, done. Now you have to record the new ones with video so I can listen first and then come by to watch :)

    • @JeremyCook
      @JeremyCook  4 года назад

      @@AndrewHelgeCox Awesome, thanks! Not every day that a YT channel gets 25% growth ;-)
      I'll bring it up to Max, though I guess that would mean making sure not to roll my eyes or give weird looks during the filming!

    • @AndrewHelgeCox
      @AndrewHelgeCox 4 года назад +1

      @@JeremyCook No, definitely give all the weird looks every time! 😅

  • @patregan
    @patregan 4 года назад +4

    I need to pack up a breadboard vise or two and mail them to Jeremy!

    • @JeremyCook
      @JeremyCook  4 года назад +1

      I'm all for it! Though is that the one you sell on Tindie? Guess my printer could "send" me one if I'm not too lazy :-)

    • @patregan
      @patregan 4 года назад +1

      @@JeremyCook It is on Tindie and Thingiverse. Nobody should buy it from Tindie. It takes too long to print, and I don't want to be printing them, so they're priced too high for 20 cents worth of plastic! :)
      I have some ideas in my head to turn it into a 3-piece CNC plywood project, so it'd take dozens of seconds to cut instead of hours to print. I just haven't sat down to CAD it!

    • @JeremyCook
      @JeremyCook  4 года назад +1

      @@patregan So you say, but I see you've got over 100 orders for your products there. So good job?

    • @patregan
      @patregan 4 года назад +1

      @@JeremyCook If Jeremy says I'm doing a good job, then I absolutely must be doing a good job! :)

    • @JeremyCook
      @JeremyCook  4 года назад +1

      @@patregan Ha, I didn't even think of that, but yes, you are doing a good job.
      RUclips, however, is doing a bad job of notifying me of your replies, so I'm glad I saw it. I guess it doesn't take you seriously.

  • @nismoskys
    @nismoskys 4 года назад +1

    Awesome video. Very cool seeing the PCB design that followed. Thanks!

    • @JeremyCook
      @JeremyCook  4 года назад

      Thank you. Considering doing something similar?

    • @nismoskys
      @nismoskys 4 года назад +1

      @@JeremyCook yes! Just built a nearly identical setup on a breadboard using a transistor with a 5V fan, now I can see why the PCB design is useful, because it's extremely compact. I'm testing out this 5V circuit before attempting to control a larger 12V 6A load with the Pi. Once I've got that circuit working I'll be very interested in designing a PCB like you have done here!

    • @JeremyCook
      @JeremyCook  4 года назад

      @@nismoskys Awesome, glad you got some use out of it! The design is on GitHub, but you'll obviously want something a bit bigger!

    • @nismoskys
      @nismoskys 4 года назад +2

      @@JeremyCook I might snag the design just for the Pi Fan use case. Thanks for making that available 👍

    • @JeremyCook
      @JeremyCook  4 года назад

      @@nismoskys No problem! I keep meaning to put them up for sale on Tindie, but so many other projects :-)

  • @tonysfun
    @tonysfun 4 года назад +2

    Nice job! Thanks for sharing.

  • @eltonmenezes
    @eltonmenezes Год назад +1

    does this vary the speed? or just cut it off and on?

    • @JeremyCook
      @JeremyCook  Год назад

      It can do either via PWM control.

  • @glennrebillard3840
    @glennrebillard3840 3 года назад +1

    Would your exact setup work with a varying pulse frequency on the base 3.3V to give you variable speed like the Andreas Spiess solution? I have all the components in your setup, but want to try it with variable speed.

    • @JeremyCook
      @JeremyCook  3 года назад

      I don't know the specifics of Spiess' solution, but I see no reason why you couldn't use PWM with this setup.

  • @rezwan8744
    @rezwan8744 4 года назад +2

    hey do you sell these? like the whole thing, which i can just plug in my pi? please let me know...thanks alot.. i really needed someting like this for my pi4..

    • @JeremyCook
      @JeremyCook  4 года назад

      Have been thinking about it. Ping me at hi@jeremyscook.com and we can talk!

  • @gavin-pp5di
    @gavin-pp5di 4 года назад +1

    Can the positive and negative leads be connected to an external power source instead of the pi?

    • @JeremyCook
      @JeremyCook  4 года назад

      I suspect so, but you'd likely need to connect the grounds (negative). You may want to check this with something non-critical first though. Would love to hear your results.

  • @bara6358
    @bara6358 3 года назад +1

    Hi Jeremy, I don’t currently have a 500ohm resistor and have seen some people use a 1k. Would that work as well?

    • @JeremyCook
      @JeremyCook  3 года назад +1

      Hi Bara, I believe a value lower than 500 ohm would work (though I'm not sure of the lower "limit" so to speak). Another commenter used a 1K and had difficulty with it, so I wouldn't recommend. That being said, you could hook 2 of them up in parallel to give 500 ohms of total resistance. Alternatively, the link in the description includes a solder kit if you so prefer.

  • @jaymooreiv8769
    @jaymooreiv8769 4 года назад +2

    @Jeremy Cook what kind of resistor do you use and diode

    • @JeremyCook
      @JeremyCook  4 года назад

      IIRC, spec'd at 1k, but used ~600 ohm - not sure that's optimal, but I don't think it has to be perfect. Diode: small one that I pulled out of my parts bin. I don't think this has to be perfect either, and is somewhat optional.

  • @ottovp
    @ottovp 3 года назад +1

    finally you can command it via raspi-config performance tab

    • @JeremyCook
      @JeremyCook  3 года назад

      Nice, I'd heard that, but hadn't tested it. Have you tried it with the transistor setup seen here?

    • @ottovp
      @ottovp 3 года назад +1

      @@JeremyCook i'm trying today with a 680ohm resistor and NPN transistor (2N2222). i'll let you know :)

    • @JeremyCook
      @JeremyCook  3 года назад

      @@ottovp Please do! You may need a smaller resistor though (or you could try two in parallel if that's all you have, though that may be a little too low).

    • @ottovp
      @ottovp 3 года назад +1

      @@JeremyCook works like a charm! tried to stress test and adding a diode for viewing pleasure! i'm an octoprint happy user now!

    • @JeremyCook
      @JeremyCook  3 года назад +1

      @@ottovp That is great to hear, thanks for letting me know! Working on something new/another video on this subject, so I hope you enjoy :-)

  • @Jesse-wm6sz
    @Jesse-wm6sz 4 года назад +1

    Hi, I am planning to follow your setup but in our local electronic store, they don't have 2N2222 Transistor, they are offering PN2222 instead. Will that work? I also got confused with the diode, did you used it?
    Please help an old guy that doesn't know anything about electronics. LOL

    • @JeremyCook
      @JeremyCook  4 года назад

      Hi Jesse, I think that will work, and might even be a form of the same thing, though I'm not certain. Diode is a good idea, but optional, it's not actually on the version I have running right now.

  • @misztong
    @misztong 4 года назад +1

    Hi Jeremy, this is a very nice tutorial and pretty soon I'll have all parts needed delivered, so I can make my own circuit. I'm just a little hesitant as to where to place the flyback diode, which you say is optional, but I figure it's so cheap and probably couldn't hurt, so why not add it. Only when you're an EE noob and not familiar with schematics, it's a bit tough to correctly decipher them... So a noob question: where exactly do I add the diode?

    • @JeremyCook
      @JeremyCook  4 года назад

      Thanks! Hmm, well if you're having trouble with the schematic, I'd try to copy the breadboard layout at 1:18, then shrink the connections down to whatever format you're using.
      Alternatively, I'm considering selling these PCBs. Would you be interested in that?

    • @misztong
      @misztong 4 года назад +1

      @@JeremyCook Hi Jeremy, using your PCB is tempting, but I think I much more prefer to get my hands dirty and try and get this working myself. What better way to learn than by actually doing it ;) Thanks again for the vid and article on your webpage.

    • @JeremyCook
      @JeremyCook  4 года назад

      @@misztong Glad it inspired you. LMK if you have any issues!

  • @iamlegend1630
    @iamlegend1630 3 года назад +1

    i do the same thing and the same script, and it doesnt work. it work if i start the fan manually, but when i set up the crontab it didnt work

    • @JeremyCook
      @JeremyCook  3 года назад

      Hmm, not sure. Did you have all stars on the crontab? It checks it every minute, so it's not immediate.

  • @krishsoundar3857
    @krishsoundar3857 3 года назад +1

    why should transistor be after load?. I noticed that my fan is not spinning full speed and transistor getting too warm. Upon inspecting I noticed my transistor is before load, and wonder if it will make a diff.

    • @JeremyCook
      @JeremyCook  3 года назад

      Hi Krish - I'm not the best person to explain the physics involved, but yes, it definitely makes a difference!

    • @paulcarpenter1824
      @paulcarpenter1824 2 года назад

      Try changing the base resistor to 100ohms

    • @brucelytle1144
      @brucelytle1144 Год назад

      Just saying here... it makes no difference which "side" is switched. It is a series circuit that has a switch (transistor) and a load (fan motor).
      The only difference is what transistor you use. If on the ground (low) side of the motor, you need an NPN type of transistor, on the positive side of the motor, you would use a PNP type of transistor. It works both ways!

  • @MdSiam-kw5ox
    @MdSiam-kw5ox 4 года назад +1

    In your final one, you didn't use the diode. Why?

    • @JeremyCook
      @JeremyCook  4 года назад

      IIRC I may have hooked the diode up backwards, so snipped it off. Put together another one with the diode, which did work correctly.

  • @drewskie_za8155
    @drewskie_za8155 4 года назад +1

    Do you not use the diode in the first (heat shrink) design?

    • @JeremyCook
      @JeremyCook  4 года назад

      Hi Andrew, It should probably be there, but I left it off so things would be easier. The board I'm actually using now has been operating without a diode for over a month, FWIW.

  • @lakshaykumar2168
    @lakshaykumar2168 2 года назад +1

    can i use 1X1000ohm resistor instead of 1X500ohm resistor?

    • @JeremyCook
      @JeremyCook  2 года назад +1

      I don't think that will work. However, two 1000 ohm resistors in parallel may.

    • @lakshaykumar2168
      @lakshaykumar2168 2 года назад +1

      @@JeremyCook I will try 2X220ohm + 10 ohm (total 450 ohm). i hope that suffice.

    • @JeremyCook
      @JeremyCook  2 года назад

      @@lakshaykumar2168 Should be OK. Honestly, I suspect 220 by itself would be OK, but no guarantees.

  • @miteshparmar1
    @miteshparmar1 3 года назад +1

    Another fantastic video but unfortunately for me this script does not switch on the fan :-(
    Steps to reproduce:
    1. in the home directory create the temp-fan.sh script and copy verbatim your code
    the only change that I made was: 'gpio -g mode 14 out' and 'gpio -g mode write 14 1' and 'gpio -g write 14 0'
    2. chmod +x ./temp-fan.sh
    3. access the crontab file using crontab -e and enter the following at the bottom of the comments: * * * * * ./temp-sh
    4. reboot the Pi for good measure: sudo reboot
    5. ssh back into the Pi and manually ran the bash script which shows the temperature being 47 but still the fan doesn't come on
    Any ideas please?

    • @JeremyCook
      @JeremyCook  3 года назад

      Glad you enjoyed the video. As for your problem, this may help: github.com/JeremySCook/RaspberryPi-Fan-Control/issues/2

    • @miteshparmar1
      @miteshparmar1 3 года назад +1

      @@JeremyCook Thanks for the reply Jeremy.
      Actually I managed to get it working by following this tutorial: howchoo.com/g/ote2mjkzzta/control-raspberry-pi-fan-temperature-python
      I followed Step 5 and created the fancontrol.py file and amended the following variables:
      ON_THRESHOLD = 45
      OFF_THRESHOLD = 40
      Followed Step 6 to ensure this script executes on bootup.
      Wired up the fan to the EZ Fan2 with the cables supplied.
      Tested the device using a hair-drier and it works a treat :-)
      Used the heat-shrink supplied to wrap it all up.
      I'm impressed with this...

    • @JeremyCook
      @JeremyCook  3 года назад

      @@miteshparmar1 Glad you got it working! I need to go through my script etc and update it.
      That being said, I'm sure the Raspberry Pi OS functionality that is available now: ruclips.net/video/AdjU_AVcZTA/видео.html will work for most people.

  • @rezwan8744
    @rezwan8744 3 года назад +1

    Hey Jeremy, I finally made some of these.. the first time I got 200 1k ohm resistor (I don’t know why) and it worked for a few days in a pi3.. then it stopped working.. the fan just flickered on for like a millisecond and didn’t stay consistent..
    So I studied for a long while and figured I’ll need a smaller resistor.. so the gpio’s output 3.3 volts and the 2n2222 base needs to be limited to 5mA so 3.3/0.005 = 660.. so I got 680 ohm resistors
    It works but not on the ice tower fan with the RGB lights.. I don’t know why.. but the one u sent works on the ice tower maybe because yours is 500> something ohm..
    I don’t have any resistors lower than 680 at the moment, so out of frustration I directly connected the GPIO to the 2n2222 base and lowered main power to fan to 3v instead of 5 to be safe.. and it works fine.. turns on off based on script.. I put it on a brand new pi4 8gb and wondering if I’m seriously risking it by not using a resistor on the 2n2222 base..
    Any advice on my situation? Is it absolutely necessary to use a resistor in a 2n2222 transistor to switch a fan? I have 100 2n2222 transistors so I’m not worried if 1 dies.. but I’ll hate it if my new pi4 dies with it..
    Your PCB is still the best.. I have it hooked to my main server and it works like a charm & looks great too, no problems yet.. if your willing, I’d like to buy two more.. I’ll keep them as an emergency backup.. please let me know..
    Thanks alot..

    • @JeremyCook
      @JeremyCook  3 года назад +2

      Hey Rezwan,
      I don't think the resistor is absolutely necessary, in the same way that you can power an LED with a 3.3V output. However, the life may be shorter than it would be absolutely. I believe the risk is more to the transistor than the Pi itself.
      Thanks for your kind words on the PCB. I actually ordered a few more PCBs, so planning to list them on Tindie soon. Just email me though and we can work something out immediately!
      Also, per a comment on the GitHub page github.com/JeremySCook/RaspberryPi-Fan-Control/issues/2 , someone was saying that they were having some problems with the script, and that the GPIO library I was using was deprecated. It also supposedly didn't work properly with the Pi 4. You've been using it with the Pi 4 with no issues, correct?
      Seems a little strange TBH.

    • @rezwan8744
      @rezwan8744 3 года назад +1

      Jeremy Cook DIY i think GPIO will work fine with the official Raspberry Pi OS.. but I use Ubuntu and apt install wiringpi” won’t work in Pi4.. I had to download unofficial source code for wiringpi from GitHub and compile it.. it’s not that difficult..
      I am using my own script to control the fan according to my need.. but a script shouldn’t be an issue as long as the latest libraries for GPIO (which does support Pi4) is installed..
      It’s great your selling the PCBs.. they are really one of a kind.. I can be your first customer in tindie :D..
      Anyways thanks for your input on the resistors.. I’ll email u in a couple of days about tindie listing..

    • @JeremyCook
      @JeremyCook  3 года назад +1

      @@rezwan8744 Well thanks! Yeah ping me in a couple days, hopefully I'll have the listing set up :-)

  • @dakbrad
    @dakbrad Год назад

    you should make a pwm fan splitter 3&4 pin with rgb and speed sensing/control. corsair gouging $50-70 and it doesn't even work with 3 pins (full speed)

    • @JeremyCook
      @JeremyCook  Год назад +1

      Interesting. What's the Corsair model #?

    • @dakota5532
      @dakota5532 Год назад +1

      ​@@JeremyCook CORSAIR - iCUE Commander Core XT Smart RGB Lighting and Fan Speed Controller - Black
      no control or sensing for 3 pin fans

    • @dakota5532
      @dakota5532 Год назад +1

      you can use (free) Fan Control if you don't already have software that you use to control fan speed

  • @Redn2000
    @Redn2000 2 года назад +1

    Hi Jeremy, maybe you can shed some light on an issue I'm having with one of the fan controllers you have on tindie. I have 2, 1 old and 1 newer version.
    My Pi 3b+ works great with the script and controller. Fan turns on and off just fine with the cron script
    My Pi4 b however can't seem to turn on the fan when connected to the controller. I've looked at the diagrams over and over for the GPIO setup and connected varying different ways to no avail. I know the fan works as I just tested it without the controller. And oddly I noticed the pin labels on my newer controller do not match images on tindie. They look to be reversed or rearranged in some way, but even after trying to reverse the cables I still don't see the fan working.
    Any advice?
    Edit: I turned off the fan control option in Pi config and the fan started working but I can't seem to turn it off now. I think there was a conflict between settings and the config, *and* it looks like the controller pins were in fact rearranged. Maybe the script isn't working?

    • @JeremyCook
      @JeremyCook  2 года назад +1

      Hey Redn - Just saw your comment. You are correct, the ground and control pins were reversed to make them easier to plug in for the newest version of the EZ Fan 2. Check out the pictures on the EZ Fan 2 listing on Tindie and that should hopefully shed some light on it.
      The new version is 5V - GND - GPIO
      The old cersionm is 5V - GPIO - GND
      LMK if you have any other questions hi @ jeremyscook dot com

    • @Redn2000
      @Redn2000 2 года назад +1

      @@JeremyCook Thanks Jeremy. I absolutely will! I appreciate you responding to comments like this still. For now it does seem to work, though the temperature it activates at is oddly ephemeral, but it does turn on and off so I'm happy with it.

    • @JeremyCook
      @JeremyCook  2 года назад

      No problem, glad I saw it, and glad it worked!
      As for the temperature, when using OS control the RPi fan control will come on at a certain programmed temperature, but won't go off until it drops well below that. 10ºC IIRC.

  • @TrollingAround
    @TrollingAround 3 года назад +1

    raspi-config now has the ability to turn on/off a GPIO pin depending on temperature - Performance settings/Fan control, unfortunately it only allows a single temp to turn on/off, I prefer having two temps, turn on when >=55, turn off when

    • @JeremyCook
      @JeremyCook  3 года назад

      Ah, that is pretty neat. Thanks for letting me know!

    • @Redn2000
      @Redn2000 3 года назад +1

      I've tried this setting a few times. Do I need all this shown in the video here, or am I just telling it the wrong GPIO pin to control?

    • @JeremyCook
      @JeremyCook  3 года назад

      @@Redn2000 If you're asking if you need a transistor setup, then most likely yes.

    • @Redn2000
      @Redn2000 3 года назад +1

      @@JeremyCook Thanks. I've been trying to find a compact guide so I can fit it inside a kana kit case, but every guide I've seen has used a breadboard for it. Is there no straightforward solution by using jumper wires and a transistor and resistor?

    • @JeremyCook
      @JeremyCook  3 года назад

      @@Redn2000 NP. I show one solution around 2:30 or I have PCBs listed in the description which may fit your requirements.