EmbeddedRelated.com

ESP32 Motion-Activated 3D Printed Lamp

A motion-activated 3D printed lamp using an ESP32 for control and an infrared or microwave sensor for presence detection.

Beginner Project — The project uses standard development boards, a simple digital sensor, and a single MOSFET switch, making it an ideal entry-level project with plenty of community library support.
Assumptions:
  • The lamp uses a 5V or 12V LED strip for illumination.
  • The user prefers a breadboard-friendly development board for prototyping.
  • The lamp will be powered by a standard USB wall adapter or a DC barrel jack.
  • Presence detection range should be approximately 3-5 meters.

Bill of Materials

Microcontroller
Top Pick ESP32-DevKitC Espressif Systems From our database
The ESP32-DevKitC is the most versatile and well-documented choice for this prototype, providing ample I/O and easy integration with common libraries.
Digikey $10.00 (1,005 in stock)
ESP32-C3-DEVKITM-1-N4X Espressif Systems From our database
Cost-effective RISC-V single-core option; ideal if high-speed processing isn't needed but WiFi/BLE is required for smart features.
ESP32-S3-DEVKITC-1-N8R8 Espressif Systems From our database
High-end version with native USB and more RAM; useful if adding complex animations or voice control later.
Sensor
Top Pick AM312 Generic
The AM312 is recommended because its compact size fits better inside 3D printed housings, and it is more immune to the electromagnetic interference generated by the ESP32's WiFi radio compared to the HC-SR501.
Digikey $51.61 (1,000 in stock) Mouser $0.40 (173 in stock)
HC-SR501 Generic
Industry standard PIR sensor; adjustable sensitivity and delay via onboard potentiometers; very low cost.
RCWL-0516 Generic
Microwave Doppler radar sensor; can detect motion through plastic lamp enclosures, allowing it to be completely hidden.
Actuator
Top Pick IRLZ44NPBF Infineon
Top pick: IRLZ44NPBF (Infineon). Robust logic-level MOSFET with high current capacity and low on-resistance, ensuring it stays cool during operation.
G5Q-14 DC5 Omron From our database
Mechanical relay; provides total electrical isolation; best choice if switching an AC-powered bulb instead of a DC strip.
Power Supply
Top Pick KLDX-0202-A Kycon
Using a KLDX-0202-A barrel jack allows you to use a standard external power brick, which is safer and more reliable than DIY AC/DC conversion.
Digikey $0.69 (26,044 in stock) Mouser $0.69 (7,804 in stock)
AP2210N-3.3TRG1 Diodes Incorporated From our database
LDO to regulate 5V down to 3.3V for the sensors if the MCU dev board's regulator is fully loaded.

Compatibility Notes

  • The ESP32-DevKitC operates at 3.3V logic; ensure the MOSFET chosen is 'logic-level' (like FQP30N06L) to ensure it fully turns on with 3.3V.
  • If using a 12V LED strip, the 12V supply must be connected to the LED anode, and a common ground must be shared between the 12V supply and the ESP32.
  • PIR sensors like HC-SR501 often require 5V VCC but output 3.3V logic, which is compatible with ESP32.

You'll Also Need

  • LED Strip (5V or 12V RGB or White)
  • 220 Ohm gate resistor for MOSFET
  • 10k Ohm pull-down resistor for MOSFET gate
  • Breadboard and jumper wires
  • 3D printed enclosure
  • External power adapter (5V or 12V depending on LEDs)
Estimated BOM Cost: $20-25 (based on live distributor pricing)
Add to Digi-Key Cart

Design Considerations

EMI and Sensor Stability
PIR sensors are sensitive to RF noise; placing the ESP32 antenna too close to the PIR sensor can cause false triggers when WiFi is active. Keep at least 5-10cm of separation or use a shielded microwave sensor like the RCWL-0516.
Soft-Start PWM
To create a premium feel, use the ESP32 LEDC peripheral to fade the LEDs on and off over 1-2 seconds rather than an abrupt switch. This also reduces the inrush current spike on your power supply.
Thermal Management
If driving more than 2 meters of high-density LED strip, the MOSFET may become hot. Ensure the 3D printed housing has ventilation holes and consider a small clip-on heatsink for the TO-220 package if current exceeds 3A.
Presence vs. Motion
PIR sensors detect 'change' in heat. If a person sits perfectly still in the room, the lamp will turn off. Implement a 'keep-on' timer in firmware (e.g., 5 minutes) that resets every time motion is detected to avoid annoying the user.
Ambient Light Sensing
Consider adding a low-cost photoresistor (LDR) so the lamp only turns on when the room is actually dark. This saves power and prevents the lamp from triggering unnecessarily during the day.

Want to customize this project or build something different?

Try the Project Advisor