In smart homes, automatic lighting adds comfort and energy savings. Toutlines an excellent DIY project that combines an Arduino UNO, a RCWL‑0516 microwave sensor, a relay module, and an LED or AC bulb to create a motion-triggered light system
What’s Inside & How It WorksThe core of the project is the RCWL‑0516 — a low-cost, Doppler‑radar‑based sensor that detects motion from any object, not just warm bodies. It works even through glass or thin materials and is unaffected by heat-based false alarms that sometimes plague PIR sensors The sensor outputs a digital HIGH when it detects movement, which the Arduino reads to control lighting.
Components Required- Arduino Uno
RCWL‑0516 microwave motion sensor
- RCWL‑0516 microwave motion sensor
Single-channel relay module (for switching AC loads)
- Single-channel relay module (for switching AC loads)
LED with a 220 Ω resistor (for visual feedback)
- LED with a 220 Ω resistor (for visual feedback)
Jumper wires and breadboard
- Jumper wires and breadboard
USB cable (for programming Arduino)
- USB cable (for programming Arduino)
AC bulb (optional, if using relay to drive mains lamp)
AC bulb (optional, if using relay to drive mains lamp)
Circuit ConnectionsRCWL‑0516 VCC → Arduino 5 V
- RCWL‑0516 VCC → Arduino 5 V
RCWL‑0516 GND → Arduino GND
- RCWL‑0516 GND → Arduino GND
RCWL‑0516 OUT → Arduino digital pin 2
- RCWL‑0516 OUT → Arduino digital pin 2
LED (with resistor) → Arduino digital pin 7 → GND
- LED (with resistor) → Arduino digital pin 7 → GND
Relay module VCC & GND → Arduino 5 V & GND
- Relay module VCC & GND → Arduino 5 V & GND
Relay input (IN) → Arduino digital pin 10
- Relay input (IN) → Arduino digital pin 10
AC bulb wired to relay output terminal → mains power (ensure safe handling)
- AC bulb wired to relay output terminal → mains power (ensure safe handling)
cpp
CopyEdit
// AUTO LIGHT – TECHATRONIC.COM
int val = 0;
void setup(){
Serial.begin(9600);
pinMode(2, INPUT); // Sensor output
pinMode(7, OUTPUT); // LED feedback
pinMode(10, OUTPUT); // Relay control
digitalWrite(10, HIGH); // Relay normally off
}
void loop(){
val = digitalRead(2);
Serial.println(val);
delay(100);
if(val == 1){
digitalWrite(7, HIGH); // LED ON
digitalWrite(10, LOW); // Relay ON → lamp on
}
else {
digitalWrite(7, LOW);
digitalWrite(10, HIGH); // Relay OFF → lamp off
}
}
cpp
CopyEdit
// AUTO LIGHT – TECHATRONIC.COM
int val = 0;
void setup(){
Serial.begin(9600);
pinMode(2, INPUT); // Sensor output
pinMode(7, OUTPUT); // LED feedback
pinMode(10, OUTPUT); // Relay control
digitalWrite(10, HIGH); // Relay normally off
}
void loop(){
val = digitalRead(2);
Serial.println(val);
delay(100);
if(val == 1){
digitalWrite(7, HIGH); // LED ON
digitalWrite(10, LOW); // Relay ON → lamp on
}
else {
digitalWrite(7, LOW);
digitalWrite(10, HIGH); // Relay OFF → lamp off
}
}
This code continuously polls the sensor pin: when motion is detected (val == 1), the LED and relay activate; otherwise, both are off
Advantages of the RCWL‑0516 Microwave SensorDetects all movement, not just heat-based motion, so it works even in very hot environments or with non-living objects moving n
- Detects all movement, not just heat-based motion, so it works even in very hot environments or with non-living objects moving
Offers 360° coverage, typically up to 5–8 m range depending on environment.
- Offers 360° coverage, typically up to 5–8 m range depending on environment.
Operates through glass or thin walls, making it more flexible than PIR in some mounting setups
- Operates through glass or thin walls, making it more flexible than PIR in some mounting setups
These sensors can be overly sensitive, sometimes triggering from motion in adjacent rooms or reflected movement. Reddit users suggest adjusting sensitivity or using shielding to constrict range
- These sensors can be overly sensitive, sometimes triggering from motion in adjacent rooms or reflected movement. Reddit users suggest adjusting sensitivity or using shielding to constrict range
Proper mounting height (2–4 m) helps avoid false triggers from ground-level traffic and improves detection consistency
Proper mounting height (2–4 m) helps avoid false triggers from ground-level traffic and improves detection consistency
Always be cautious when wiring mains-level components and use proper relays or optoisolators.
- Always be cautious when wiring mains-level components and use proper relays or optoisolators.
You can customize the system to include adjustable delay timers or ambient light sensing to avoid turning lights on during daylight hours.
- You can customize the system to include adjustable delay timers or ambient light sensing to avoid turning lights on during daylight hours.
Adding optional serial logging allows you to monitor detection events in real time and debug sensitivity or placement.
- Adding optional serial logging allows you to monitor detection events in real time and debug sensitivity or placement.
For multi-zone detection, consider integrating multiple sensors into one Arduino or expanding with wireless modules.
- For multi-zone detection, consider integrating multiple sensors into one Arduino or expanding with wireless modules.
Comments