Build a Smart Light Sensor with Motion and Lux Detection

Are you tired of motion sensors that turn on lights even when it's already bright enough? Traditional motion sensors send constant data to Home Assistant, increasing database size and processing load. In this project, we’re building an intelligent light sensor that only turns on the light when needed—based on both motion and ambient light levels. Plus, it reduces unnecessary data sent to Home Assistant, making your smart home more efficient.

Why This Sensor is Different Unlike regular motion sensors, this smart light sensor makes decisions locally. It determines whether the light should be turned on by checking real-time motion and lux levels before sending a simple "on" or "off" signal to Home Assistant. This means:

Components Needed

How It Works

  1. The PIR sensor detects motion.
  2. The lux sensor measures the current light level.
  3. If motion is detected AND the light level is below a set threshold, the sensor triggers the light.
  4. Instead of flooding Home Assistant with continuous data, the ESP8266 only sends necessary updates via MQTT.

Programming the ESP8266 This project is programmed in Arduino, with logic handled locally on the ESP8266. The timer function also runs on the ESP, ensuring lights stay on for a set duration without relying on Home Assistant calculations. MQTT is used for communication with Home Assistant.

Step-by-Step Guide

  1. Install Arduino IDE and add ESP8266 board support.
  2. Connect the sensors to the ESP8266.
  3. Write the Arduino code to process motion and lux data.
  4. Set up MQTT communication for integration with Home Assistant.
  5. Upload the code to the ESP8266.
  6. Test and fine-tune the lux threshold and timing.

Wiring this project :

Watch the Full Video Want to see the full build process, including wiring, coding, and integration with Home Assistant? Watch the complete tutorial on YouTube: YouTube

Final Thoughts This smart light sensor is a game-changer for efficient lighting automation. It reduces unnecessary triggers, keeps your Home Assistant setup lean, and ensures lights only turn on when truly needed. Try it out and optimize your smart home today!

💾 Get the Code and 3D Print Files Find all the source code and 3D print files for this project on GitHub: GitHub 3D-print files

Copyright © DIY-Sensors 2025