Jamesbeat
Posts: 46
Joined: Mon Oct 15, 2012 8:19 pm

External Activity LED on Pi3?

Mon Jun 26, 2017 5:21 pm

I'm building a Pi3/Retropie based emulation box specifically for computer based emulators (Spectrum, C64, Atari ST etc).
It's 90% complete, but I have a few loose ends to tie up.

I've hooked up a power LED, but I cheated and connected it to the power supply, so it's on whenever the power supply is on, whether or not the Pi itself is powered up.

What I'd like to do is have a second LED for activity, mostly so that I know when it's safe to switch off the power.

I have found some guides online for connecting an LED to the GPIO pins.
These look simple enough, but appear to be mostly for older Pi models or for the Zero.
A few of the more recent guides cryptically mention that they won't work for the Pi3 because 'something changed', but don't go into any detail.

Can this still be done on the Pi3, and if so, how?

I already have the LED and resistor ready to go, I just need to know which pins to connect it to and any accompanying code needed.

I would prefer processor activity, but SD card activity would also be ok.

User avatar
rpdom
Posts: 12948
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: External Activity LED on Pi3?

Mon Jun 26, 2017 5:37 pm

Do those instructions mention using pi3-act-led in config.txt?

Code: Select all

Name:   pi3-act-led
Info:   Pi3 uses a GPIO expander to drive the LEDs which can only be accessed
        from the VPU. There is a special driver for this with a separate DT
        node, which has the unfortunate consequence of breaking the
        act_led_gpio and act_led_activelow dtparams.
        This overlay changes the GPIO controller back to the standard one and
        restores the dtparams.
Load:   dtoverlay=pi3-act-led,<param>=<val>
Params: activelow               Set to "on" to invert the sense of the LED
                                (default "off")

        gpio                    Set which GPIO to use for the activity LED
                                (in case you want to connect it to an external
                                device)
                                REQUIRED
Use it instead of the act_led_gpio that the instructions probably mention.

Jamesbeat
Posts: 46
Joined: Mon Oct 15, 2012 8:19 pm

Re: External Activity LED on Pi3?

Mon Jun 26, 2017 6:10 pm

Yes, that is the problem that I saw mentioned in the tutorials.

Forgive my ignorance - do I have to recompile to use that overlay?

I'm hoping to avoid anything too complicated because I'm using a pre-built Retropie image.

User avatar
rpdom
Posts: 12948
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: External Activity LED on Pi3?

Mon Jun 26, 2017 6:20 pm

No, you don't need to recompile anything.

I assume in the tutorials they say to add a line to /boot/config.txt with something like

Code: Select all

dtparam=act_led_gpio=XX
where XX is the BCM pin number of the GPIO you want to drive your LED with.

Well, all you need to do is instead of that line, put in

Code: Select all

dtoverlay=pi3-act-led,gpio=XX
and reboot.

Jamesbeat
Posts: 46
Joined: Mon Oct 15, 2012 8:19 pm

Re: External Activity LED on Pi3?

Mon Jun 26, 2017 6:23 pm

Great, I'm glad it's a nice simple solution!

I'll try it out tonight, thanks :)

Jamesbeat
Posts: 46
Joined: Mon Oct 15, 2012 8:19 pm

Re: External Activity LED on Pi3?

Mon Jun 26, 2017 11:39 pm

It worked perfectly, thanks :D

I hooked it up to GPIO 21.
I was able to just plug in the LED across pins 39 and 40 because I'm using a PC case LED with a standard connector on it.

The only modification I had to make was to splice in a resistor.

Thanks again!

Return to “General discussion”