Cooling Fan Control Raspberry Pi Libreelec.

  • Hi,

    coming back to the 4-wire fan with PWM:

    I just connected the blue wire (pwm control wire) to GPIO18 (pin 12), set in the cooler.py script: GPIO.PWM(12, 25000) 12 for the pin and frequency to 25kHz and here we go: works like a charm -so far.

    Thanks for your help.

    Cheers

    Roland

  • You can set GPIO and Frequence variables here

    Code
    # Configuration
    FAN_PIN = 18  # BCM pin used to drive transistor's base
    WAIT_TIME = 10  # [s] Time to wait between each refresh
    FAN_MIN = 30  # [%] Fan minimum speed.
    PWM_FREQ = 25000  # [Hz] 25kHz for Noctua PWM control

    and leave this as is

    Code
    fan = GPIO.PWM(FAN_PIN, PWM_FREQ)

    You can also play with the temp and speed you need...

    Code
    # Configurable temperature and fan speed steps
    tempSteps = [30, 40, 45, 50, 55, 60, 65, 70, 75]  # [°C]
    speedSteps = [0, 30, 35, 40, 60, 70, 80, 90, 100]  # [%]

    this is what I m using

    My fan only starts at 30% so anything lower then that it won't start

    This is a small tool to change speed from SSH for testing before you set lowest speed in script..It lets you input different speed from SSH till your fan starts..

    calibrate.py.txt

    Edited once, last by Mario77 (January 6, 2021 at 10:59 AM).

  • I have a great request:

    Can you sum up 1 working solutions with all the steps needed in your first post as the topic is interesting but it is going longer and longer.

    The topic is growing and in 1 part we have scripts, update in another, after there is script with variable speed and for me it is a bit confusing

    Thanks in advance!

    Edited once, last by Nayed (January 31, 2021 at 9:55 PM).

  • I have a great request:

    Can you sum up 1 working solutions with all the steps needed in your first post as the topic is interesting but it is going longer and longer.

    The topic is growing and in 1 part we have scripts, update in another, after there is script with variable speed and for me it is a bit confusing

    Thanks in advance!

    What are you planning to do?

    2 pin 5v fan ?

    Script in post #60 works fine for PWM temp/speed control..

    You just need to make circuit..

  • What are you planning to do?

    2 pin 5v fan ?

    Script in post #60 works fine for PWM temp/speed control..

    You just need to make circuit..

    2 pin 5v fan

    I made a circuit with 2n2222 transistor and 1k resistor I use the following circuit

    Temperature Controlled Fan for Raspberry Pi 4 - Fizzy

    but I would like to use your script from #60 because of the speed control

    I just change the fan file from the link above with your script from #60 and now intend to turn it on

    Seems I made something wrong(either circuit, either places for the script, .. or something else) as I turn it on but the fans are not starting

  • Did you connect transistor base to the proper gpio?

  • Did you connect transistor base to the proper gpio?

    yes,
    all is fine now! I repeat the steps in #58, used the fan file from #60 and it starts
    now trying visually to check the speed change of the fans

    before with no fan temp was 53 deg Celsius now is stable 44-46

    Thanks a lot for your guidelines and support

    Edited once, last by Nayed: add info (February 1, 2021 at 4:15 PM).

  • How can I verify that the speed fan is temperature controlled? I am looking at it and speed seems the same all the time

    Post #74 I posted a small script calibrate.py

    That is similar script to the one on #60 but works manually from terminal instead of reading temperatures...it's just for testing and to find your fan minimum speed...mine started at 30%...less then that and it wont turn...

    You can test fan with that script from terminal....you type 50 will be 50% speed..100 will be 100% speed and so on...

  • Thank you!


    Post #74 I posted a small script calibrate.py

    That is similar script to the one on #60 but works manually from terminal instead of reading temperatures...it's just for testing and to find your fan minimum speed...mine started at 30%...less then that and it wont turn...

    You can test fan with that script from terminal....you type 50 will be 50% speed..100 will be 100% speed and so on...

    Edited 2 times, last by Nayed: Merged a post created by Nayed into this post. (February 1, 2021 at 6:04 PM).

  • Thank you!


    speed steps in script are low so you dont see much difference by looking at the fan

    Code
    tempSteps = [30, 35, 40, 45, 50, 55, 60, 65, 70, 75]  # [°C]
    speedSteps = [0, 35, 45, 50, 55, 60, 70, 80, 90, 100]  # [%]

    try to change the steps and you ll see a big jump from 50% to 100%

    something like:

    Code
    tempSteps = [45, 50]  # [°C]
    speedSteps = [50, 100]  # [%]

    This way it jumps from 50% straight to full throttle

  • You just edit script and restart to try with 50% to 100% but you dont really have to..if fan is working all should be fine

    If you want to try change values just ssh systemctl reload fan.service or stop and then start service

  • You just edit script and restart to try with 50% to 100% but you dont really have to..if fan is working all should be fine

    If you want to try change values just ssh systemctl reload fan.service or stop and then start service

    checked

    There is a difference in the speed definitely . Mine is starting from 30 as well

    Thanks for the support!