Using Pi GPIO for other things other than controllers

  • Hi,

    Ive just stumbled on this brilliant OS after search for issues I am having with my own custom build.
    Currently I am working on a project which brings kodi, moonlight and emualtion station into one but am having trouble with the controller registers. I am looking to try out this build as I read on git that usb controllers are automatically recongised. (I hope this is true).

    However, my question lies around the pi's gpio. I am looking to hook up a fan and some leds lights that imitate the pwr and act leds on the pi, ready to go into a custom box. I was just curious is it possible to do this on the OS?

  • Moderator

    Sure you can ! Our python gpio God @supernature2k can do anything you need :)

    2 things :

    • if you search ni the forum, you'll find quite some ressources concerning that
    • we are also working on giving gpios other super powers : reset (when available) or kill an emulator, use retroarch network commands ... Prety amazing stuff in fact :)

  • Translator
    Translation Master

    @sirus555 I have a working fan script running in my recalbox. It just turns the fan on at a defined cpu temperature for a certain time to cool it down.
    I could post it here when I am at home :) (if still needed)

  • Thanks @subs

    Thanks @lackyluuk that would be much appreicated.

  • Translator
    Translation Master

    Here is an example with GPIO pin 14 for controlling the fan. The indents might not be correct ;) I had a little trouble with copy/paste the code :D
    Hope I can help you with this

    #!/usr/bin/env python
    import os
    import time
    import RPi.GPIO as GPIO
    #Set max. temperature of CPU
    TEMP_MAX = 67
    ON_TIME = 200
    #Set pin 14 as transistor gate
    GATE = 14
    #Set pin 14 as an output and shut down
    GPIO.setup(GATE, GPIO.OUT)
    GPIO.output(GATE, False)
    def getCPUtemperature():
    	 res = os.popen('vcgencmd measure_temp').readline()
    while True:
    		temp_float = float(getCPUtemperature())
    		if (temp_float > TEMP_MAX):
    			# ein
    			GPIO.output(GATE, True)
    			# aus
    			GPIO.output(GATE, False)
    			GPIO.output(GATE, False)
    except KeyboardInterrupt:
    	print float(getCPUtemperature())
    	print "power off fan..."
    	GPIO.output(GATE, False)
    	print "cancelling..."

    Here you will also find a small drawing for the transistor etc :)

  • @lackyluuk Thanks bud, super neat.

Log in to reply

Want to support us ?





Looks like your connection to Recalbox Forum was lost, please wait while we try to reconnect.