Libreelec on Pi 4 Cooling Fan control

  • Hi,

    I have installed Libreelec 9.2.1 on Pi 4 with cooling fan that is connected to GPIO 4 (red) and 6 (black) directly without a transistor. I wanted to control this fan depending on the temperature of CPU. Found some information on internet, and based on these i programmed the Pi as the following:

    Created a file fancontrol.py in /storage/.config/ with access 755.

    It contains the following script

    Then i made another file named fancontrol.sh in /storage/.config/ with access 755

    Lastly i created an autostart.sh file in /storage/.config/ with

    Bash
    #!/bin/bash
    (
    /storage/.config/fancontrol.sh
    )&

    I have reboot the pi, but the fan is not controlled, it is non stop works with cpu temperature 35.

    What did i do wrong? How to make it work?

    thank you

  • You can't control the fan if you didn't add the transistor.

    Pins 4/6 are +5V and GND so the fan will be constantly running as long as your RPi is powered up.

    The python script you posted expects a transistor connected to GPIO 17.

    BTW: a much simpler alternative to using a python script is to use the gpio-fan DT overlay. GPIO number and temperature can be passed in as parameters. eg

    Code
    dtoverlay=gpio-fan,temp=40000

    see also here linux/README at rpi-4.19.y · raspberrypi/linux · GitHub and here

    linux/gpio-fan-overlay.dts at rpi-4.19.y · raspberrypi/linux · GitHub

    so long,

    Hias

  • Just add the dtoverlay line to config.txt Raspberry Pi Config.txt [LibreELEC.wiki] adjust the temp parameter as needed. If you use a different GPIO than the default 12 you also have to add gpiopin=GPIONUMBER

    The second link (to the gpio-fan-overlay.dts file) shows how the transistor should be hooked up and also contains a link to the RPi forum with more details Overlay for GPIO connected fan - Raspberry Pi Forums

    so long,

    Hias

    Sorry if I reply to an old thread. I just wanted to know: the solution you provided still needs a transistor to work?