Build a Wi-Fi Presence Detector Using ESP32 and Home Assistant

June 10, 2025 · ESP32, Home Assistant, Wi-Fi Presence Detection, Smart Home Automation, DIY IoT

Ever walked into a room and wished the lights would just know to turn on? Or wanted your smart home to react the moment your phone connects to Wi-Fi? With an ESP32 and Home Assistant, you can build a Wi-Fi presence detector that does exactly that—no fancy sensors or wearables required. In this guide, I’ll walk you through my own journey of setting this up, complete with code snippets, troubleshooting tips, and a few laughs at my own mistakes.

Why Wi-Fi Presence Detection?

Bluetooth-based presence detection is common, but Wi-Fi offers better range and reliability—especially if your phone is stubborn about keeping Bluetooth on (looking at you, iOS users). By detecting Wi-Fi probe requests (the “Hey, is my network here?” signals devices broadcast), an ESP32 can act as a low-cost, low-power presence sensor.

What You’ll Need

Pro Tip: If your ESP32 struggles with Wi-Fi range, consider adding an external antenna. My first attempt failed because my router was too far away—turns out walls aren’t Wi-Fi’s best friend.

Step 1: Flash ESP32 with ESPHome

ESPHome makes firmware management a breeze. If you haven’t installed it yet, go to Home Assistant → Add-ons → ESPHome and hit install. Then:

  1. Create a new device in ESPHome, naming it something like wifi_presence_detector.
  2. Use the following YAML configuration (adjust ssid and password to match your Wi-Fi):
esphome:
  name: wifi_presence_detector
  platform: ESP32
  board: esp32dev

wifi:
  ssid: "Your_WiFi_SSID"
  password: "Your_WiFi_Password"
  power_save_mode: none # Disable sleep for real-time detection

api:
  password: "your_api_password"

ota:
  password: "your_ota_password"

logger:
  level: DEBUG # Helpful for troubleshooting

binary_sensor:
  - platform: wifi_scan
    ssid: !secret target_ssid # Replace with the SSID of the device you're tracking
    name: "Phone Presence"
    id: phone_present
  1. Flash the ESP32 via USB. Click “Install” in ESPHome, select “Plug into this computer,” and follow the prompts.
Troubleshooting: If the ESP32 won’t connect, double-check your Wi-Fi credentials and ensure your network is 2.4GHz (ESP32 doesn’t play nice with 5GHz for scanning).

Step 2: Integrate with Home Assistant

Once flashed, the ESP32 should appear in Home Assistant’s Integrations tab. If not, manually add it via Configuration → Devices & Services → Add Integration → ESPHome.


Step 3: Automate All the Things!

Now for the fun part: automations! Here’s one to turn on lights when you arrive home:

automation:
  - alias: "Turn on lights when phone arrives"
    trigger:
      platform: state
      entity_id: binary_sensor.phone_present
      to: "on"
    action:
      service: light.turn_on
      target:
        entity_id: light.living_room_lights

Want to get fancy? Add a delay to avoid false triggers when your phone briefly disconnects:

trigger:
  platform: state
  entity_id: binary_sensor.phone_present
  to: "on"
  for:
    minutes: 1 # Only trigger after 1 minute of continuous presence

Common Pitfalls and Fixes

  1. False Positives/Negatives:

    • Adjust the scan_interval in ESPHome (default: 60s). Shorter intervals drain battery faster but improve accuracy.
    • Use MAC address filtering for precision (add mac_address: "AA:BB:CC:..." under binary_sensor).
  2. ESP32 Overheating:

    • If your board gets warm, lower the scan_interval or add a heatsink. Mine once got so hot I could’ve fried an egg on it.
  3. Home Assistant Delays:

    • Ensure your ESP32 and HA are on the same local network to minimize latency.

Going Further


FAQ

Q: Can I detect multiple devices?
A: Absolutely! Duplicate the binary_sensor block in ESPHome for each SSID/MAC.

Q: Will this work if my phone’s Wi-Fi is off?
A: Nope—devices must broadcast probe requests. iOS 15+ and Android 10+ randomize MAC addresses by default, but you can whitelist your home network to avoid this.

Q: How accurate is Wi-Fi presence detection?
A: Range is ~10-20m indoors. For pinpoint accuracy, combine with Bluetooth (like my Xiaomi Mijia temperature guide).


Now go forth and make your home just a little smarter. And if your ESP32 starts judging your comings and goings… well, that’s between you and your Wi-Fi router. 😉

Building something like this in production?

I help teams turn setups like this into reliable, monitored infrastructure.

Get a free consulting call

Get my monitoring stack checklist

The exact checklist I use when setting up observability for a new team. No spam, unsubscribe anytime.