Building DriveLights

Posted on 12/2/2026 in blog with tags Hardware IoT Homelab

In the previous post I described the front-panel lights I added to the drives in my rack. This one is the how: parts, wiring, firmware and the bit of software that feeds it. The whole project is on GitHub as DriveLights.

Parts

Very little, which was the point:

Part Qty
Wemos D1 mini (ESP8266) 1
Pixels cut from a 5 V WS2812B LED strip 1 per drive (up to 4)
330 Ω resistor, for the data line 1
100 µF capacitor, 10 V or more 1

Plus a micro-USB cable that actually carries data. More on that below.

Cutting the pixels

The strip I had is the dense kind where every 5050 LED has its own driver chip inside and there's a cut line between each one. Each pixel has three pads on either side: + (5 V), G (ground) and a data pad marked I on the way in and O on the way out.

Cut straight through the middle of the copper pads, so each pixel keeps half a pad on both sides to solder to. Each pixel keeps its own little capacitor too, so nothing else is needed per LED.

On the front panel, each pixel sits behind a 5 mm hole. A short piece of clear acrylic rod or a bit of printed white plastic in the hole works as a diffuser, so you see a round dot rather than a bare square LED.

Wiring

The pixels form a single chain, one per bay, left to right:

D4 ── 330 Ω ── I [bay 1] O ── I [bay 2] O ── I [bay 3] O ── I [bay 4]
5V ──┬── + of every pixel
     └── 100 µF ── GND
GND ──── G of every pixel

Follow the arrows printed on the strip: data goes into I and comes out of O. If you only have two drives, stop the chain after two pixels. The firmware doesn't mind.

D4 isn't a random choice. On the ESP8266 it's the only pin that can drive these LEDs through the chip's UART hardware, which keeps the timing clean. A side effect is that the D1 mini's own little blue LED, which shares that pin, blinks faintly whenever the colours change.

Power comes from USB. Four pixels at the brightness I use draw well under 100 mA.

Firmware

The firmware is a few hundred lines of Arduino code, built with PlatformIO and the NeoPixelBus library. Wi-Fi is switched off, since it isn't needed and its interrupts can upset the LED timing.

The board listens on USB serial for one-line commands:

Command What it does
? Replies with DRIVELIGHTS, the version and the number of bays, so the PC can find it
A 200 0 0 0 Activity level per bay, 0 to 255
H o w - - Health per bay: ok, warn, bad, asleep, unknown, or - for no drive
T Lamp test: red, green, blue

Activity is shown as a flicker rather than a steady glow. Every 40 ms each busy bay rolls the dice, and the higher its activity level, the more likely it is to be lit. Light I/O gives occasional blinks, a big copy is almost solid blue, and it ends up looking a lot like an old hard-drive light.

There's also a watchdog: if no health update arrives for 30 seconds, every bay switches to a faint white breathing. Without it, a crashed script would leave the lights showing whatever they showed last, and "everything looks fine" is the worst possible failure mode for a health light.

Flashing it is one command:

cd firmware
pio run -t upload

This is where I got stuck for a while. The PC wouldn't see the board: no USB sound, no COM port, nothing in Device Manager. The cable was a USB-C to micro-USB one that, it turns out, only carries power. A boring old USB-A cable fixed it instantly. If your board lights up but the PC doesn't notice it, it's the cable.

The agent

On the PC side there's a small Python script. It runs on freeside, the Windows VM, as a scheduled task under the SYSTEM account, so it starts at boot before anyone signs in. Windows only lets administrators send SMART commands, which is why it needs that account.

Every five minutes it runs smartctl -j -a -n standby on each drive. The -j gives JSON, and the -n standby part matters more than it looks: it makes smartctl skip a sleeping drive instead of spinning it up just to ask how it's doing. The script then turns the result into one of the health states:

  • Red if there are pending or uncorrectable sectors, reallocated sectors have grown, the last self-test failed, the drive reports SMART FAILED, or it's at 60 °C or more.
  • Amber if there are a few reallocated sectors that aren't growing, CRC errors or command timeouts have gone up, or it's at 50 °C or more.

"Gone up" means compared with a baseline saved the first time each drive was seen. Once I've dealt with something (say, replaced a cable), drivelights.py --ack accepts the current numbers as the new baseline. A sleeping drive keeps showing its last warning, so a problem doesn't disappear just because the disk spun down.

Twenty times a second the script also reads Windows' per-disk I/O counters (through psutil) and sends each bay's activity level.

Drives are tied to bays by serial number in a small config file, so replugging a drive into a different USB port doesn't shuffle the lights around:

{
  "bays": ["<serial of left drive>", "<serial of right drive>", "", ""],
  "temp_warn_c": 50,
  "temp_bad_c": 60
}

An empty string is an empty bay, and its pixel stays dark. A drive that's listed but not connected shows purple, so an unplugged drive stands out instead of just going quiet.

The Proxmox part

Because the drives belong to a VM, the D1 mini and every USB adapter have to be passed through to it, and two details tripped me up:

  • Pass them through by port, not by device ID. All the drive adapters share the same USB ID, and an ID-based mapping only grabs one of them.
  • Check what Windows actually sees. Get-Disk should list the drives with BusType USB and their real model names. If they show up as QEMU HARDDISK, they're attached as virtual disks and SMART can't reach them.

After any change to USB passthrough, the VM needs a full shutdown and start. A reboot from inside Windows isn't enough.

Was it worth it?

For a handful of cheap parts, most of which I already had, yes. The rack is dark almost all the time, the pixels flicker when the drives are busy, and the one time something lit up amber, it told me the drives run warmer than I'd like.

Related media