Redson Dev · Idea
Low-Cost Environmental Monitor for Indoor Spaces
Published May 26, 2026
This project enables anyone to build a practical environmental monitoring system for indoor spaces, providing real-time data on air quality and environmental conditions. It's useful for ensuring comfortable and healthy environments in places like a small office, a school classroom, or a hobby workshop. The output can help optimize ventilation or heating, potentially saving energy and improving well-being in an example application like a community center.
What you'll need
- ESP32 development board x1
- DHT11 temperature/humidity sensor x1
- MQ-2 gas sensor (smoke/LPG/CH4) x1
- Breadboard x1
- Jumper wires (male-to-male) x10
- Micro-USB cable x1
- 5V power supply (e.g., phone charger) x1
Step-by-step
- 01
Assemble Hardware Components
Connect the DHT11 sensor: VCC to 3.3V on ESP32, GND to GND, and Data pin to ESP32 pin D2. For the MQ-2 sensor: VCC to 5V, GND to GND, and Analog Out (A0) to ESP32 pin A0 (GPIO36). Place components on the breadboard for stability and easy wiring.
- 02
Install Development Environment and Libraries
Install the Arduino IDE. Open 'Tools' -> 'Board' -> 'Boards Manager...' and search for 'ESP32' to install the ESP32 board definitions. Then, go to 'Sketch' -> 'Include Library' -> 'Manage Libraries...' and install 'DHT sensor library' by Adafruit and 'MQ2Unified'.
- 03
Upload Initial Firmware
Connect the ESP32 to your computer via micro-USB. Select the correct board ('ESP32 Dev Module') and port in the Arduino IDE 'Tools' menu. Upload a basic sketch that reads data from both sensors and prints it to the Serial Monitor (e.g., using `DHT.readTemperature()` and `MQ2.readRs()`). Verify readings are sensible.
- 04
Implement Data Transmission
Modify the sketch to connect to a local Wi-Fi network using `WiFi.begin("YOUR_SSID", "YOUR_PASSWORD")`. Then, implement a simple HTTP POST request using `HTTPClient` to send the sensor data to a local server or a simple data logging service every few seconds. Ensure your local server is running and configured to receive data.
- 05
Set Up Data Visualization (Optional)
On a computer on the same network, set up a simple web server (e.g., using Python Flask or Node.js Express) to receive the data. Create a basic HTML page with JavaScript to display the incoming temperature, humidity, and air quality readings dynamically. This provides a user-friendly interface for the environmental data.
Tips
- For MQ-2 calibration, expose the sensor to fresh air for 24-48 hours before taking readings for better accuracy.
- Consider adding a small OLED display directly to the ESP32 for on-device real-time readings without a separate server.
