This project is an Internet of Things (IoT) application that uses an ESP32 microcontroller to monitor various environmental parameters. It collects data from a DHT21 sensor (temperature and humidity), a Pulse sensor, and an MQ135 gas sensor (CO2 levels). The data is displayed on a web page hosted on the ESP32, where users can also toggle a connected lamp and download recorded data.
- WiFi Connectivity: Connects to a specified WiFi network.
- Multiple Sensors: Reads data from DHT21, Pulse sensor, and MQ135 sensor.
- Web Server: Hosts a web page to display sensor data and control a lamp.
- SPIFFS: Stores data locally on the ESP32 filesystem.
- JSON: Uses JSON for data interchange between the ESP32 and the web interface.
- ESP32 microcontroller
- DHT21 temperature and humidity sensor
- Pulse sensor
- MQ135 gas sensor
- LED lamp (optional)
- Resistors, breadboard, and jumper wires
- Arduino IDE with ESP32 support
- ArduinoJson library
- DHT sensor library
- WiFi library
- WebServer library
- SPIFFS library
- HTTPClient library
Connect the sensors to the ESP32 as follows:
- VCC to 3.3V
- GND to GND
- DATA to GPIO4
- Purple wire to GPIO36
- Analog output to GPIO34
- Control pin to GPIO2 (with appropriate resistor)
- Library Inclusions: Includes necessary libraries for WiFi, web server, DHT sensor, SPIFFS, and JSON.
- WiFi Configuration: Sets up WiFi credentials for network connection.
- Sensor Initialization: Initializes the DHT21, Pulse sensor, and MQ135 sensor.
- Web Server Routes: Defines routes for the main page, toggling the lamp, reading sensor data, and downloading data.
- Main Page: Serves an HTML page that displays sensor data and provides buttons for toggling the lamp and downloading data.
- Data Handling: Reads sensor data, stores it in SPIFFS, and sends it to a remote server.
- Install Arduino IDE: Make sure you have the Arduino IDE installed on your computer.
- Install ESP32 Board in Arduino IDE:
- Go to
File>Preferences. - Add
https://dl.espressif.com/dl/package_esp32_index.jsonto theAdditional Board Manager URLs. - Open the
Boards ManagerfromTools>Boardand install theesp32package.
- Go to
- Install Required Libraries:
- Go to
Sketch>Include Library>Manage Libraries. - Install the following libraries:
ArduinoJson,DHT sensor library,WiFi,WebServer,SPIFFS,HTTPClient.
- Go to
- Connect ESP32 to Your Computer: Use a USB cable to connect the ESP32 to your computer.
- Upload the Code: Open the provided code in Arduino IDE and upload it to the ESP32.
- Power the ESP32: After uploading the code, power the ESP32 using the USB connection or an external power source.
- Connect to WiFi: The ESP32 will attempt to connect to the specified WiFi network.
- Access the Web Interface:
- Open a web browser on a device connected to the same WiFi network.
- Enter the IP address of the ESP32 displayed in the Serial Monitor.
- Monitor Data: View temperature, humidity, CO2 levels, and heart rate data, toggle the lamp, and download recorded data from the web interface.
Feel free to fork this repository and contribute by submitting pull requests. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this project helpful, consider making a donation: