Skip to content

Ahmedmhmud/Smart-Home

Repository files navigation

Smart Home System

A comprehensive smart home automation system built with the ATmega32 microcontroller, featuring integrated temperature control, fire detection, automatic lighting, and motor control.

Overview

This project implements a fully functional smart home control system that monitors environmental conditions and automatically adjusts home systems in response. The system uses various sensors and actuators to provide intelligent automation and safety features.

Features

🌡️ Temperature Control

  • LM35 Temperature Sensor: Continuously monitors room temperature in real-time
  • Smart LED Indicators:
    • Green LED when temperature is normal (≤30°C)
    • Red LED when temperature exceeds 30°C
  • Adaptive PWM Buzzer: Alert intensity increases with temperature
    • 100 PWM level: 30-50°C range
    • 200 PWM level: 50-60°C range
    • 255 PWM level: Above 60°C
  • LCD Display: Shows current temperature with degree symbol

🔥 Fire Alarm System

  • Dual Fire Detection:
    • Flame sensor input for direct flame detection
    • ADC-based smoke/heat sensor (threshold at 900)
  • Immediate Response:
    • Buzzer activation on fire detection
    • Red alert LED illuminates
    • Green safety LED turns off
    • Real-time status display on LCD
  • Visual Feedback: "FIRE!!!" warning message on display when danger detected

💡 Automatic Lighting Control

  • LDR (Light Dependent Resistor): Detects ambient light levels
  • Day/Night Mode:
    • Automatically switches to "Day" mode when sufficient light detected
    • Automatically switches to "Night" mode in darkness
    • Adjusts light levels accordingly
  • LCD Status: Displays current lighting mode in real-time

⚙️ Motor Control

  • Multi-directional Motor: Controlled via relay outputs
  • Speed Control: Adjustable through PWM signal
  • Flexible Integration: Easy integration with other automation routines

📊 System Information Display

  • LCD Interface: 16x2 character LCD display
  • Real-time Monitoring: All sensor data displayed simultaneously
  • Status Updates: Continuous refresh at 200ms intervals
  • Temperature Display: With degree symbol and Celsius indicator

Hardware Components

  • Microcontroller: ATmega32
  • Temperature Sensor: LM35 (Analog)
  • Fire Detection: Flame sensor + Smoke sensor (ADC)
  • Light Sensor: LDR (Light Dependent Resistor)
  • Display: 16x2 Character LCD
  • Actuators:
    • Red and Green LEDs (Temperature indicator set)
    • Red and Green LEDs (Fire alarm indicator set)
    • Buzzer with PWM control
    • Motor with relay control
  • Power Supply: ±12V for relay circuits, 5V for logic

System Architecture

Software Structure

  • HAL (Hardware Abstraction Layer): Sensor and actuator interfaces
    • LM35 temperature sensor
    • Buzzer control
    • LED management
    • LCD display interface
    • Button/Switch interface
  • MCAL (Microcontroller Abstraction Layer):
    • ADC (Analog-to-Digital Conversion)
    • External Interrupts (EXTI)
    • Timer 2 for PWM generation
    • DIO (Digital Input/Output)
  • Application Layer: Main logic and control routines

Operating Logic

  1. Initialization: All sensors and peripherals are initialized on startup
  2. Continuous Monitoring Loop (200ms cycle):
    • Read LM35 temperature
    • Evaluate temperature thresholds
    • Control temperature indicator LEDs
    • Adjust buzzer frequency based on temperature
    • Check fire detection sensors
    • Activate fire alarm if needed
    • Monitor light levels with LDR
    • Control ambient lighting
    • Update LCD with all status information

Usage

The system operates autonomously after initialization. No user input is required for normal operation, though external interrupt handling (EXTI0) is implemented for button control integration.

Display Information

The LCD shows four key pieces of information:

  • Row 1: Current temperature (e.g., "Temp: 31°C")
  • Row 2 (Left): Fire status ("FIRE!!!" or "No fire")
  • Row 2 (Right): Lighting mode ("Day" or "Night")

Safety Features

  • Thermal Monitoring: Prevents dangerous temperature conditions
  • Fire Detection: Dual-sensor system ensures reliable fire alarm activation
  • Automatic Response: All safety actions trigger without delay
  • Visual & Audio Alerts: Multiple notification methods for alarm conditions
  • LED Indicators: Instant visual feedback of system status

Notes

  • The system operates on a continuous refresh cycle of 200ms
  • Temperature readings are updated in real-time
  • Fire detection uses redundant sensors for reliability
  • LCD interface allows clear monitoring of all system states

About

Smart home using ATmega32

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors