check
check
check
check
check
check
check
check
check
check
Imagine walking into a room, and the lights gently brighten just before you reach the switch. Or picture your outdoor security system activating subtly as someone approaches the gate. These seamless experiences aren’t just futuristic concepts; they’re achievable today with the power of ESPHome proximity sensors. By combining affordable hardware with the incredible flexibility of the ESPHome firmware, you unlock a world of intelligent automation tailored precisely to your needs. This guide dives deep into how proximity sensors integrate effortlessly with ESPHome, the different types available, practical setup instructions, and inspiring ideas to elevate your smart home.
Understanding the Core: What are Proximity Sensors? At their essence, proximity sensors detect the presence or absence of an object within a specific range without needing physical contact. They achieve this through various technologies, each with unique strengths:

Why ESPHome Makes Proximity Sensing Accessible ESPHome shines as a platform for integrating proximity sensors into your Home Assistant ecosystem for several compelling reasons:
filters (e.g., offset, sliding_window_moving_average, calibrate_linear) to smooth noisy sensor readings, apply offsets, or linearize responses directly within the YAML configuration, drastically improving reliability.Getting Hands-On: ESPHome Proximity Sensor Setup Example Let’s illustrate with a common scenario: adding an HC-SR04 ultrasonic sensor to an ESP32 board via ESPHome.
VCC to the ESP32 5V (or 3.3V if your sensor supports it, but 5V is standard).GND to the ESP32 GND.Trig pin to a GPIO pin on the ESP32 (e.g., GPIO16).Echo pin to another GPIO pin on the ESP32 (e.g., GPIO17).esphome:
name: garage-door-proximity
platform: ESP32
board: nodemcu-32s
# Enable logging for debugging
logger:
# Enable Home Assistant API
api:
encryption:
key: "your_encryption_key"
ota:
password: "your_ota_password"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Configure the ultrasonic sensor (HC-SR04)
sensor:
- platform: ultrasonic
trigger_pin: GPIO16
echo_pin: GPIO17
name: "Garage Door Distance"
id: garage_distance
unit_of_measurement: "cm"
update_interval: 1s
# Optional but recommended filters for smoothing
filters:
- sliding_window_moving_average: # Take average of last 5 readings
window_size: 5
send_every: 1
- calibrate_linear: # Apply calibration mapping
- 0.0 -> 0.0
- 100.0 -> 105.0
# Set a timeout to prevent hangs (in microseconds, 11600us ~ 2m)
timeout: 2m
This configuration defines an ultrasonic sensor, applies smoothing and calibration, and publishes the distance in centimeters to Home Assistant every second. The id allows referencing this sensor elsewhere in the YAML (e.g., in automations or other components).
Beyond Distance: Unleashing Automation Possibilities Integrating proximity sensors with ESPHome opens a treasure trove of automation ideas: