Posts by pooh22

    I believe Raspberry Pi OS automatically updates the EEPROM at boot, so perhaps that is what it took?

    I guess that would do it.
    There seems to be some confusion about the term "firmware", I thought it was the stuff that stays on the pi, rather than the sd-card, but it looks like it may be just "drivers" for the kernel in raspian. Or perhaps rpi-update calls the eeprom update as well?

    Anyway, if it was the booting of raspberry OS or running rpi-update, it does boot when I press the button now...

    I wonder what gives with the cec-client, perhaps the cable is the problem, as that's different with the one I used for the rpi3...

    NB, I tried to do this same thing on the raspberry pi 4 (rpi4) and it doesn't work entirely the same.

    The pi4 needs a recent firmware (the first ones produced have a firm-ware which doesn't let the power button works. If you have this problem, best use a different sd card with raspian to update the firmware with ``````rpi-update

    Furthermore, the cec-client seems to have issues with some TV's or hdmi cables. And it's only supposed to work on the hdmi port closest to the powersupply port. For me (Philips tv), it still doesn't work. It could be the cable, the TV or something else.

    For the most part though, it can work on the rpi4 as well.

    I just created this for my setup, perhaps it is useful for others:

    required items:

    • rpi3 with libreelec
    • switch (normally open) between ports 5 and 6 of the GPIO pins
    • led between ports 6 (or some other GND) and 8 of the GPIO pins (TX uart) (add 330 ohm resistor)
    • install package adafruit-libraries

    The uart is off by default, so you need to turn it on in the config.txt

    Code
    mount -o rw,remount /flash

    Edit /flash/config.txt`` and insert the following somewhere logical

    Code
    dtoverlay=pi3-miniuart-bt

    ```

    create the following files

    • /storage/scripts/off-button.py

    `

    • /storage/scripts/poweroff.sh
    Bash
    #!/bin/sh
    
    echo "standby 0" | cec-client RPI -s -d 1 -p 0
    shutdown -h now

    Make both scripts executable:

    Code
    chmod +x /storage/scripts/poweroff.sh /storage/scripts/off-button.py

    Then make sure the off-button.py script is started when the rpi starts up:

    • /storage/.config/autostart.sh
    Code
    (
      python /storage/scripts/off-button.py
    ) &

    After rebooting the rpi3, it should work.

    Thanks to AndrewH7 of instructables for the python script and everyone on the internet who wrote about adding a power button with or without LED to the rpi.

    (The only thing I added/changed was the cec-client stuff via an external script)