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?

Nick
  • 776
  • 4
  • 15

4 Answers4

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.

stevieb
  • 1,466
  • 9
  • 11
  • see https://raspberrypi.stackexchange.com/a/1504/78211 – Fabian Jun 09 '18 at 15:32
  • 1
    you can do that on a Pi 1 and 2 as well – Jaromanda X Jun 10 '18 at 01:39
  • @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. – Nick Jun 13 '18 at 11:13
  • Thanks @Nick. If it did indeed solve your problem, please accept the answer. – stevieb Jun 13 '18 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.

That Brazilian Guy
  • 452
  • 1
  • 8
  • 20
NomadMaker
  • 1,560
  • 9
  • 10
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.

user2497
  • 679
  • 5
  • 8
  • 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. – ivanivan Jun 10 '18 at 18:18
  • @ivanivan I only keep /etc/hosts entries for static dhcp entries. It is easier to grep than dhcpd.conf – user2497 Jun 10 '18 at 18:33
  • What make you think that the RasPis are not connected by WiFi? – Ingo Sep 04 '20 at 08: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
    The green led is a green led. What color on what led do you want to change and why? – Ingo Sep 04 '20 at 08:16