Build a motion-sensor light
A light that switches on when you walk by: a PIR motion sensor drives a small MOSFET switch, which turns on a USB LED strip. Build it on an 18650 cell with USB-C charging for closets and stairs, or on USB for a bedside light.
New to electronics? The words used on this page
- 18650
- A common lithium cell, a bit bigger than an AA battery, 3.6 to 3.7 V.
- TP4056
- A small, cheap board that charges one lithium cell from a USB charger.
- Multimeter
- A hand-held meter that measures voltage. Use it to check before you connect anything.
- Step-up (boost) board
- A small board that raises a voltage, for example 3.7 V up to 5 V.
- In parallel
- Batteries joined + to + and − to −. The capacity adds up, the voltage stays the same.
- Ground
- The negative (−) side of a 12 V system. In a car it is the bare metal body.
Which way is for you?
ABattery: 18650 with USB-C charging
Closets, stairs, cupboards. The sensor sleeps at about 15 µA, so a charge lasts weeks. Soldering · about 1 hour
You will need
- AM312 mini PIR sensorRuns straight from a lithium cell (2.7–12 V) and uses very little powerView on Amazon
- Logic-level MOSFET switch boardSwitches the light on when the sensor says so (D4184 or AO3400 board)View on Amazon
- MT3608 boost boardMakes 5 V for the USB LED stripView on Amazon
- 18650 lithium cells and a holder3.7 V cells. Buy cells from a battery shop; the holder snaps them in without solderingView on Amazon
- USB-C charging board (TP4056, with protection)Charges the lithium battery from a phone charger and protects it from running too lowView on Amazon
- USB LED strip (5 V)Warm white suits a night lightView on Amazon
- MultimeterTo check voltages before you connect anythingView on Amazon
Tools
Soldering iron, multimeter.
Step by step
- 1
Wire the cell holder to the charging board's B+ and B−.
- 2
Power the sensor: its VCC to OUT+, GND to OUT−, and its OUT pin to the MOSFET board's signal input (SIG or PWM).
- 3
Switch the boost board: its IN+ to OUT+; its IN− goes through the MOSFET board (DC− / load −) to OUT−.
Check: the MOSFET switches the − side, so the boost board only runs when there's motion.
- 4
Set the boost board to 5.0 V: wave at the sensor to switch it on and adjust while measuring.
- 5
Connect the LED strip to the boost board's OUT+ and OUT−.
- 6
Fix it in place, sensor facing where people walk. Charge with a phone cable when it dims.
Every connection, one by one
Tick each one as you make it. When every box is ticked, the wiring is complete.
| Done | From | To | Wire |
|---|---|---|---|
| Cell holder + | Charging board B+ | Red | |
| Cell holder − | Charging board B− | Black | |
| Charging board OUT+ | Sensor VCC | Red | |
| Charging board OUT− | Sensor GND | Black | |
| Sensor OUT | MOSFET board signal input (SIG / PWM) | Thin wire, any colour | |
| Charging board OUT+ | Boost board IN+ | Red | |
| Boost board IN− | MOSFET board load − (DC−) | Black | |
| MOSFET board GND | Charging board OUT− | Black | |
| Boost board OUT+ (5.0 V) | LED strip + | Red | |
| Boost board OUT− | LED strip − | Black |
As an Amazon Associate I earn from qualifying purchases. Links open Amazon search results.
BUSB-powered with an adjustable sensor
Bedside or desk, next to a socket. The HC-SR501 sensor has dials for on-time and sensitivity. Soldering · 30 minutes
You will need
- HC-SR501 PIR sensorAdjustable on-time (5 s to 5 min) and sensitivity; needs 5 VView on Amazon
- Logic-level MOSFET switch boardD4184 or AO3400 boardView on Amazon
- Old USB cablePower from a phone chargerView on Amazon
- USB LED strip (5 V)View on Amazon
Tools
Soldering iron, multimeter.
Step by step
- 1
Cut the USB cable: red is +5 V, black is ground.
- 2
Power the sensor from red (VCC) and black (GND). Its OUT pin goes to the MOSFET board's signal input.
- 3
Wire the LED strip's + to red, and its − through the MOSFET board (load −) to black.
- 4
Set the sensor's time dial for how long the light stays on, and the sensitivity dial for the distance.
Every connection, one by one
Tick each one as you make it. When every box is ticked, the wiring is complete.
| Done | From | To | Wire |
|---|---|---|---|
| USB cable red wire | Sensor VCC | Red | |
| USB cable black wire | Sensor GND | Black | |
| Sensor OUT | MOSFET board signal input | Thin wire, any colour | |
| USB cable red wire | LED strip + | Red | |
| LED strip − | MOSFET board load − | Black | |
| MOSFET board GND | USB cable black wire | Black |
As an Amazon Associate I earn from qualifying purchases. Links open Amazon search results.
Check your numbers
How long a charge lasts and how long it takes to recharge.
How this is calculated
- Method
- Energy per day = LED W × seconds on × times a day ÷ 3,600, plus the sensor's standby. Days per charge = usable battery Wh ÷ energy per day.
- Assumptions
- One 18650 = 3.6 V × 2.6 Ah × 90% usable × 88% converter efficiency. Sensor standby about 15 µA (HC-SR505 class).
- Sources
- HC-SR501 and HC-SR505 datasheets; typical 18650 ratings.
Stay safe
- Lithium cells need a charging board with protection; insulate every joint.
- Keep the parts away from clothes and heat sources.
- Use a TP4056 board with protection (the version with the DW01 chip and two outputs, OUT+ and OUT−), or a proper BMS for packs.
- Buy cells from a known brand and seller. Fake cells often hold a fraction of the label and can lack protection.
- Do not leave lithium cells charging unattended, and charge them on a non-flammable surface.
- Never use a swollen, dented or leaking cell. Recycle it.
- Put a fuse close to the battery's + terminal.
- While soldering or spot-welding, keep the cell ends covered so nothing can short them.
- Low-voltage DC only. Never connect any part of these builds to mains power.
Questions people ask
Why an AM312 on battery and an HC-SR501 on USB?
The HC-SR501 needs at least 4.5 V, more than a lithium cell gives. The AM312 runs from 2.7 V and sleeps at about 15 µA, but its on-time is short (about 2 seconds after the last movement). On USB the HC-SR501's dials give 5 seconds to 5 minutes.
Why switch the boost board and not just the LEDs?
A boost board uses some current even with nothing connected. Switching it off between uses keeps the battery for the light.
Can it come on only at night?
Yes: the HC-SR501 has a spot for a light sensor (LDR); on the battery version, add an LDR module that blocks the signal in daylight.
Written and checked by Moataz FOUAD, telecom and electronics engineer. About this site.