Community project

Wi-Fi Motion Detector

ESP32
Photo of Wi-Fi Motion Detector
Generated with AI

Lazar Doric

Published October 3, 2026

This Wi-Fi motion detector uses an ESP32 to detect movement via a PIR sensor and report it over wireless connectivity. The project combines a modified HC-SR501 motion sensor with battery-powered ESP32 operation, featuring a custom reset circuit that wakes the microcontroller only when motion is detected, minimizing power consumption for extended deployment.

The guide provides a complete wiring diagram, full parts list with sources, and step-by-step assembly instructions for building the detector on breadboard. Readers will learn how to integrate the TP4056 charging module for Li-Ion battery management, configure the HT7833A regulator for stable 3.3V operation, and implement the reset-pulse circuit that bridges the PIR sensor to the ESP32's reset pin. Firmware code is included to establish the wake-on-motion behavior and prepare for Wi-Fi connectivity.

Wiring diagram

Wiring diagram for Wi-Fi Motion Detector

Gather all the parts

QtyComponent
1

Modified HC-SR501 PIR motion sensor

The motion sensor module, modified so its electronics and OUT signal use the 3.3 V supply.

1

TP4056 Li-Ion/LiPo charger module with protection

TP4056 single-cell Li-Ion/LiPo linear charger module, 5V USB input, 1A charge current (programmable). Common variants ship with DW01 protection. Pair with battery_lipo_storage for the cell.

1

Lithium Ion Battery - 3.7V 2000mAh

3.7V 2000mAh lithium-ion polymer battery with JST-PH connector and protection circuitry. Output ranges from 4.2 V fully charged to 3.0 V cutoff.

1

Breadboard-friendly SPDT Slide Switch

Compact through-hole SPDT slide switch with three pins for direct breadboard insertion.

1

HT7833A-1 3.3 V 500 mA LDO regulator

The TO-92 low-dropout regulator that makes a steady 3.3 V supply from the protected battery output.

1

2N3904 NPN Transistor

General-purpose NPN bipolar junction transistor (BJT) in a TO-92 package. Rated for 60V collector-emitter voltage and 200mA continuous collector current with an hFE (gain) of 100–300. Commonly used as a low-side switch or signal amplifier driven by a microcontroller digital output pin via a current-limiting base resistor.

1

10 kΩ reset-pulse series resistor

10 kΩ

Limits current into the reset-pulse capacitor and transistor base.

1

100 kΩ transistor base pull-down resistor

100 kΩ

Turns the reset transistor back off after the short motion-trigger pulse.

1

10 kΩ ESP-01 reset pull-up resistor

10 kΩ

Normally holds the ESP-01 reset pin high so it can run.

1

10 µF reset-pulse electrolytic capacitor

10 µF, 6.3 V or higher

Turns the PIR's rising output edge into one short ESP-01 reset pulse.

1

10 µF regulator input capacitor

10 µF, 6.3 V or higher

Keeps the regulator input steady when the ESP-01 starts.

1

10 µF regulator output capacitor

10 µF, 6.3 V or higher

Keeps the HT7833A-1 output stable.

1

470 µF ESP-01 supply capacitor

470 µF, 6.3 V or higher

Supplies short Wi-Fi current bursts so the ESP-01 is less likely to reset.

1

0.1 µF ESP-01 ceramic bypass capacitor

0.1 µF ceramic

Filters very fast electrical noise at the ESP-01 supply pins.

1

10 kΩ ESP-01 GPIO0 boot pull-up resistor

10 kΩ

Keeps GPIO0 high during normal use so the ESP-01 starts its saved firmware instead of programming mode.

1

10 kΩ ESP-01 GPIO2 boot pull-up resistor

10 kΩ

Keeps GPIO2 high while the ESP-01 starts normally.

1

1N4148 Signal Diode

Fast small-signal switching diode in DO-35 glass package. Forward voltage ~0.6–0.7 V at low current, reverse breakdown 75 V, max forward current 300 mA, reverse recovery time 4 ns. Used here in an anti-parallel pair across the TL072 op-amp feedback loop (D1: anode→OPAMP_OUT, cathode→OPAMP_IN_NEG; D2: anode→OPAMP_IN_NEG, cathode→OPAMP_OUT) to provide soft audio clipping.

