RPi4 GPIO using in LibreELEC

  • Wht don't you try gpiozero Button..more flexible....you can add short press reboot,long press shutdown etc

    Hello #Mario77... It seems that you are good at Linux coding. I am not that good at Linux/LE, and i have make few changes through SSH, so i know what it is ans so. Today i have Generic AMD/Intel/NVIDIA (x86_64) installed on a PC, and it is connected to a UPS that support it at a power break. My idea was to make a script or so like: "if LAN/ethernet goes down start shutdown.sh" or something like that. Thought there was an "power manager addon" that has a function for my idea, but can not find any. Best regards from Thore in Sweden

  • Hello #Mario77... It seems that you are good at Linux coding. I am not that good at Linux/LE, and i have make few changes through SSH, so i know what it is ans so. Today i have Generic AMD/Intel/NVIDIA (x86_64) installed on a PC, and it is connected to a UPS that support it at a power break. My idea was to make a script or so like: "if LAN/ethernet goes down start shutdown.sh" or something like that. Thought there was an "power manager addon" that has a function for my idea, but can not find any. Best regards from Thore in Sweden

    Hi,sorry can't help you much with that..I mostly play with my Rpi but have no idea about Generic AMD/Intel/NVIDIA (x86_64)

  • Mario77 : How do I do that, where do i find an exact discription to do that?

    easy enough


    Will look something like this

    Taken from here just changed few bits to work with LE..

    You ll need to install Rpi Tools addon for this to work..

    Edited once, last by Mario77: Merged a post created by Mario77 into this post. (September 15, 2023 at 1:47 PM).

  • Mario77 : downloaded the zip and tried to install it, but unable to.

    Which zip?

    I didn't mean you just download that zip and install it...

    but on previous post I made you a small modified script that will work..

    You ll need to create a system.d service that start the script or use autostart.sh to start it..

    This you can play around how you want ex changing the when released function to something like

    Code
    def rls():
            global held_for
            if (held_for > 3.0):
                    check_call(['/sbin/poweroff'])
            else:
                    check_call(['/sbin/reboot'])

    this will exec shutdown if held more then 3 seconds or reboot if less...

    You got plenty of options to playwith...ex my switch has an led built into it and it can blink or fade or whatever you want it to do but for that you ll need an npn transistor.

  • FYI RPI Tools add-on may not work anymore on some LE releases / builds.

    ghtester
    August 3, 2023 at 6:50 AM

    I don't know if it could be your case as well or not.

  • This is much to deep water for me, if there is a typo, i won't regognize that and drowning would be likely. For instance: They are counting the GPIO headers in my option the wrong way arround. i would say that there button is connected on pin 13 and 14.

    But I am so in experienced, that my pin 5 and 6 probably are 35 and 36

  • This is much to deep water for me, if there is a typo, i won't regognize that and drowning would be likely. For instance: They are counting the GPIO headers in my option the wrong way arround. i would say that there button is connected on pin 13 and 14.

    But I am so in experienced, that my pin 5 and 6 probably are 35 and 36

    I changed that as your wiring if you look on my post above

    use_button=3 

    as Da Flex pointed out Pin 5 is GPIO 03 as gpiozero uses gpio numbering..


    So you keep using pin 5 (+) and 6 (-)

    Edited once, last by Mario77: Merged a post created by Mario77 into this post. (September 15, 2023 at 5:59 PM).

  • To all whom, gave input, thanks!

    I finally found that the problem was hardware based. After changing config.txt by adding the line “dtoverlay gpio-shutdown,gpio_pin=3” the button did what it should do. After some reboots suddenly NOT any more. Be-course, I’d tried every other syntax, I’d determined that it had to be hardware related. Pure by chance I tried my 2 hand bought 3A power-supply, to use for charging my drained TomTom and it wouldn’t charge, or start.

    Connected a different adapter, to the Pi and behold, after reboot I did got a shutdown menu. After renaming keyboard.xmlt back to keyboard.xml, the button performed a shutdown as it should time after time

    There was another problem. To surch a switch; wires; connectors for GPIO in my things/stock, I found a suitable button and two pieces of wire with a connector, saved from a old desktop. For experimenting reasons, I didn’t shortened the wires, but soldered them to de two ends on de button.

    Twisted the black and red wires and began experimenting. It made a cable approx 15cm and left it dangling of the RPi when the alterations took effect and the Pi was shutdown, after a few minutes it booted again, probably as a result of the to long wires working like antenna, or capacitator, when I rolled the cable together that problem was also solved.