WattNWave
DIY projects › Lights and LEDs

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.

9V
Easy to mediumSoldering1 hour
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

Charging boardTP4056B+B−OUT+OUT−+−186501PIR sensorAM312VCCOUTGND2MOSFET boardD41843Boost boardMT3608 → 5 VIN+IN−load −5.004USB LED strip56+ positive− negativeteal = sensor signal
Swipe sideways to see the whole drawing. The numbers on the drawing match the steps below.

You will need

  • AM312 mini PIR sensorRuns straight from a lithium cell (2.7–12 V) and uses very little power
    View 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 strip
    View on Amazon
  • 18650 lithium cells and a holder3.7 V cells. Buy cells from a battery shop; the holder snaps them in without soldering
    View on Amazon
  • USB-C charging board (TP4056, with protection)Charges the lithium battery from a phone charger and protects it from running too low
    View on Amazon
  • USB LED strip (5 V)Warm white suits a night light
    View on Amazon
  • MultimeterTo check voltages before you connect anything
    View on Amazon

Tools

Soldering iron, multimeter.

Step by step

  1. 1

    Wire the cell holder to the charging board's B+ and B−.

  2. 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. 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. 4

    Set the boost board to 5.0 V: wave at the sensor to switch it on and adjust while measuring.

  5. 5

    Connect the LED strip to the boost board's OUT+ and OUT−.

  6. 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.

DoneFromToWire
Cell holder +Charging board B+Red
Cell holder −Charging board B−Black
Charging board OUT+Sensor VCCRed
Charging board OUT−Sensor GNDBlack
Sensor OUTMOSFET 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 GNDCharging 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

old USB cable1PIR sensorHC-SR5012MOSFET boardD41843USB LED strip4time & range dials+ positive− negative
Swipe sideways to see the whole drawing. The numbers on the drawing match the steps below.

You will need

Tools

Soldering iron, multimeter.

Step by step

  1. 1

    Cut the USB cable: red is +5 V, black is ground.

  2. 2

    Power the sensor from red (VCC) and black (GND). Its OUT pin goes to the MOSFET board's signal input.

  3. 3

    Wire the LED strip's + to red, and its − through the MOSFET board (load −) to black.

  4. 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.

DoneFromToWire
USB cable red wireSensor VCCRed
USB cable black wireSensor GNDBlack
Sensor OUTMOSFET board signal inputThin wire, any colour
USB cable red wireLED strip +Red
LED strip −MOSFET board load −Black
MOSFET board GNDUSB cable black wireBlack

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.

A 1 m USB strip is about 1–3 W; check the label.
Our suggestion
—

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

Stop at once if a cell or board smells, gets hot to the touch, swells, hisses or smokes. Unplug it, move it onto a non-flammable surface outdoors if you safely can, and keep away until it is cold.
  • 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.