Skip to content

Built a Real-Time Smart Room Automation System with STM32F407 and Embedded C, integrating motion sensing, RFID access, temperature monitoring, and automated lighting/fan control.

Notifications You must be signed in to change notification settings

Muhammad-Ahmad17/RealTimeSmartRoomAutomation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Real-Time Smart Room Automation System

A comprehensive embedded systems project implementing a smart room automation system using STM32F407 microcontroller with RFID card detection, motion sensing, and automated lighting control.

📋 Overview

This project demonstrates a real-time smart room automation system that integrates multiple sensors and actuators to create an intelligent environment control system. The system automatically manages room lighting, fan operation, and security features based on motion detection, RFID card recognition, and user inputs.

🎯 Key Features

1. Motion & Presence Detection

  • IR Motion Sensor: Detects presence and tracks people passing through the room
  • Accelerometer Integration: LIS302DL 3-axis accelerometer for precise motion detection
  • Dual Detection System: Combines IR sensor for room occupancy and accelerometer for activity tracking
  • Baseline Calibration: Automatic baseline calibration for accurate motion thresholds
  • Real-Time Monitoring: Continuous motion tracking with configurable sensitivity
  • Movement History: Maintains motion count and timestamps for analytics
  • Presence Verification: Distinguishes between static presence and active movement

2. RFID Card Access Control

  • MFRC522 RFID Module: Supports RFID card detection and identification
  • Card Management: Tracks card UID and detection timestamps
  • Access Validation: Card-based authentication for room access
  • Multiple Card Support: Can store and validate multiple authorized cards

3. Intelligent Lighting Control

  • Automatic Activation: Lights activate on motion detection or RFID card scan
  • Manual Override: Push buttons for manual light control
  • LED Management: GPIO-based LED light control with PWM support
  • Smart Shutdown: Lights automatically turn off after leaving the room or on manual request

4. Audio Feedback System

  • Buzzer Alerts: Multi-frequency buzzer for different system states
    • 330 Hz: Neutral tone (E4)
    • 523 Hz: Affirmative/Success (C5)
    • 165 Hz: Alert/Warning (E3)
    • 1047 Hz: Critical Alert (C6)

5. Intelligent Fan Control with Temperature Monitoring

  • LM35 Temperature Sensor: Real-time temperature monitoring via ADC(DMA)
  • Automatic Fan Control: Fan automatically activates when temperature exceeds threshold
  • Temperature-Based Adjustment: Fan speed adjusts based on real-time temperature readings
  • Precise Temperature Measurement: Analog voltage conversion to Celsius
  • Status Monitoring: Real-time fan status and temperature display on LCD

6. Real-Time Display

  • LCD Display: 16x2 LCD with PCF8574 I2C Backpack (Address: 0x27)
  • System Status: Real-time display of system state and sensor readings
  • User Feedback: Visual confirmation of user actions

🔧 Hardware Components

Component Model Interface Purpose
Microcontroller STM32F407VGTx - Main processor
Accelerometer LIS302DL SPI2 Motion detection
RFID Reader MFRC522 SPI1 Card identification
Temperature Sensor LM35 ADC1 Real-time temperature monitoring
LCD Display 16x2 I2C (PCF8574) System feedback
Motion Sensor IR Sensor GPIO (PC7) Detects person presence and movement through room
Buzzer Generic PWM Timer Audio alerts
LED Light Generic GPIO (PC9) Room lighting
Fan Motor Generic GPIO/PWM Temperature-controlled ventilation
Buttons Push Buttons GPIO Manual control

💻 Interfaces

  • SPI1: RFID Module (MFRC522)
  • SPI2: Accelerometer (LIS302DL)
  • I2C1: LCD Display (PCF8574)
  • ADC1: Analog sensor inputs
  • Timer2, Timer3, Timer4: PWM and timing control
  • DMA: ADC data transfer

📁 Project Structure

code/
├── Core/
│   ├── Inc/           # Header files (main.h, mfrc522.h, etc.)
│   ├── Src/           # Main source code (actual code logic)
│   └── Startup/       # STM32 startup code
├── Drivers/
│   ├── CMSIS/         # ARM CMSIS headers
│   └── STM32F4xx_HAL_Driver/  # HAL libraries
├── Middlewares/
│   └── ST/STM32_USB_Host_Library/  # USB support
├── USB_HOST/          # USB host configuration
├── Debug/             # Build artifacts
└── *.ioc, *.ld        # STM32CubeMX & linker files

⚙️ Technical Specifications

  • Microcontroller: ARM Cortex-M4F (STM32F407)
  • Clock Speed: Up to 168 MHz
  • Flash Memory: 1 MB
  • RAM: 192 KB
  • Peripherals: SPI, I2C, ADC, Timers, GPIO, DMA
  • Communication: USB Host support

🚀 Getting Started

Prerequisites

  • STM32CubeIDE
  • STM32F407VGTx development board
  • Required sensors and components

Building the Project

  1. Open the project in STM32CubeIDE
  2. Build the project using the Debug makefile
  3. Program the STM32F407VGTx using ST-Link debugger

Configuration

  • Modify sensor thresholds in main.c as needed
  • Adjust motion detection sensitivity via calibration
  • Configure RFID authorized card UIDs
  • Set LCD display parameters

🔐 Security Features

  • RFID card-based access control
  • Motion detection for intrusion detection
  • Real-time alert system with buzzer feedback
  • Card detection logging with timestamps

📊 System States

State Trigger Action
Idle No motion, no card Lights off, low power
Active Motion detected Lights on, monitoring
Card Detected RFID scan Verify access, activate
Exit Exit button pressed Prepare shutdown
Fan Active Timer enabled Fan runs for duration
Alert Critical event Buzzer sounds warning

📝 Development Notes

  • Uses HAL library for hardware abstraction
  • DMA-based ADC conversion for efficiency
  • Interrupt-driven card detection
  • Calibrated motion thresholds for accuracy
  • Real-time system monitoring and feedback

📚 Documentation

For detailed information about the project:

  • CEP_Proposal.pdf: Initial project proposal
  • CEP_Report.pdf: Comprehensive project report

⚠️ Demo Video

Incomplete Demo - brokendemo.mp4

Status: ⏳ Incomplete Demo Due to Hardware Constraints
Reason: Some hardware components require final integration and calibration

The demo video showcases:

  • Real-time motion detection and sensor integration
  • RFID card scanning and access validation
  • System audio feedback mechanisms (multi-frequency buzzer)
  • LCD display real-time updates
  • Temperature monitoring and fan control
  • Emergency shutdown procedures

Video File: brokendemo.mp4


About

Built a Real-Time Smart Room Automation System with STM32F407 and Embedded C, integrating motion sensing, RFID access, temperature monitoring, and automated lighting/fan control.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages