This is an old revision of the document!


Environmental Comfort Monitoring System with ESP32

Autor: Burciu Iustin Florian Email: iustin.burciu@stud.fiir.upb.ro Grupa: AAC

Introduction

This project focuses on building an embedded system to monitor environmental comfort using the ESP32 development board, along with an LM35 temperature sensor and an MQ-4 gas sensor. It continuously evaluates environmental conditions and computes a comfort score based on temperature and gas readings.

The implementation was initially created as a local web server hosted directly on the ESP32, allowing real-time monitoring from any browser within the same Wi-Fi network. Later, a second version was developed using Firebase Realtime Database, enabling remote data access and logging in real time from anywhere in the world.

The project includes:

  • Real-time data acquisition from temperature and gas sensors
  • Live display of sensor values and computed comfort score
  • Visual charts and indicator LEDs (both virtual and physical)
  • Automatic alerts and a persistent log for critical events
  • Optional Firebase integration for remote access

Hardware

Used Components:

  • ESP32 DevKit V1 – WiFi + Bluetooth enabled development board
  • LM35 – analog temperature sensor
  • MQ-4 – analog gas sensor
  • 2x LEDs (red and blue) – for visual alerts
  • Jumper wires, breadboard

ESP32 Connections:

Component ESP32 Pin Description
LM35 VCC 3.3V Power supply
LM35 GND GND Ground
LM35 OUT GPIO34 Temperature signal
MQ-4 VCC VIN Power supply (regulated)
MQ-4 GND GND Ground
MQ-4 A0 GPIO32 Gas level (analog)
LED Blue GPIO25 Lights up at comfort score 100
LED Red GPIO26 Lights up if gas > 30

System Diagram

Functionality

The designed system aims to monitor indoor environmental comfort by evaluating two essential parameters: temperature and gas concentration. These values are processed to calculate a comfort score ranging from 0 to 100, which reflects the overall air quality and thermal comfort.

The core functionalities of the system include:

  • Reading analog values from the LM35 temperature sensor (in °C) and the MQ-4 gas sensor (in ppm).
  • Computing the comfort score based on pre-defined thresholds for temperature and gas, penalizing deviations from optimal ranges.
  • Real-time display of measurements through a web-based dashboard, hosted locally on the ESP32 microcontroller.
  • Automatic dashboard refresh every 2 seconds, showing:
    • Current temperature
    • Gas level (methane/LPG)
    • Comfort score out of 100
    • Two animated line charts visualizing historical values
  • Visual indicators (LEDs):
    • Red LED – lights up when gas level exceeds 30 ppm
    • Blue LED – lights up when the comfort score reaches 100
  • Virtual LEDs on the web interface, mimicking the behavior of physical ones
  • Persistent event log displaying timestamps, temperature, gas level, and comfort score whenever a threshold is crossed
  • *(Optional)* Cloud integration with Firebase Realtime Database, using a separate sketch, allowing data to be viewed remotely

This system provides continuous assessment of the indoor environment, with a user-friendly interface that enables real-time monitoring and alerts, both locally and remotely via cloud services.

Optional: Firebase Support

In a separate sketch, the system can also:

  • Push live data to Firebase Realtime Database
  • Use credentials and Web API key
  • Display values remotely via a mobile app or web

Code Snippets

1. Read Temperature and Gas:

```c float citesteTemperatura() {

int adc = analogRead(pinLM35);
float voltaj = adc * (5.0 / 4095.0);
return voltaj * 100.0;

}

int citesteGaz() {

return analogRead(pinMQ4);

}

iothings/proiecte/2025sric/esp32environmentalcomfortmonitoringsystemweb.1748482662.txt.gz · Last modified: 2025/05/29 04:37 by iustin.burciu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0