Recalbox Forum

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

    Using Pi GPIO for other things other than controllers

    Recalbox General
    gpio things
    4
    6
    2551
    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.
    • sirus555
      sirus555 last edited by

      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?

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

        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 🙂

        Former dev - Please reply with @substring so that i am notified when you answer me
        Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

        1 Reply Last reply Reply Quote 0
        • lackyluuk
          lackyluuk Translator last edited by

          @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)

          NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

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

            Thanks @subs

            Thanks @lackyluuk that would be much appreicated.

            1 Reply Last reply Reply Quote 0
            • lackyluuk
              lackyluuk Translator last edited by lackyluuk

              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 😄
              Hope I can help you with this

              #!/usr/bin/env python
              
              import os
              import time
              import RPi.GPIO as GPIO
              
              GPIO.setwarnings(False)
              GPIO.setmode(GPIO.BCM)
              #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()
              	return(res.replace("temp=","").replace("'C\n",""))
              
              while True:
              
              		temp_float = float(getCPUtemperature())
              
              	try:
              		if (temp_float > TEMP_MAX):
              			# ein
              			GPIO.output(GATE, True)
              			time.sleep(ON_TIME)
              			# aus
              			GPIO.output(GATE, False)
              		else:
              			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 🙂
              https://forum.recalbox.com/topic/3704/push-button-on-off-script-problems/11

              NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

              marchegiano 1 Reply Last reply Reply Quote 1
              • marchegiano
                marchegiano @lackyluuk last edited by

                @lackyluuk Thanks bud, super neat.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post

                Want to support us ?

                84
                Online

                99.6k
                Users

                28.1k
                Topics

                187.1k
                Posts

                Copyright © 2021 recalbox.com