This Wi-Fi door sensor uses an ESP32 microcontroller to detect door open/closed states via a reed switch and broadcast the status over a local wireless network. The device connects to power through USB-C, regulates voltage with an AMS1117, and provides real-time door state monitoring accessible through a simple web interface.
The guide includes a complete wiring diagram, full parts list, pre-written firmware ready to flash, and step-by-step assembly instructions covering power input, ESP32 module installation, control button and LED connections, reed switch integration, and UART programming header setup.
Wiring diagram

Gather all the parts
Assemble it in 5 steps
1. Assemble the power input
Fit J1 and its separate R1/R2 CC pull-downs. Connect all VBUS contacts to +5V, all ground contacts and shell tabs to GND. Leave data/SBU pins unconnected. Fit U1, C1, C2, C3 and C4. U1 SOT-223 pin 1 is GND, pin 2 and tab are 3V3, pin 3 is +5V.
- C3 is polarized: positive to 3V3. U1 tab is NOT ground. Use a dedicated 5 V USB supply rated at least 1 A; CC resistors do not negotiate USB PD or detect available current.
2. Fit the ESP32 module and bypass capacitors
Fit U2 ESP32-WROOM-32E-N4 to a PCB footprint. Pin 2 goes to 3V3. Ground pins 1, 15, 38 and exposed pad 39. Place C5 and C6 at pin 2. Leave NC pins 17–22 and 32 unconnected, and leave unused GPIOs unconnected. Keep all copper, traces and components out of the antenna keepout on every layer.
- The module already contains its crystal, flash and RF matching. Give U1 a large 3V3 copper heat-spreading area; dissipation reaches about 0.85 W at 500 mA. Check its temperature under Wi-Fi load.
3. Fit reset and boot controls
R3 pulls EN (U2 pin 3) to 3V3; C7 delays EN at startup. SW1 grounds EN when pressed. R4 pulls GPIO0 (pin 25) to 3V3; SW2 grounds it for programming. Leave GPIO2 and GPIO12 unconnected so their internal boot pull-downs are not overridden.
4. Connect the door contact and LEDs
J2 pin 1 connects through R6 to GPIO4 (U2 pin 26). R5 pulls GPIO4 high; C8 filters it to ground. J2 pin 2 is ground. Connect the reed contact between the two terminals. D1 is powered through R7 from 3V3. GPIO25 (pin 10) drives D2 through R8. Both LED cathodes go to ground.
- Use short indoor reed-switch wiring. This input has no surge protection for long outdoor cables.
5. Check power and connect programming header
Before fitting power, check for shorts. Measure 3V3 before programming. J3 pins are 1=3V3 reference, 2=ESP TX GPIO1 (U2 pin 35), 3=ESP RX GPIO3 (pin 34), 4=GND. Adapter RX goes to J3 pin 2 and adapter TX to pin 3. Use only 3.3 V UART logic.
- Hold BOOT, press and release RESET, then release BOOT to enter download mode. Reset again after programming. The four-pin header has no automatic reset signals.
- When USB powers the board, leave the adapter power lead disconnected. J3 3V3 is a reference/output, not a second supply input. Never connect 5 V TTL or RS-232 signals.
Review all connections
1. Connections between "R1" and "ESP32"
2. Connections between "R2" and "ESP32"
3. Connections between "R3" and "ESP32"
4. Connections between "R4" and "ESP32"
5. Connections between "R5" and "ESP32"
6. Connections between "R6" and "ESP32"
7. Connections between "R7" and "ESP32"
8. Connections between "R8" and "ESP32"
9. Connections between "C1" and "ESP32"
10. Connections between "C2" and "ESP32"
11. Connections between "C4" and "ESP32"
12. Connections between "C5" and "ESP32"
13. Connections between "C6" and "ESP32"
14. Connections between "C7" and "ESP32"
15. Connections between "C8" and "ESP32"
16. Connections between "C3" and "ESP32"
17. Connections between "J1" and "ESP32"
18. Connections between "U1" and "ESP32"
19. Connections between "SW1" and "ESP32"
20. Connections between "SW2" and "ESP32"
21. Connections between "J2" and "ESP32"
22. Connections between "REED1" and "ESP32"
23. Connections between "D1" and "ESP32"
24. Connections between "D2" and "ESP32"
25. Connections between "J3" and "ESP32"
Deploy the firmware
#include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>
WebServer server(80);
constexpr int REED_PIN=4, STATUS_LED_PIN=25;
bool stableOpen=true, lastRaw=true;
uint32_t changedAt=0;
void setup(){
pinMode(REED_PIN,INPUT); pinMode(STATUS_LED_PIN,OUTPUT);
Serial.begin(115200);
stableOpen=lastRaw=digitalRead(REED_PIN); digitalWrite(STATUS_LED_PIN,stableOpen);
WiFi.mode(WIFI_AP);
WiFi.softAP("DoorSensor", "DoorSensor32!");
server.on("/", [](){server.send(200,"text/plain",stableOpen?"Door OPEN\n":"Door CLOSED\n");});
server.begin();
Serial.println("Connect to DoorSensor; password DoorSensor32!; visit http://192.168.4.1/");
}
void loop(){
server.handleClient();
bool raw=digitalRead(REED_PIN);
if(raw!=lastRaw){lastRaw=raw;changedAt=millis();}
if(raw!=stableOpen && millis()-changedAt>=40){stableOpen=raw;digitalWrite(STATUS_LED_PIN,stableOpen);Serial.println(stableOpen?"OPEN":"CLOSED");}
}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.




