Recalbox Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • recalbox.com
    • Gitlab repository
    • Documentation
    • Discord

    Raspberry Pi 5 Geekpi case fan GPIO functionality issues

    GamePad/GPIO/USB encoder
    nespicase fan gpio rpi5
    2
    6
    1613
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Nosferatu676
      Nosferatu676 last edited by

      Board model: Raspberry Pi 5 - 8GB
      Recalbox version (build) : 9.2-rpi5-experimental-2 (RPi 5 64bits)
      Hardware (Micro SD, Power Supply, etc.):
      GeeekPi Case for Raspberry Pi 5, Pi 5 Case with Armor Lite V5 Active Cooler,
      SanDisk 256GB Extreme microSDXC UHS-I Memory Card,
      CanaKit 45W USB-C Power Supply with PD for Raspberry Pi 5 (27W @ 5A),
      oldboytech 4K Micro HDMI to HDMI Male Cable Adapter
      Controller(s): 8BitDo Ultimate Wired Controller

      I assembled a Raspberry Pi 5 with the case featured here.
      https://www.amazon.com/dp/B0CTBJ42P9?psc=1&ref=ppx_yo2ov_dt_b_product_details

      It comes with a side fan that plugs in directly into the 40 pin header (pins 4,6). The issue I have is the fan is always on when the power supply is plugged in, even when the system is shut down.

      After some research and checking the docs and forums, I got a transistor adapter to connect the fan to GPIO 14 (pin 8). https://www.tindie.com/products/jeremycook/ez-fan2-tiny-raspberry-pi-fan-controller/

      The fan does not turn on at all and I have tried several fixes from accross this forum. But, since they are mostly from 2017, they don't translate well to the Pi 5 format.
      https://forum.recalbox.com/topic/29385/recalbox-rgb-dual-fan-control
      https://forum.recalbox.com/topic/3704/push-button-on-off-script-problems/32?lang=en-US
      https://digitalab.org/2021/08/how-to-control-raspberry-pi-fan/

      I just want this small fan to run when the CPU heats up and turn off when it cools down or the system shuts down. I don't need variable speed, just ON/OFF is fine.

      Let me know what I'm doing wrong,
      Thanks.

      Nosferatu676 1 Reply Last reply Reply Quote 0
      • Nosferatu676
        Nosferatu676 @Nosferatu676 last edited by

        Update: So, after watching another video by the guy who made the transistor part I bought, I found out that GPIO 3 is the pin to use instead of 14. I used 14 because his video on the product page used 14 in the raspberry pie OS config.

        This makes the fan turn on while the console(board) is powered on and turn off when powered down, which is an improvement. But, I could still improve it one more step with on/off based on temp control.

        I'll try using PuTTY to write the bash script he has and see if I can add temperature functionality as well. Maybe this could be helpful to others as the python method mentioned in this post and this post didn't work for me. /recalbox/scripts and /etc/init.d don't exist on my sd card, and I couldn't find how to quit emulationstation and open the terminal on any documentation. running chmod +x fancontrol.py with PuTTy didn't get any results either.

        If anyone knows how to do it through the recalbox-user-config.txt like this guy did, I'd appreciate a more thorough breakdown of how to do it, because it didn't work for me at all, though I did change the pin from 26 to 14 in my version.

        Nosferatu676 1 Reply Last reply Reply Quote 0
        • Nosferatu676
          Nosferatu676 @Nosferatu676 last edited by

          Edit: I found the terminal documentation. It does not boot the terminal. And yes, I did it in order of Alt + F2 first, followed by Alt + F4. Multiple combinations of both, and no terminal.

          Nosferatu676 1 Reply Last reply Reply Quote 0
          • Nosferatu676
            Nosferatu676 @Nosferatu676 last edited by Nosferatu676

            Another update: The fan only powers off when I hold the power button on the Pi, if I shut down the system by the regular shutdown method in emulationstation or by pressing the button, the fan still stays on. So, essentially back at square one.

            I've been trying to run a bash file using the scripts on emulationstation documentation. I can't tell if they are even running. I'm using a modified version of the Jeremy Cook bash script since I cant run contrab like in the video.

            temp-fan(permanent).sh

            #!/bin/bash
            ontemp=55
            gpio -g mode 3 out
            temp=$(vcgencmd measure_temp | egrep -o '[0-9]*\.[0-9]*')
            echo $temp #use BCM pin 3, as pin 2 is used for PSU conrol
            temp0=${temp%.*}
            echo $temp0
            
            
            fan_check () {
            
            if [ $temp0 -gt $ontemp ]
            then
            	echo greater than $ontemp fan on
            	gpio -g write 3 1
            else
            	echo less than or equal to $ontemp fan off
            	gpio -g write 3 0
            fi
            
            }
            
            while true
            do
            	fan_check
            	sleep 60
            done
            

            Any advice is appreciated.

            1 Reply Last reply Reply Quote 0
            • Nosferatu676
              Nosferatu676 last edited by Nosferatu676

              Welp, I don't know how I did it, but I managed to fix the issue. it really was the recalbox-user-config.txt. I made sure to delete all my userscripts, pasted in this code in the user config: dtoverlay=gpio-fan,gpiopin=14,temp=60000 and connected my resistor wire to the corresponding GPIO pin and now it works exactly how I want.

              I started noticing the fan was actually starting and stopping while the box was on after moving everything to a new SD card. I don't think it was the card that fixed it as I copied everything in both the recalbox and share drives to the new image, overwriting everything with my configs. The only difference is I removed the bash and python scripts I was experimenting with in the userscripts folder. The user-config still had the previous line of code and actually started working.

              I still had one problem as I was still using GPIO 3 instead of 14, and the fan would stay on if I quit recalbox through the menu instead of a hard power down by holding down the button. Switching to GPIO 14 like I originally wanted and updating the code to match the pin fixed this, thankfully. Now I have a properly functioning mini fan that came with the case.

              Tl;Dr;

              If you buy a Geekpi case for Raspberry Pi 5, buy a EZ fan2 for it with some extra wires. Install the 5v and ground wires into pins 4 and 6 like the Geekpi instructions say, and add your new resistor wire to pin 8 (GPIO 14).

              654d39e7-7853-4b1a-bb9a-1af511f4bd58-image.png

              Set up your recalbox as recommended, doing the first time boot and setup so it creates the needed files.

              Open up your recalbox-user-config.txt located in the root of the RECALBOX drive either on your computer or via a network.

              Paste in dtoverlay=gpio-fan,gpiopin=14,temp=60000 in a free line.

              #Add a comment line above the code like this to write down it's the fan control code if you'd like

              reboot

              And that should work. I will experiment to see if why it didn't work for me before might have been because I wrote 55000 for the temp and that was too low or not, but I'm satisfied with 60 degrees as a trigger.

              I will also quickly mention that the EZ fan2 does fit in the rather compact case. Just tuck it under the board with the wires in an "S" shape.

              geekpi wiring.jpg

              I still think it would be nice if there could be a GPIO fan control menu in emulationstation like Raspberry Pi OS has, but I managed to work around it.

              Thanks for listening and hope this helps someone in the future.

              1 Reply Last reply Reply Quote 1
              • Kelvin
                Kelvin Banned last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • Locked by  admin admin 
                • First post
                  Last post

                Want to support us ?

                76
                Online

                99.2k
                Users

                28.1k
                Topics

                187.1k
                Posts

                Copyright © 2021 recalbox.com