14

I have a stack of five Pis, each of which have a separate hostname and are on the same network. I need to physically identify each Pi from another Pi, perhaps by flashing the onboard LEDs in a recognisable manner. Any idea how I might do this from Bash ideally, and without wiring anything up?

3
  • 1
    You can control the onboard LEDs although there looks to be some constraints on some models. You probably want to use the green ACT one as the red PWR one may not be so easily co-opted. raspberrypi.stackexchange.com/search?q=onboard+leds Commented Jun 9, 2018 at 13:25
  • 2
    Possible duplicate of How do I control the system LEDs using my software? Commented Jun 9, 2018 at 15:34
  • 1
    did you just want to run something in bash to identify one particular Pi at a time, or did you want something that would result in the Pi's always "flashing" their own unique sequence? Commented Jun 10, 2018 at 1:39

4 Answers 4

25

On at least a Pi 3, you can turn the green (SD card activity) LED to be on constantly with the following command (as root):

echo 1 > /sys/class/leds/led0/brightness 

Now that Pi will have the green LED on steady, which makes it very easy to identify and label.

To put the LED back to its default state:

echo 0 > /sys/class/leds/led0/brightness echo mmc0 > /sys/class/leds/led0/trigger 

Iterate through all of your Pis this way until you've got them all addressed and labeled accordingly.

4
  • see raspberrypi.stackexchange.com/a/1504/78211 Commented Jun 9, 2018 at 15:32
  • 1
    you can do that on a Pi 1 and 2 as well Commented Jun 10, 2018 at 1:39
  • 1
    @stevieb that fixed the problem nicely, thanks. Shutting down and rebooting or disconnecting from the network weren't in the running since I need to keep the cluster up and running. I just needed to identify which Pi was top of the stack so I could ssh into it and turn the HDMI port back on so I could attach it to a display. Commented Jun 13, 2018 at 11:13
  • Thanks @Nick. If it did indeed solve your problem, please accept the answer. Commented Jun 13, 2018 at 17:53
14

Shut one of them down. There should be recognizable behavior from the green light, which will eventually go out.

Then put a label on that pi with its ipname.

Then you can start that one up again.

Repeat until all are marked.

Or you can shut them all down, and then bring them up one at a time and see what ip number comes up in your router.

Either a physical label or a hostname with a really good description of where they are if that won't change is a very useful thing. If they use Ethernet, you can wrap the label around the cable.

3

I would recommend just pulling the ethernet cable, and pinging each Pi in turn. Which does then not reply? These other solutions are neat, but ping is evergreen. If for some reason you’ve filtered icmp requests on these Pis, you can use nping from the nmap package: nping —arp 192.168.0.25

If you’re in a hurry, just use Fing (free) from Play/App store to do a quick arp scan, and see which host drops off when you pull a cable.

And assign static IPs based on MAC address in your dhcpd.conf to avoid this kind of problem. ISC-DHCPD is just what you need. It’s a beautiful service. Don’t use dnsmasq unless you need its many++ features.

Print dymo-labels with MACs, IPs and hostnames and stick them on top of each Pi. Don’t rely on mDNS/avahi/bonjour/auto-anything, it’s not foolproof. Besides, avahi-daemon has had some serious security problems over the years.

/etc/hosts remains king for small lab/SoHo networks, I always use it as a reference for my dhcpd static clients.

3
  • 1
    When I bothered starting to use my (single) Pi as a dhcp server I went ahead and set up a fake domain (.ivan of course) and made DNS entries for things I have a static-dhcp set up for... which turns out to be all of my devices. Guests get true DHCP. Much easier than /etc/hosts especially for devices where you can't do that - like my iphone. Commented Jun 10, 2018 at 18:18
  • @ivanivan I only keep /etc/hosts entries for static dhcp entries. It is easier to grep than dhcpd.conf Commented Jun 10, 2018 at 18:33
  • What make you think that the RasPis are not connected by WiFi? Commented Sep 4, 2020 at 8:14
0

I can't change the color of the led for some reason following @stevieb's instruction. However following similar path, I was able to turn on and off the power led by changing the led1 value instead.

echo 0 > /sys/devices/platform/leds/leds/led1/brightness <-- turn it off echo 1 > /sys/devices/platform/leds/leds/led1/brightness <-- turn it back on

1
  • 1
    The green led is a green led. What color on what led do you want to change and why? Commented Sep 4, 2020 at 8:16

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.