Cooling Fan Control Raspberry Pi Libreelec.

  • HI..been looking for some info and giving up now...I m trying to get a fan to work with my raspberry pi..with some kind of control when rpi reaches let s say 50 degrees fan goes on...below 50 goes off..I understand that there has to be a small circuit and transistor to gpio pin...I m more stuck at the scripts bit and if there is a way to make them work with libreelec from something like raspberry pi tools addon...Hopefully someone who got it working can share some knowledge..and some easy steps....I found few howto's online but none point to libreelec..

    Thanks for any help

  • The pi tools add-on has several options for python-based GPIO control that something could be built around. If you're only interested in the end-result and not the learning process a Pi case with good passive cooling (and no noisy fans) would be an easier option. The Kodi 'flirc' case is metal with a conductive heat-sink for the main processor as part of the design.

  • You'll basically just need to use the RPI.GPIO python library and set one of the gpio pins to high when they system temp reaches the set point.

    Although this might be a fun project it isn't really necessary. You can slap on a small heat sink if you are really worried about overheating.

  • Thanks for your replys...I installed the raspberry pi tools addon and I can build a simple circuit from fan to transistor to raspberry pi gpio for control and power from power source or raspberry pi itself 5 v pins...

    Been in the addon folders...got 3 folders I assume I have to put the script in...one of these...Gpiozero,picamera and rPi...This is where it s getting complicated and not sure where I m starting from...Been using Kodi for few years now but when it comes to this kind of scripts I m hopeless...

    It's really more of a fun thing I m trying then that I really need a fan

    Thanks for any more help..

  • Have a look Here. It's the code used for the "Hotpi", and it might give you some ideas.

    That's all chinese for me lol...but I did have a look and looks like the script is made for fan control with fan speed control...I just need something simple like on and off..thanks Iridium for your help

  • I've done what I think you're after, I found my Pi 3 was overheating when playing HD content. It switches the fan on when the temperature goes above 55C and then switches it off again when it drops below 45C. (Having it switch on and off at the same temperature will make it switch too quickly.)
    What part are you having trouble with, how to actually control the fan, or how to do it in LibreElec?

  • I've done what I think you're after, I found my Pi 3 was overheating when playing HD content. It switches the fan on when the temperature goes above 55C and then switches it off again when it drops below 45C. (Having it switch on and off at the same temperature will make it switch too quickly.)
    What part are you having trouble with, how to actually control the fan, or how to do it in LibreElec?

    Hi GaryB...that is exactly what I m planning to do...did you use a transistor or a relay?I think the electronic part would be easy enough for me to set up and seen lots of guides around how to connect from gpio to transistor or relay and 5 volts headers..I m stuck how to control the fan from script...have no idea what to do...did you use the raspberry pi tools addon?

  • I used an S8050 transistor, I think a relay would draw too much current.

    Yes, I used the Raspberry Pi Tools addon for the GPIO library.
    I've added the Python script I use, feel free to use as-is, or just as a pointer. I run it using systemd, but you could just execute it at startup.
    run-fan.py.txt
    (I have my /storage on NFS, if you have it on an SD card you won't want the logging.)

  • I used an S8050 transistor, I think a relay would draw too much current.

    Yes, I used the Raspberry Pi Tools addon for the GPIO library.
    I've added the Python script I use, feel free to use as-is, or just as a pointer. I run it using systemd, but you could just execute it at startup.
    run-fan.py.txt
    (I have my /storage on NFS, if you have it on an SD card you won't want the logging.)

    So I have to create a folder in storage...name it Fan or scripts...put the python script in it...removing .txt and then create another script in systemd to run it?Do I have to put anything in the raspberry pi tools addon folder or is that just a library for the script to work?

    Will something like this work in autostart.sh ?

    Code
    python /storage/scripts/run-fan.py &

    What have you added to systemd to run it?I pnly used systemd to mount network hdd's normally...

    Thanks again...looks like I m getting somewhere..

  • You don't need to touch the Raspberry Tools addon, just install it. The Python code imports the GPIO library.
    You could do exactly what you've suggested there, that's the easy way. I put run-fan.py in /storage/local/bin/ (I have some other scripts in there), but anywhere in /storage that suits you.

    The advantage of systemd is that it will automatically restart the script if it fails for some reason. I've attached my .service file, that needs to go in /storage/.config/system.d run-fan.service.txt
    Enable it with "systemctl enable run-fan" and start it with "systemctl start run-fan".

    BTW, the .txt on the end of the files is just because this forum only allows uploading of certain types of files.


    My next project is to use multiple GPIO outputs so I can vary the speed, still haven't thought through exactly how yet.

  • You don't need to touch the Raspberry Tools addon, just install it. The Python code imports the GPIO library.
    You could do exactly what you've suggested there, that's the easy way. I put run-fan.py in /storage/local/bin/ (I have some other scripts in there), but anywhere in /storage that suits you.

    The advantage of systemd is that it will automatically restart the script if it fails for some reason. I've attached my .service file, that needs to go in /storage/.config/system.d run-fan.service.txt
    Enable it with "systemctl enable run-fan" and start it with "systemctl start run-fan".

    BTW, the .txt on the end of the files is just because this forum only allows uploading of certain types of files.


    My next project is to use multiple GPIO outputs so I can vary the speed, still haven't thought through exactly how yet.

    So if my run.py script is in storage/fan folder run-fan.service should look like this run-fan.service (2).txt and here remains the same ExecStart=/usr/bin/python?

  • Ok think I got the script working...still don't have transistor to try tough...

    Something very strange is happening tough..on fan logs the date is saying May 26 log.txt

    Fri May 26 21:26:24 2017 :- Initializing.

    Fri May 26 21:26:24 2017 :- Temp=59.5C. Switching fan On.

    Fri May 26 21:26:24 2017 :- Initializing.

    Fri May 26 21:26:24 2017 :- Temp=57.3C. Switching fan On.

  • Yeah, that's OK. The Pi doesn't have a battery backed clock, until it connects to an NTP server across the network it reports the time/date from when it was compiled. Subsequent entries should have the correct time provided your clock is eventually getting set.

  • Yeah, that's OK. The Pi doesn't have a battery backed clock, until it connects to an NTP server across the network it reports the time/date from when it was compiled. Subsequent entries should have the correct time provided your clock is eventually getting set.

    Yeah I see what you mean...playing with temp limits to see how it works log.txt

    Gary I m not sure what you mean by this (I have my /storage on NFS, if you have it on an SD card you won't want the logging.)

    Is it the logs from script you mean,,the one I just showed you..?

    Did you use a resistance?

    Edited once, last by Mario77: new question... (August 6, 2017 at 1:32 PM).