Skip to content

Seymagocmez/STM32_Temperature_Ventilation_Control

Repository files navigation

Temperature-Controlled Ventilation System for Indoor Environments

This STM32-based system provides precise temperature-controlled ventilation, featuring automatic and manual fan control, real-time monitoring, and comprehensive alert mechanisms.

License: MIT Project Status: Completed

Table of Contents

🤝 Collaborators

This project was developed through the valuable collaboration of:

Merve Elanur Azman Gül Nur Deviren Şeyma Göçmez

Project Overview

The system controls indoor temperature using an LM35 sensor and displays real-time temperature on an LCD1602 display. An electric DC fan can be controlled automatically or manually:

  • Automatic Mode: The fan adjusts direction and speed based on predefined temperature thresholds.
  • Manual Mode: The user controls fan direction (forward/reverse) and speed using push buttons.

Visual (LEDs) and audible (buzzer) alerts notify users when the temperature is outside the safe range.

Features

Temperature Measurement

  • LM35 analog sensor
  • Real-time display on LCD1602
  • Updates triggered by ≥0.5°C change

Fan Control

  • Auto Mode:

    • Above 20°C → Counter-clockwise (cooling mode)
    • Below 10°C → Clockwise (heating mode)
    • Between 10–20°C → Fan stops
  • Manual Mode:

    • 5 push buttons control fan direction (FWD, REV, STOP)
    • PWM speed control (+10% / -10% per button press)

Motor Control

  • L298N Dual H-Bridge for direction control
  • PWM-based speed control (0–100%)

Alerts

  • Red LED + Buzzer: Danger zone (Temp <10°C or >20°C)
  • Green LED: Safe range (10–20°C)

Communication

  • UART (Serial Output): Transmits PWM duty cycle for monitoring

Interrupt Handling

  • EXTI interrupts handle button inputs for real-time control

Custom LCD Library

  • lcd1602.h driver written from scratch using STM32 HAL GPIO functions

Hardware Components

Component Description
MCU STM32F103R6
Sensor LM35 Analog Temperature Sensor
Motor Driver L298N Dual H-Bridge
Display LCD1602 (16x2 Character Display)
Fan DC Motor with adjustable direction/speed
Push Buttons 5 (FWD, REV, STOP, PWM+, PWM-)
LEDs + Buzzer Red & Green LEDs + Buzzer for alerts
UART Virtual terminal output for PWM monitoring

System Logic

Digital Control Flow

Control Flow Diagram

Figure 1: Ventilation System Digital Connections and Control Logic.

Workflow:

  • Initialize hardware

  • Loop:

    • Read LM35 sensor

    • Update LCD if temp changes ≥0.5°C

    • Check mode:

      • Manual Mode: Set direction & speed via buttons

      • Auto Mode:

        • 20°C → Fan CCW + Alerts

        • <10°C → Fan CW + Alerts
        • 10–20°C → Fan stops, green LED on

Fan Direction

Fan Direction Diagram

Figure 2: Fan Direction Control Mechanism.

Mode Direction Purpose GPIO
Summer Mode Counter-clockwise Cooling airflow PC8=HIGH, PC9=LOW
Winter Mode Clockwise Warm air circulation PC8=LOW, PC9=HIGH

Implementation

Tools & Environment

  • STM32CubeMX: Peripheral configuration
  • Keil MDK-ARM: Embedded C programming
  • Proteus 8.17: Circuit simulation

STM32CubeMX Pinout

STM32CubeMX Pinout

Figure 3: STM32CubeMX Pinout Configuration.

Supplementary Configuration Tables

Supplementary Config Tables

Figure 4: Supplementary Configuration Tables.

Proteus Simulation Setup

Connections:

Function STM32 Pin
LM35 Sensor PA1 (ADC)
LCD Control PA2–PA4
LCD Data PC0–PC6, PC10
Fan PWM PC7 (TIM3_CH2)
Fan Dir PC8, PC9
UART TX PA9
Red LED PB11
Green LED PB10
Buzzer PA0
Buttons PB0–PB4

Simulation Snapshots:

Safe Temp
Safe Temp
High Temp
High Temp

How to Run

Run in Proteus (Simulation)

Prerequisites

  • Proteus 8.17+
  • Keil MDK-ARM 5+
  • STM32CubeIDE (Optional)

Steps

git clone https://github.com/Seymagocmez/STM32_Temperature_Ventilation_Control.git
cd STM32_Temperature_Ventilation_Control
  1. Open the ventilition_system.pdsprj file in Proteus.
  2. Open the Keil project (ventilition_system.uvprojx) in Keil MDK-ARM.
  3. Build the project in Keil to generate the .hex file.
  4. Load the generated .hex file into the STM32 MCU component in the Proteus schematic.
  5. Start the simulation in Proteus to observe the system behavior.

For a more detailed documentation, please refer to the project docs.

Documentation

For a more detailed explanation of the system design, implementation details, and usage instructions, please refer to the project documentation (PDF).

License

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

Figure 2 Image Source

About

A ventilation system application based on STM32F103, featuring basic sensor integration and LCD display support.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages