Smart Staircase Lighting with ESP32-C3 and Ultrasonic Sensors

I recently upgraded my staircase with an automated LED lighting system that responds to motion at both the top and bottom. Built around an ESP32-C3 Super Mini and two HC-SR04 ultrasonic sensors, the setup detects when someone enters the staircase and triggers a smooth lighting effect that runs along a hidden LED strip in the handrail.

Hardware Setup

The ESP32-C3 Super Mini is tucked away in the staircase closet, keeping all electronics hidden but accessible. From there, I ran wires to two HC-SR04 ultrasonic sensors—one positioned at the top and one at the bottom of the staircase. These sensors detect presence by measuring distance changes when someone walks into their range.

For the lighting itself, I routed a channel into the bottom of the wooden staircase handle using a router, creating a clean insertion point for an addressable LED strip. The strip runs the full length of the handrail, providing even illumination along the entire staircase.

How It Works

The logic is straightforward but effective:

  • Bottom sensor triggered: When the lower HC-SR04 detects someone entering from the ground floor, the LED strip lights up from bottom to top, guiding the person upward.
  • Top sensor triggered: When the upper sensor detects presence at the top landing, the LEDs activate from top to bottom, lighting the way down.
This bidirectional animation not only looks impressive but also provides practical visibility exactly where it's needed, depending on the direction of travel.

Why Ultrasonic Sensors?

Unlike PIR motion sensors, which can be finicky with placement and angles, the HC-SR04 ultrasonic sensors give reliable distance-based detection. They work well in the confined space of a staircase and aren't affected by ambient light changes. Placing them in the closet keeps the wiring tidy and protects the ESP32 from accidental bumps.

Power and Control

The ESP32-C3 handles all the sensor readings and LED control in a single compact package. Its small footprint made it easy to fit into the closet, and its Wi-Fi capability leaves room for future Home Assistant integration if I want to add scheduling, brightness control, or automation triggers later.

The result is a clean, functional upgrade that makes navigating the stairs safer at night while adding a bit of smart-home flair to the house.

The code for the Home Assistant Animation

alias: Stairs movement
description: ''
triggers:
  - type: value
    device_id: [DEVICE ID]
    entity_id: [ENTITY ID]
    domain: sensor
    trigger: device
    below: 0.6
  - type: value
    device_id:  [DEVICE ID]
    entity_id: [ENTITY ID]
    domain: sensor
    trigger: device
    below: 0.6
conditions:
  - condition: state
    entity_id:  [ENTITY ID]
    state:
      - 'off'
actions:
  - data:
      effect: Bottom to top
    target:
      device_id:  [DEVICE ID]
    action: light.turn_on
  - delay:
      hours: 0
      minutes: 0
      seconds: 30
  - target:
      device_id:  [DEVICE ID]
    action: light.turn_off
    data: {}
mode: single

Find me online

neomess.nl
github.com/neomess


Special thanks

home-assistant.io
kno.wled.ge (WLED)
Pexels.com for stock photo's

Contact

Email to info@myprojects.nl or ask your question using the form below.