- Overview
- Features
- Hardware Requirements
- Software Requirements
- Installation
- Configuration
- Usage
- Project Structure
- Troubleshooting
- Contributing
- License
- Acknowledgments
The ESP32-C3 Home Weather Alert System uses an ESP32-C3 microcontroller to monitor temperature and humidity via a DHT sensor. When significant changes in these parameters are detected beyond predefined thresholds, the system automatically sends out email alerts to designated recipients. The project also features a web-based GUI for real-time data monitoring and configuration, including threshold adjustments, NTP synchronization, and debug logs.
Web Demo: ESP32-C3 Home Weather Alert System - 14.4.202.60:80
- Real-Time Sensor Monitoring: Continuously reads temperature and humidity data using a DHT sensor (DHT11 or DHT22).
- Email Alerts: Automates email notifications when significant changes in temperature or humidity occur.
- Web-Based GUI: Offers a user-friendly interface to view sensor data and manage system settings.
- NTP Time Sync: Ensures accurate timestamps by synchronizing with an NTP server.
- Network Resilience: Reconnects to Wi-Fi automatically if the connection is lost.
- Configurable Thresholds: Allows you to set high/low temperature and humidity thresholds.
- Debug Logging: Provides detailed logs for troubleshooting.
- ESP32-C3 Development Board (e.g., ESP32-C3-DevKitM-1)
- DHT Sensor (DHT11 or DHT22)
- OLED or LCD Display (Optional, but recommended for local data visualization)
- Jumper Wires
- Breadboard (Optional, for prototyping)
- USB Cable / Power Adapter for ESP32
Below is a breadboard wiring diagram showing how to connect a DHT22 sensor and an OLED display to the ESP32-C3:
-
DHT22 Connections:
- Pin 1 (VCC) → 3.3V on ESP32
- Pin 2 (Data) → GPIO10 on ESP32
- Pin 3 (NC) → Not Connected
- Pin 4 (GND) → GND on ESP32
-
OLED Connections:
- VCC → 3.3V on ESP32
- GND → GND on ESP32
- SDA → GPIO8 (SDA default for ESP32-C3)
- SCK → GPIO9 (SCL default for ESP32-C3)
From the above image, you can see there is a pinout diagram for the ESP32-C3 DevKit, showing default I2C pins (GPIO8 for SDA, GPIO9 for SCL) and available GPIO pins:
Depending on your DHT sensor model, use the corresponding pinout diagram:
- DHT11 or DHT22 typically have:
- VCC (3.3V)
- Data
- NC (Not Connected)
- GNDGitHub repository.
- PlatformIO: Cross-platform build system, integrated into VSCode.
- Arduino Framework: Underlying development environment for the ESP32.
- Adafruit DHT Sensor Library: For interfacing with the DHT sensor.
- ESP Mail Client Library: For sending email alerts.
- LiquidCrystal_I2C or Adafruit_SSD1306 (optional) for display usage.
If you haven't installed PlatformIO yet, follow these steps:
-
Install Visual Studio Code (VSCode):
- Download and install from VSCode Download.
-
Install PlatformIO Extension:
- Open VSCode.
- Navigate to the Extensions panel (
Ctrl+Shift+XorCmd+Shift+Xon macOS). - Search for
PlatformIO IDEand install the official extension.
-
Verify Installation:
- Click on the PlatformIO icon in the sidebar to open PlatformIO Home.
- Ensure PlatformIO Core is up-to-date.
git clone https://github.com/jakhon37/esp32-c3-home-weather-alert.git
cd esp32-c3-home-weather-alert- File > Open Folder
- Select the cloned
esp32-c3-home-weather-alertdirectory. - PlatformIO should automatically detect the project.
Open a new terminal in VSCode (`Ctrl+`` or View > Terminal) and run:
pio runOr click the PlatformIO Build button (checkmark icon) or press Ctrl+Shift+P → PlatformIO: Build.
PlatformIO will fetch and install necessary libraries defined in platformio.ini.
Edit include/Config.h:
#ifndef CONFIG_H
#define CONFIG_H
// WiFi Configuration
const char* WIFI_SSID = "Your_WiFi_SSID";
const char* WIFI_PASSWORD = "Your_WiFi_Password";
// Email Configuration
const char* SMTP_HOST = "smtp.gmail.com";
const uint16_t SMTP_PORT = 587; // 465 for SSL/TLS
const char* AUTHOR_EMAIL = "[email protected]";
const char* AUTHOR_PASSWORD = "your_email_password_or_app_specific_password";
const char* RECIPIENT_EMAIL = "[email protected]";
// DHT Sensor Configuration
#define DHTPIN 10
#define DHTTYPE DHT22
// LCD Display Configuration
#define LCD_ADDRESS 0x27
#define LCD_COLS 16
#define LCD_ROWS 2
#define SDA_PIN 20 //8
#define SCL_PIN 21 //9
// OLED Display Configuration
#define OLED_WIDTH 128
#define OLED_HEIGHT 32
#define OLED_SDA_PIN 8 //20 //8
#define OLED_SCL_PIN 9 //21 //9
#define OLED_RESET_PIN -1
// Alert Thresholds
const float TEMP_HIGH_THRESHOLD = 26.5;
const float TEMP_LOW_THRESHOLD = 22.0;
const float HUM_HIGH_THRESHOLD = 85.0;
const float HUM_LOW_THRESHOLD = 40.0;
const float TEMP_CHANGE_THRESHOLD = 1.0; // °C
const float HUM_CHANGE_THRESHOLD = 5.0; // %
const unsigned long ALERT_COOLDOWN = 60000; // 1 minute in milliseconds
#endif // CONFIG_H
Security Note: For production or public repos, avoid hardcoding credentials—consider app passwords or environment variables.
- Port 587 for STARTTLS.
- Port 465 for SSL/TLS.
Set TEMP_CHANGE_THRESHOLD and HUM_CHANGE_THRESHOLD to fine-tune alert sensitivity.
You can build, upload, and monitor your project via VSCode or Terminal.
-
Build:
- Click the PlatformIO Build button (checkmark icon) or press
Ctrl+Shift+P→PlatformIO: Build.
- Click the PlatformIO Build button (checkmark icon) or press
-
Upload:
- Connect ESP32-C3 via USB.
- Click the PlatformIO Upload button (right arrow icon).
-
Monitor Serial:
- Click the PlatformIO Monitor button (plug icon).
- Set baud rate to 115200 if prompted.
-
Web GUI:
- Check the Serial output for your ESP32 IP address.
- Open a browser and go to
http://<ESP32_IP_Address>.
-
Install PlatformIO CLI (if not already):
pip install platformio
-
Build:
pio run
-
Upload:
pio run -t upload
-
Monitor:
pio device monitor -b 115200
-
Web GUI:
- Note the IP address in the Serial Monitor.
- Open
http://<ESP32_IP_Address>in your browser.
esp32-c3-home-weather-alert/
├── include/
│ ├── Config.h
│ └── (other headers)
├── lib/
│ ├── DhtSensor/
│ ├── EmailClient/
│ ├── WebGui/
│ ├── OLEDDisplay/ (or LCDisplay/)
│ └── ...
├── src/
│ └── main.cpp
├── test/
├── platformio.ini
├── README.md
└── CODE_OF_CONDUCT.md
- include/: Shared headers and configurations (
Config.h). - lib/: Custom libraries (e.g.,
DhtSensor,EmailClient,WebGui,OLEDDisplay/LCDisplay). - src/: Main application source (
main.cpp). - test/: Unit or integration tests.
- platformio.ini: PlatformIO build and dependency configuration.
- README.md: Project documentation.
-
Check Wiring:
- Ensure DHT sensor pinout is correct.
- Verify SDA and SCL pins for I2C devices (OLED) match the code.
-
I2C Address:
- If the OLED isn't displaying, use an I2C scanner to confirm the address (
0x3C, etc.).
- If the OLED isn't displaying, use an I2C scanner to confirm the address (
-
Serial Monitor:
- Watch logs for Wi-Fi connection issues, sensor read failures, or email errors.
- Increase debug outputs if needed.
-
Email Credentials:
- If using Gmail with 2FA, generate an App Password instead of your normal password.
-
NTP Sync:
- Verify the NTP server address if time synchronization fails.
-
Fork and Clone:
git clone https://github.com/<yourusername>/esp32-c3-home-weather-alert.git cd esp32-c3-home-weather-alert
-
Create a Branch:
git checkout -b feature/AmazingFeature
-
Make Changes & Commit:
git commit -m "Add AmazingFeature" -
Push & Pull Request:
git push origin feature/AmazingFeature
- Submit a PR on GitHub.
Please follow the Code of Conduct to help maintain a welcoming environment for all contributors.
Distributed under the MIT License. Refer to LICENSE for details.
- ESP-Mail-Client by Mobizt — robust email sending support.
- Adafruit DHT Sensor Library — easy DHT sensor handling.
- Adafruit SSD1306 / LiquidCrystal_I2C — display libraries for visual feedback.
- The open-source community for invaluable resources, examples, and troubleshooting help.
If you have any questions or need support, please open an issue in the GitHub repository.

