Skip to content

Latest commit

Β 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SmartClimate Station

An intelligent weather monitoring system with proximity-based display activation using ESP32 microcontroller.

🌟 Features

  • 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

πŸ“‹ Hardware Requirements

Components

  • 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

Pin Configuration

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

πŸ› οΈ Software Setup

Prerequisites

Installation

  1. Clone the repository
git clone https://github.com/Maksikos-ctrl/smartclimate-station.git
cd smartclimate-station
  1. Open in PlatformIO
code .
  1. Install dependencies Dependencies are automatically installed via platformio.ini:
  • DHT sensor library
  • Adafruit Unified Sensor
  • TFT_eSPI
  1. Configure display driver Update User_Setup.h in 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
  1. Build and upload
platformio run --target upload

πŸ“ Project Structure

β”œβ”€β”€ 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

πŸ”§ System Architecture

Hardware Layer

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  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    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Communication Protocols Used

SPI (Serial Peripheral Interface)

  • 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

1-Wire Protocol

  • 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

GPIO (General Purpose Input/Output)

  • 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

Real-Time Operating System

The project runs on FreeRTOS (Free Real-Time Operating System) which is integrated into the ESP32 Arduino framework:

FreeRTOS Features Used:

  • 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

RTOS Benefits in This Project:

  • 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

Task Distribution:

// 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 interrupts

You 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());

πŸ”§ System Behavior

Proximity Detection

  • Activation delay: 1 second
  • Deactivation delay: 5 seconds
  • Measurement interval: 200ms

Display States

Sleep Mode (No presence detected)

  • Black screen with "ΠŸΠΎΠ΄ΠΎΠΉΠ΄ΠΈΡ‚Π΅ Π±Π»ΠΈΠΆΠ΅..." message
  • Minimal power consumption
  • Continuous proximity monitoring

Active Mode (Presence detected)

  • Header: "Weather Station"
  • Humidity: Green text with % symbol
  • Temperature: Yellow text with Β°C symbol
  • Distance: White text with cm measurement
  • Update interval: 2 seconds

Data Output

Real-time sensor data is output to Serial Monitor:

Temperature: 28.5Β°C, Humidity: 45.2%
Distance: 67 cm, Person present: YES

πŸ“Έ Project Gallery

Complete Weather Station

SmartClimate Station Complete SmartClimate Station with proximity detection and real-time environmental monitoring

🎨 Display Layout

Visual States

Sleep Mode

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                 β”‚
β”‚                                 β”‚
β”‚         ΠŸΠΎΠ΄ΠΎΠΉΠ΄ΠΈΡ‚Π΅ Π±Π»ΠΈΠΆΠ΅...      β”‚
β”‚                                 β”‚
β”‚                                 β”‚
β”‚  WiFi: Connected                β”‚
β”‚  192.168.1.123                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Active Mode

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Weather Station         β”‚
β”‚                          Online β”‚
β”‚                                 β”‚
β”‚  Humidity:              45.2 %  β”‚
β”‚                                 β”‚
β”‚  Temperature:           28.5 C  β”‚
β”‚                                 β”‚
β”‚  Distance:                67 cm β”‚
β”‚                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”„ Workflow Demonstration

  1. System Boot: Display shows sleep screen
  2. User Approaches: HC-SR04 detects proximity < 100cm
  3. Display Activation: Screen switches to weather data view
  4. Data Updates: Real-time sensor readings every 2 seconds
  5. User Leaves: After 5 seconds, returns to sleep mode
  6. Energy Saving: Minimal power consumption in sleep state

βš™οΈ Configuration

Sensor Thresholds

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 delay

Display Settings

Adjust positioning in displayTFT.h:

static const int HUM_LABEL_X = 20;
static const int HUM_LABEL_Y = 80;
// ... other coordinates

πŸ” Troubleshooting

Display Issues

  • Verify TFT driver type in User_Setup.h
  • Check SPI pin connections
  • Ensure backlight (LED) pin is connected to power

Sensor Issues

  • DHT11 requires pull-up resistor (built-in INPUT_PULLUP used)
  • HC-SR04 needs stable power supply
  • Check serial output for sensor readings

Common Problems

  • White/blank display: Wrong driver or missing backlight
  • No sensor readings: Check pin connections and power
  • Erratic proximity detection: Adjust PRESENCE_THRESHOLD

πŸš€ Future Enhancements

Planned Features

  • βœ… 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

Potential Applications

  • 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

πŸ“Š Technical Specifications

  • 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

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“§ Contact

Your Name - maksikos973@gmail.com

Project Link: https://github.com/Maksikos-ctrl/smartclimate-station

About

An intelligent weather monitoring system with proximity-based display activation using ESP32 microcontroller.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages