I have a homelab that consists of similar looking HP Elitedesk machines and wanted a simple way to identify which machine was which. Super cheap really basic method to identify which machine I want to do something with from the shell. Also useful if you need to give instructions to another person remotely - you can identify which machine they need to work on.
I purchased a handful of the Waveshare RP2040-One devices and put this together.
Each device is controlled based on its serial number so you can have multiple devices plugged in and control each one specifically.
sudo apt update
sudo apt install -y git cmake gcc-arm-none-eabi libnewlib-arm-none-eabi \
build-essential libstdc++-arm-none-eabi-newlib
You might need to remove your os version of arm gcc. I built this on Ubuntu 24.04 LTS and had to use the arm site toolchain.
sudo apt remove gcc-arm-none-eabi binutils-arm-none-eabi
and install the arm version
cd ~
wget https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz
tar xf arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz
cd ~
git clone https://github.com/raspberrypi/pico-sdk.git
cd pico-sdk
git submodule update --init
echo 'export PICO_SDK_PATH=$HOME/pico-sdk' >> ~/.bashrc
source ~/.bashrc
cd ~
git clone https://github.com/raspberrypi/pico-examples.git
cd ~/pico-dev/USBNotify
rm -rf build
mkdir build && cd build
cmake .. -DPICO_BOARD=waveshare_rp2040_one
make -j$(nproc)
Once the code builds successfully insert the device while holding the boot button, it will present as a usb drive. Copy the uf2 file from the build directory to it and it will automatically disconnect and restart as a usb hid device. You'll need to be root or use sudo to control the device unless you do the following:
cp support/99-hid-led.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && sudo udevadm trigger
Remove and plug in your device again, you should no longer need to sudo to control it.
MacOS doesn't give access to hidraw directly so if you want to use this with a mac you need to install hidapitester
brew install hidapi
git clone https://github.com/libusb/hidapi
git clone https://github.com/todbot/hidapitester
cd hidapitester
make
move it
sudo mv hidapitester /usr/local/bin/
Example script for control in support directory also linux udev rule.
There are named colours in the example script ( red, green, blue, yellow, magenta, cyan,white, orange, purple,amber, indigo, off )
List all the devices on a machine:
./example.sh list
Scanning for Waveshare RP2040-One devices...
Node | Serial Number
/dev/hidraw4 | DE64A876CF551522
Control the LED with
./example.sh <DEVICE-SERIAL-NUMBER> <COLOUR> <EFFECT> <BRIGHTNESS>
eg
./example.sh DE64A876CF551522 red pulse 10
Valid effects are solid, pulse, flash, blip, rainbow.
The colour off just sets the RGB values to 0,0,0
The script is not a requirement you can write directly to the hidraw device yourself if you prefer.
You can save the colour, effect and brightness to the device so that it will start up with those options.
./example.sh <DEVICE-SERIAL-NUMBER> <COLOUR> <EFFECT> <BRIGHTNESS> --save
eg
./example.sh DE64A876CF551522 red pulse 10 --save
If you save your settings you should see the LED flash white 4 times and then return to your saved settings. On boot if you have no saved settings the LED with flash blue once, then red. If you have saved settings the LED will flash blue once and then green twice before applying those settings.
I'm pondering building a little enclosure with an acrylic segment being placed over the led so that a nameplate can be engraved with the machine name/id.