Skip to main content
Automated Cabinet Lighting With a Raspberry Pi: Build Guide

Automated Cabinet Lighting With a Raspberry Pi: Build Guide

A parts list, wiring notes, and automation logic for triggering LED strips from a door or Zigbee sensor.

How a Raspberry Pi, a door sensor, and an addressable LED strip combine into automated cabinet lighting — parts, wiring, power budgeting, and automation logic.

A Raspberry Pi wired to a door or reed sensor, paired with an addressable LED strip, turns a cabinet, workbench drawer, or media console into a light that switches on the moment it opens. The build has three parts: a sensor that detects the door state, a controller that decides what to do, and an LED strip that responds. This guide covers component selection, wiring, power budgeting, and the automation logic that ties it together — without inventing benchmark numbers the underlying hardware doesn't publish.

What You Need

ComponentRoleNotes
Raspberry Pi (Zero 2 W, 3B+, or 4)ControllerAny model with a 40-pin GPIO header works via the gpiozero library
Reed switch or Zigbee contact sensorTriggerA wired reed switch is the simplest option; a Zigbee sensor adds wireless flexibility
Addressable LED strip (WS2812B or APA102)Light sourceCut-to-length, individually addressable pixels
5V power supplyPowerSize it to the strip's LED count, not just the Pi's draw
Zigbee coordinator (USB stick)BridgeOnly needed if the sensor is wireless
microSD cardOS storageRaspberry Pi OS boots from this

Choosing the Raspberry Pi Model

Any Raspberry Pi with a GPIO header can read a sensor and drive an LED strip through Python's gpiozero library, per its official documentation. A Pi Zero 2 W is enough for a single-cabinet build with no other duties. Stepping up to a Pi 4 makes sense when the same board is also running Home Assistant, a Zigbee2MQTT bridge, or handling more than one cabinet — the same class of board used in the retro emulation cabinet build, where a Pi 4 8GB carries frontend, emulation, and I/O duties simultaneously. If the project is meant to stay single-purpose rather than multi-tasking, a microcontroller-based approach — similar in spirit to the RP2040-based DIY 3D Vision emitter build — is a lighter-weight alternative to a full Linux board.

Wired Reed Switch vs. Zigbee Contact Sensor

Wired reed switchZigbee contact sensor
ConnectionDirect to GPIO pinWireless, via a Zigbee coordinator
LatencyNear-instant (polled or interrupt-driven GPIO)Adds a network hop through the coordinator and, if used, an MQTT broker
Hub requiredNoYes — a Zigbee coordinator (e.g., a USB stick) plus a bridge like Zigbee2MQTT
Cable run limitsShort runs only (voltage drop, noise)None — it's wireless
Best forA single nearby cabinetMultiple cabinets, or integrating with an existing Home Assistant setup

Zigbee is a low-power mesh networking standard maintained by the Connectivity Standards Alliance, designed for exactly this kind of always-on sensor network. A mesh of Zigbee devices can also extend coverage between rooms in a way a single wired GPIO run can't.

Picking an Addressable LED Strip: WS2812B vs. APA102

WS2812B (NeoPixel)APA102 (DotStar)
Data linesSingle wire, timing-criticalSeparate data and clock lines
Noise toleranceLower — long runs are more prone to glitchingHigher — the clock line makes it more forgiving over distance
Refresh rateLowerHigher
CostGenerally cheaperGenerally more expensive

Per Adafruit's NeoPixel Uberguide, each individual WS2812-style LED can draw up to roughly 60mA at full white brightness (20mA per red/green/blue channel). That figure scales directly with strip density and length:

Strip densityLEDs in 1 meterApproximate max draw at full white
30 LEDs/m30~1.8A (9W)
60 LEDs/m60~3.6A (18W)
144 LEDs/m144~8.6A (43W)

Those are worst-case numbers — a cabinet light dimmed to a warm white at partial brightness draws a fraction of that — but they're the figures to design a power supply around, not the number the strip will typically pull day to day.

Wiring and Power Notes

The Raspberry Pi's GPIO pins output 3.3V logic; WS2812-style strips expect a 5V data signal, which is a common source of flaky first-pixel behavior if a level shifter isn't used. Power the LED strip from its own 5V supply rather than the Pi's 5V rail — the Pi can't source enough current for more than a handful of pixels. Adafruit's guide recommends injecting power at both ends of longer runs and adding a large capacitor across the strip's power leads to smooth out the current spikes that come with fast color changes; both practices reduce the visible voltage-drop dimming that shows up as a color shift toward the far end of a long strip.

Software: Reading the Sensor and Driving the Automation

For a directly wired reed switch, gpiozero exposes a Button-style object that can bind a callback to the pin's open/closed transition, which then hands off to whichever library drives the LED strip. For a Zigbee sensor, the flow runs through Zigbee2MQTT, which publishes the sensor's state as an MQTT message; a Home Assistant automation (or any script subscribed to the same MQTT broker) reacts to that message by calling a light entity's turn-on service, typically with an auto-off timer once the door closes again. Home Assistant's own MQTT integration documentation covers the entity and automation setup for this pattern in detail.

Storage: Picking a microSD Card for Raspberry Pi OS

The Pi boots and runs from its microSD card, so card choice matters more for reliability than raw capacity in a project this size. A Raspberry Pi OS Lite install running only the sensor script and an MQTT client fits comfortably on a 32GB SanDisk Ultra microSDHC card, currently listed at $28.00 in SpecPicks' catalog (price and availability may vary). If the same Pi is also running Home Assistant with a growing recorder database, camera snapshots, or extensive logging, a larger card such as the 256GB SanDisk Ultra microSDXC, listed at $52.99, leaves more headroom before log rotation becomes a chore.

Budget Tiers

Rather than a single total, cost here scales with two choices: sensor type and strip length. A wired reed switch driving a short LED run under a single cabinet is the cheapest configuration — no coordinator, no hub, minimal wiring. Adding a Zigbee contact sensor and coordinator brings in a wireless bridge and the flexibility to cover multiple cabinets from one Pi, at the cost of an extra device in the chain. Strip length and LED density are the other lever — longer, denser strips need a beefier power supply per the draw figures above, which is a bigger driver of total cost than the sensor choice itself.

Troubleshooting Common Issues

Voltage drop on long runs. Symptoms show up as a color shift (often toward red or amber) at the far end of the strip. Power injection at both ends and thicker-gauge wire for the power rail are the standard fixes described in Adafruit's guide.

RF interference with a Zigbee coordinator. The Raspberry Pi 4's USB 3.0 controller is a well-documented source of 2.4GHz interference in Raspberry Pi community discussions. Moving the Zigbee coordinator to a USB extension cable, away from the board and any USB 3.0 devices, is a common mitigation.

Thermal management in an enclosed cabinet. Raspberry Pi boards throttle performance once internal temperature crosses a defined threshold, per Raspberry Pi's official documentation — relevant if the same board is also handling video decoding or a database, not just polling a GPIO pin. Passive ventilation or a small heatsink is worth adding if the enclosure fully seals the board in.

Related Builds

A cabinet-lighting Pi pairs naturally with other small-footprint SBC and microcontroller projects: the retro emulation cabinet on a Pi 4 8GB uses the same board family for a different job, the RP2040-based 3D Vision emitter shows the microcontroller-only alternative to a full Linux board, and running a large language model on CPU alone is a reminder of how much headroom even a modest ARM board has for tasks well outside GPIO work. If the cabinet in question is a retro-gaming display case rather than a kitchen cabinet, it's worth pairing the lighting build with a look at 1:1 faithful game remakes for what to put behind the glass, and a handheld gaming PC with a keyboard is a reasonable side project for the same maker toolkit.

Citations and sources

This piece is editorial synthesis based on publicly available information. No independent first-party benchmarking is reported.

Products mentioned in this article

Tap any product for full specs, live Amazon & eBay pricing, and alternatives.

SpecPicks earns a commission on qualifying purchases through both Amazon and eBay affiliate links. Prices and stock update independently.

Sources

— SpecPicks Editorial · Last verified 2026-08-04

More guides & deep dives from the SpecPicks archive

Browse all articles & guides →

More reviews from the SpecPicks archive

Browse all reviews →

More buying guides from SpecPicks

Browse all buying guides →