Assemble it in 6 steps

1. Place the power parts

Put charger_1, power_switch_1, regulator_1, and the ESP-01 on the raster board. Your TP4056 is the protected six-pad version: it has IN+/IN− for 5 V charging, B+/B− for the cell, and OUT+/OUT− for the protected load. Connect charger_1 OUT+ to power_switch_1 COM (battery power), then connect switch A to regulator_1 VIN (switched battery power). Connect charger_1 OUT−, regulator_1 GND, and ESP-01 GND together (ground).

  • Leave the TP4056 USB socket accessible for charging.
  • Check the HT7833A-1 lead order from its marking or datasheet before soldering; TO-92 regulators do not all share the same order.
  • Do not use B+ as the circuit supply: use OUT+ and OUT− so the TP4056 protection circuit remains between the cell and the load.
  • Do not connect the Li-ion cell directly to ESP-01 VCC; a full cell is about 4.2 V and can damage the ESP-01.

2. Add the regulator capacitors

Connect regulator_input_cap_1 + to regulator_1 VIN (input smoothing) and its − lead to ground. Connect regulator_output_cap_1 + to regulator_1 VOUT (the 3.3 V rail) and its − lead to ground. Keep both capacitors close to the regulator.

  • The striped side of an electrolytic capacitor is its − lead.
  • Reversing an electrolytic capacitor can make it heat up or fail.

3. Wire the real ESP-01 header

Use the ESP-01’s actual eight header pins: VCC, RST, GND, GPIO0, TX/GPIO1, GPIO2, RX/GPIO3, and CH_PD. Connect VCC to the regulator 3.3 V rail (power), GND to ground (ground), and CH_PD directly to 3.3 V (enables the ESP). Connect reset_pullup_1 from 3.3 V to RST (keeps it out of reset). Connect gpio0_pullup_1 from 3.3 V to GPIO0 and gpio2_pullup_1 from 3.3 V to GPIO2 (normal boot settings). TX/GPIO1 and RX/GPIO3 are left available for programming. Fit esp_bulk_cap_1 and esp_bypass_cap_1 directly between VCC and GND beside the ESP-01: electrolytic + to VCC and − to GND; the ceramic part has no polarity.

  • Keep the 470 µF capacitor and 0.1 µF ceramic capacitor physically close to ESP-01 VCC and GND.
  • For ordinary running, GPIO0 and GPIO2 must not be connected to ground.
  • Do not put 5 V on VCC, RST, CH_PD, GPIO0, GPIO1, GPIO2, or GPIO3. Every ESP-01 pin is a 3.3 V pin.

4. Wire the PIR sensor

Connect pir_1 VCC to the 3.3 V rail (power) and pir_1 GND to ground (ground). Connect pir_1 OUT to reset_series_resistor_1 A (motion signal), then connect reset_series_resistor_1 B to reset_pulse_cap_1 + (starts the short reset pulse).

  • Set the HC-SR501 delay control to its shortest setting so it can report another movement sooner.
  • This assumes your HC-SR501 has been modified and tested for a 3.3 V supply.
  • Do not swap the PIR VCC and GND pins; swapped power can damage the sensor.

5. Make the reset pulse

Join reset_pulse_cap_1 −, reset_transistor_1 Base, base_pulldown_1 A, and the unmarked end of base_clamp_diode_1 into one point (reset-pulse control). Connect base_pulldown_1 B to ground (turns the transistor off after the short pulse). Connect the marked end of base_clamp_diode_1 to ground. Connect the 2N3904 Emitter to ground. Connect the 2N3904 Collector to the ESP-01 RST pin, at the same point as reset_pullup_1 B (reset signal). A new PIR detection briefly grounds RST, making the ESP-01 restart.

  • The diode’s band marks its cathode; in this circuit the banded end goes to ground.
  • Check the 2N3904’s pin order from the flat side before soldering.
  • If the transistor collector and emitter are swapped, the ESP-01 may fail to reset or stay held in reset.

6. Connect and charge the battery

Connect battery_1 BAT+ to charger_1 B+ (battery positive) and battery_1 BAT− to charger_1 B− (battery negative). Charge only through the TP4056 USB input: USB 5 V reaches IN+ and USB ground reaches IN−. Before inserting the ESP-01, switch on and measure between the 3.3 V rail and ground; it should be close to 3.3 V.

  • The PIR needs a short warm-up after power is first switched on.
  • A reversed Li-ion cell can damage the charger and become dangerously hot. If any part gets hot, disconnect the battery immediately.

Review all connections

1. Connections between "battery_1" and "ESP32"

Functionbattery_1ESP32
powerBAT+ → TP4056 Li-Ion/LiPo charger module with protection B+EXT
groundBAT- → TP4056 Li-Ion/LiPo charger module with protection B-EXT

2. Connections between "charger_1" and "ESP32"

Functioncharger_1ESP32
powerOUT+ → Breadboard-friendly SPDT Slide Switch COMEXT
groundOUT-GND
powerIN+5V
groundIN-GND

3. Connections between "power_switch_1" and "ESP32"

Functionpower_switch_1ESP32
digitalA → HT7833A-1 3.3 V 500 mA LDO regulator VINEXT

4. Connections between "regulator_1" and "ESP32"

Functionregulator_1ESP32
groundGNDGND
powerVOUT3V3

5. Connections between "regulator_input_cap_1" and "ESP32"

Functionregulator_input_cap_1ESP32
power+ → HT7833A-1 3.3 V 500 mA LDO regulator VINEXT
ground-GND

6. Connections between "regulator_output_cap_1" and "ESP32"

Functionregulator_output_cap_1ESP32
power+3V3
ground-GND

7. Connections between "esp_bulk_cap_1" and "ESP32"

Functionesp_bulk_cap_1ESP32
power+3V3
ground-GND

8. Connections between "esp_bypass_cap_1" and "ESP32"

Functionesp_bypass_cap_1ESP32
powerA3V3
groundBGND

9. Connections between "pir_1" and "ESP32"

Functionpir_1ESP32
powerVCC3V3
groundGNDGND
digitalOUT → 10 kΩ reset-pulse series resistor AEXT

10. Connections between "reset_series_resistor_1" and "ESP32"

Functionreset_series_resistor_1ESP32
dataB → 10 µF reset-pulse electrolytic capacitor +EXT

11. Connections between "reset_pulse_cap_1" and "ESP32"

Functionreset_pulse_cap_1ESP32
data- → 2N3904 NPN Transistor Base (B)EXT

12. Connections between "base_pulldown_1" and "ESP32"

Functionbase_pulldown_1ESP32
dataA → 2N3904 NPN Transistor Base (B)EXT
groundBGND

13. Connections between "base_clamp_diode_1" and "ESP32"

Functionbase_clamp_diode_1ESP32
groundANODEGND
dataCATHODE → 2N3904 NPN Transistor Base (B)EXT

14. Connections between "reset_transistor_1" and "ESP32"

Functionreset_transistor_1ESP32
groundEmitter (E)GND

15. Connections between "reset_pullup_1" and "ESP32"

Functionreset_pullup_1ESP32
powerA3V3
dataB → 2N3904 NPN Transistor Collector (C)EXT

16. Connections between "gpio0_pullup_1" and "ESP32"

Functiongpio0_pullup_1ESP32
powerA3V3
dataBGPIO 0

17. Connections between "gpio2_pullup_1" and "ESP32"

Functiongpio2_pullup_1ESP32
powerA3V3
dataBGPIO 2

Deploy the firmware

#include <Arduino.h>

void setup() {
  // A PIR rising edge pulls RST low briefly and boots the ESP-01.
  // Future Wi-Fi reporting belongs here, before the sleep call.
  delay(25);
  ESP.deepSleep(0);
}

void loop() {
  // The ESP8266 does not reach this while deep sleep is active.
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace — diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik