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

    Shell-Script
    1. #!/bin/bash
    2. (
    3. /storage/.config/fancontrol.sh
    4. )&

    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
    1. 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