On this page

Hardware

The device is an ESP32 LOLIN32 with four sensors and a display. This page lists what is in the bill of materials and how it is wired. Each peripheral has its own chapter further down.

Bill of materials

PartInterfaceChapter
ESP32 LOLIN32 board:ESP32 & pin configuration
MQ-2 gas sensor moduleAnalog out → GPIO 32MQ-2 sensing
DHT22 temperature and humidity sensor1-Wire → GPIO 13DHT22 climate monitoring
PIR motion sensorDigital out → GPIO 34PIR sensing and wakeup
16x2 I2C LCD with PCF8574 backpackI2C → GPIO 17 / 19LCD interface
3.7 V LiPo battery with charging circuitPower → VINLow-power architecture

Pin map

Every pin is defined as a macro in include/config.h.

MacroPinSignal
PIN_GAS_SENSORGPIO 32MQ-2 analog output (ADC1_CH4)
PIN_TEMP_HUM_SENSORGPIO 13DHT22 data line
PIN_MOTION_SENSORGPIO 34PIR output, also the deep-sleep wake source
LCD SDAGPIO 17I2C data
LCD SCLGPIO 19I2C clock
Status LEDGPIO 22digital output

GPIO 34 is input-only and has no internal pull-up, which is why the PIR is powered from the board’s 5 V rail and its output is read directly.

Wiring

3.3V  ──> MQ-2 VCC, DHT22 VCC, LCD VCC
GND   ──> common ground for every module
VIN   ──> battery positive (through a regulator if the cell needs one)
5V    ──> PIR VCC, soldered on the board

MQ-2 A0  ──> GPIO 32
DHT22    ──> GPIO 13
PIR OUT  ──> GPIO 34
LCD SDA  ──> GPIO 17
LCD SCL  ──> GPIO 19

Power

The device is battery operated. It spends nearly all of its time in deep sleep, wakes on motion, reads the sensors, updates the display and sleeps again. The LCD backlight is switched off while the device sleeps. See Low-power architecture for the wake timing and the 20 second idle window.