This project is an environmental monitoring system built using the ESP32 microcontroller. It monitors temperature and humidity using a DHT sensor, controls a relay, and sends data to an MQTT broker. The system ensures continuous internet connectivity and handles MQTT messaging.
- Wi-Fi connectivity
- DHT sensor integration for temperature and humidity monitoring
- Relay control
- MQTT client for data publishing
- Uptime tracking
- Logging system for status and error messages
-
Clone the repository:
git clone https://github.com/unrealbg/ESP32-Env-Monitor-PO.git cd ESP32-Env-Monitor-PO -
Install dependencies:
- Ensure you have the Arduino IDE installed.
- Install the necessary libraries:
- WiFi
- PubSubClient
- DHT sensor library
-
Configure the project:
- Update the
config.hfile with your Wi-Fi credentials and MQTT broker details.
- Update the
-
Upload the code:
- Connect your ESP32 to your computer.
- Open the project in Arduino IDE.
- Select the correct board and port.
- Upload the code to the ESP32.
-
Monitor the system:
- Open the Serial Monitor in Arduino IDE to view logs.
- The ESP32 will connect to Wi-Fi, start the MQTT client, and begin monitoring temperature and humidity.
-
MQTT Messaging:
- The system will publish temperature and humidity data to the configured MQTT topic.
- It will also handle incoming MQTT messages and log them.
src/main.cpp: Main application code handling setup and loop functions.RelayService.h/.cpp: Handles relay control.DhtService.h/.cpp: Manages the DHT sensor.InternetConnectionService.h/.cpp: Ensures continuous internet connectivity.MqttClientService.h/.cpp: Manages MQTT client operations.UptimeService.h/.cpp: Tracks and logs system uptime.LogHelper.h/.cpp: Provides logging functionality.
Contributions are welcome! Please fork the repository and submit pull requests.
This project is licensed under the MIT License.