ESP32 DevKit (30-pin) seen from above: antenna at the top, USB at the bottom. Every sensor's VCC, GND and signal wire is shown.
← Swipe to see the whole diagram →
Flame sensor
Sensor pin
ESP32
VCC
3V3
GND
GND
D0 (digital out)
G15
A0
not used
Use D0, not A0. The module's D0 LED lights when it sees a flame. Turn its blue screw to set the distance.
MQ-2 gas / smoke
Sensor pin
ESP32
VCC
VIN (5 V)
GND
GND
AO (analog out)
divider → G34
DO
not used
MQ-2 AO ── 10 kΩ ──┬── G34
│
20 kΩ
│
GND
AO can reach 5 V; G34 accepts 3.3 V at most. The divider brings it down safely. Clean air reads about 260; the alarm triggers at 800. Allow 2 minutes of warm-up.
IR sensors (people counter)
Sensor pin
IR A (outside)
IR B (inside)
VCC
3V3
3V3
GND
GND
GND
OUT
G18
G19
OUTSIDE │ door │ INSIDE
[IR A] │ ─────► │ [IR B]
A then B (within 1.5 s) = entry
B then A (within 1.5 s) = exit
Mount them 10–15 cm apart at waist height, pointing across the doorway. Adjust each blue screw so the LED lights only when someone passes.
DHT22 temperature & humidity
Sensor pin
ESP32
+ / VCC
3V3
OUT / DATA / S
G4
− / GND
GND
Wire by the labels printed on the module, since pin order differs between brands. A bare 4-pin DHT22 also needs a 10 kΩ resistor from DATA to 3V3.
Buzzer
Buzzer pin
ESP32
+ (long leg)
G25
−
GND
Use an active buzzer (it beeps by itself on 3–5 V). For a louder buzzer, drive it through an NPN transistor (2N2222 / S8050) with a 1 kΩ base resistor.
Never use G0, G2 or G12 for the buzzer: they control how the ESP32 boots.
Power & ground
Rail
Feeds
VIN 5 V (from USB)
MQ-2 heater
3V3
DHT22, flame, IR A, IR B
GND
Every sensor and the buzzer
All grounds must be connected together. Use a short, good-quality USB data cable; the MQ-2 heater draws about 150 mA, and a weak cable causes USB dropouts.
The fan runs separately from its own 12 V adapter.