An intelligent weather monitoring system with proximity-based display activation using ESP32 microcontroller.
- Real-time environmental monitoring - Temperature and humidity sensing
- Proximity-based activation - Display automatically turns on/off based on user presence
- Color-coded TFT display - Visual representation of sensor data
- Energy efficient - Smart sleep mode when no one is around
- Modular architecture - Easy to extend with additional sensors
- ESP32-WROOM-32 - Main microcontroller
- DHT11 - Temperature and humidity sensor
- HC-SR04 - Ultrasonic distance sensor
- 2.4" TFT ILI9341/ST7789 - Color display (240x320)
- Breadboard - For prototyping connections
- Jumper wires - For connections
DHT11:
βββ VCC β 3.3V
βββ GND β GND
βββ DATA β GPIO4
TFT Display:
βββ VCC β 3.3V
βββ GND β GND
βββ CS β GPIO5
βββ RST β GPIO22
βββ DC β GPIO21
βββ MOSI β GPIO23
βββ SCK β GPIO18
βββ MISO β GPIO19
βββ LED β 3.3V (backlight)
HC-SR04:
βββ VCC β 3.3V/5V
βββ GND β GND
βββ Trig β GPIO15
βββ Echo β GPIO2
- PlatformIO IDE
- Visual Studio Code (recommended)
- Clone the repository
git clone https://github.com/Maksikos-ctrl/smartclimate-station.git
cd smartclimate-station- Open in PlatformIO
code .- Install dependencies
Dependencies are automatically installed via
platformio.ini:
- DHT sensor library
- Adafruit Unified Sensor
- TFT_eSPI
- Configure display driver
Update
User_Setup.hin TFT_eSPI library with your display type:
#define ST7789_DRIVER // or ILI9341_DRIVER depending on your display
#define TFT_WIDTH 240
#define TFT_HEIGHT 320- Build and upload
platformio run --target uploadβββ include/
β βββ displayTFT.h # TFT display management
β βββ sensorDHT.h # DHT11 sensor interface
β βββ ultrasonicSensor.h # HC-SR04 proximity sensor
βββ src/
β βββ main.cpp # Main application logic
β βββ displayTFT.cpp # Display implementation
β βββ sensorDHT.cpp # DHT11 implementation
β βββ ultrasonicSensor.cpp # Ultrasonic sensor implementation
βββ platformio.ini # Project configuration
βββ README.md
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ESP32-WROOM-32 β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββ β
β β FreeRTOS β β Arduino β β System Tasks β β
β β Kernel β β Framework β β WiFi/Bluetooth β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Communication Protocols β
β SPI β 1-Wire β GPIO β I2C β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Sensors Layer β
β TFT Display β DHT11 β HC-SR04 β Future β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Used by: TFT Display (and potentially RFID modules)
- Pins: SCK (GPIO18), MOSI (GPIO23), MISO (GPIO19), CS (GPIO5)
- Type: Synchronous, full-duplex, master-slave architecture
- Speed: 27MHz
- Benefits: High-speed data transfer, multiple devices on same bus
- Used by: DHT11 Temperature/Humidity Sensor
- Pins: Single data line (GPIO4) with built-in pull-up
- Type: Asynchronous, half-duplex, single-wire digital protocol
- Features: Power and data on same line, timing-critical communication
- Implementation: Custom DHT11 library handling timing sequences
- Used by: HC-SR04 Ultrasonic Sensor
- Pins: TRIG (GPIO15 - OUTPUT), ECHO (GPIO2 - INPUT)
- Type: Digital pulse-based measurement
- Method: Pulse width modulation for distance calculation
The project runs on FreeRTOS (Free Real-Time Operating System) which is integrated into the ESP32 Arduino framework:
- Task Scheduling: Automatic time-slicing between operations
- Memory Management: Dynamic heap allocation for sensor data
- Timer Services: Built-in delay and timing functions
- Interrupt Handling: Hardware timer interrupts for sensor readings
- Watchdog Timer: System stability monitoring
- Concurrent Operations: Simultaneous sensor reading, display updates, and proximity detection
- Real-time Response: Guaranteed response times for critical operations
- Memory Safety: Protected memory allocation for sensor buffers
- System Stability: Automatic recovery from sensor failures
// Implicit FreeRTOS tasks in Arduino framework:
loop() // Main application task (1ms tick)
WiFi handling // Background network task
SPI operations // Hardware abstraction task
Timer callbacks // Sensor reading interruptsYou can access FreeRTOS directly if needed:
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
// Check FreeRTOS version and memory
Serial.println(tskKERNEL_VERSION_NUMBER);
Serial.println(ESP.getFreeHeap());- Activation delay: 1 second
- Deactivation delay: 5 seconds
- Measurement interval: 200ms
- Black screen with "ΠΠΎΠ΄ΠΎΠΉΠ΄ΠΈΡΠ΅ Π±Π»ΠΈΠΆΠ΅..." message
- Minimal power consumption
- Continuous proximity monitoring
- Header: "Weather Station"
- Humidity: Green text with % symbol
- Temperature: Yellow text with Β°C symbol
- Distance: White text with cm measurement
- Update interval: 2 seconds
Real-time sensor data is output to Serial Monitor:
Temperature: 28.5Β°C, Humidity: 45.2%
Distance: 67 cm, Person present: YES
Complete SmartClimate Station with proximity detection and real-time environmental monitoring
βββββββββββββββββββββββββββββββββββ
β β
β β
β ΠΠΎΠ΄ΠΎΠΉΠ΄ΠΈΡΠ΅ Π±Π»ΠΈΠΆΠ΅... β
β β
β β
β WiFi: Connected β
β 192.168.1.123 β
βββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββ
β Weather Station β
β Online β
β β
β Humidity: 45.2 % β
β β
β Temperature: 28.5 C β
β β
β Distance: 67 cm β
β β
βββββββββββββββββββββββββββββββββββ
- System Boot: Display shows sleep screen
- User Approaches: HC-SR04 detects proximity < 100cm
- Display Activation: Screen switches to weather data view
- Data Updates: Real-time sensor readings every 2 seconds
- User Leaves: After 5 seconds, returns to sleep mode
- Energy Saving: Minimal power consumption in sleep state
Modify values in ultrasonicSensor.cpp:
static const float PRESENCE_THRESHOLD = 100.0; // Detection range in cm
static const unsigned long PRESENCE_DELAY = 1000; // Activation delay
static const unsigned long ABSENCE_DELAY = 5000; // Deactivation delayAdjust positioning in displayTFT.h:
static const int HUM_LABEL_X = 20;
static const int HUM_LABEL_Y = 80;
// ... other coordinates- Verify TFT driver type in
User_Setup.h - Check SPI pin connections
- Ensure backlight (LED) pin is connected to power
- DHT11 requires pull-up resistor (built-in
INPUT_PULLUPused) - HC-SR04 needs stable power supply
- Check serial output for sensor readings
- White/blank display: Wrong driver or missing backlight
- No sensor readings: Check pin connections and power
- Erratic proximity detection: Adjust
PRESENCE_THRESHOLD
- β WiFi connectivity for remote monitoring and data logging
- RFID access control for personalized user profiles
- Additional sensors (pressure, light, air quality)
- Web dashboard with historical data visualization
- Mobile app integration for remote access
- AI-powered object classification (distinguish between hand, person, objects)
- β Firebase integration for data persistence
- C++ desktop application for advanced analytics
- Smart Building: Office climate monitoring and occupancy detection
- Agriculture: Greenhouse environmental control
- Healthcare: Patient room monitoring
- Smart Home: Automated climate control based on presence
- Research: Environmental data collection for studies
- Microcontroller: ESP32-WROOM-32 (Dual-core Xtensa LX6, 240MHz)
- Operating System: FreeRTOS v10.x
- Operating Voltage: 3.3V
- Power Consumption: ~150mA (active), ~50mA (sleep)
- Temperature Range: 0-50Β°C (DHT11 limitation)
- Humidity Range: 20-90% RH (Β±5% accuracy)
- Distance Range: 2-400cm (Β±3mm accuracy)
- Display Resolution: 240x320 pixels, 16-bit color
- Communication Protocols: SPI, 1-Wire, GPIO
- Update Rate: 2 seconds (display), 200ms (proximity)
- Memory: 520KB SRAM, 4MB Flash
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- PlatformIO for the development environment
- TFT_eSPI library for display management
- DHT sensor library by Adafruit
Your Name - maksikos973@gmail.com
Project Link: https://github.com/Maksikos-ctrl/smartclimate-station