Skip to content

AhmedWaleed36/Smart_Home

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ ๐Ÿ’ก Smart Home System โ€” Design & Implementation

This project showcases the complete implementation of a Smart Home system using the ATMega32 microcontroller. It demonstrates key embedded systems principles including:

- ๐ŸŒก๏ธ Environmental monitoring and control

- ๐Ÿ”” Alert and notification systems

- ๐Ÿ”Œ Peripheral device integration

- ๐Ÿง  Intelligent decision making

โœ… Full smart home functionality โœ… Supports multiple sensors and actuators โœ… Designed for ATMega32 microcontroller โœ… Implements layered software architecture

๐Ÿงฉ Architecture Design

๐Ÿ” 1. System Overview

The Smart Home system represents a complete embedded application:

๐Ÿšฆ Uses ATMega32 microcontroller as the core processor

๐ŸŒก๏ธ Monitors environmental conditions through sensors

๐Ÿ”” Provides alerts and notifications through buzzers

๐Ÿ”Œ Controls various home appliances and devices

๐Ÿง  Makes intelligent decisions based on sensor readings

๐Ÿงฑ 2. Hardware Components

The system is built around these key hardware components:

- ๐Ÿง  ATMega32 Microcontroller

- ๐ŸŒก๏ธ Temperature sensors

- ๐Ÿ’ง Humidity sensors

- ๐Ÿ”† Light sensors

- ๐Ÿ”” Buzzers for alerts

- ๐Ÿ’ก LEDs for status indication

- ๐Ÿ”Œ Relays for appliance control

๐Ÿ”ง 3. Software Architecture

The software is organized in a layered architecture:

- ๐Ÿ“‚ MCAL (Microcontroller Abstraction Layer)

    - GPIO: For digital input/output control
    
    - ADC: For analog sensor readings
    
    - EXIT: For external interrupt handling
    
    - GIE: For global interrupt control
    
- ๐Ÿ“‚ HAL (Hardware Abstraction Layer)

    - BUZ: For buzzer control
    
    - LED: For LED control and indication
    
    - Sensors: For environmental monitoring
    
- ๐Ÿ“‚ LIB (Libraries)

    - Standard types and bit manipulation
    
- ๐Ÿ“‚ APP (Application Layer)

    - Main application logic
    - Decision making algorithms

๐Ÿง  Component Implementations

๐ŸŒก๏ธ 1. Sensor Monitoring System

- Interfaces with multiple environmental sensors

- ๐Ÿ”ข Converts analog readings to digital values

- ๐Ÿงฎ Processes and interprets sensor data

- ๐Ÿ“Š Maintains thresholds for decision making

๐Ÿ”” 2. Alert System

- Implements buzzer control for notifications

- ๐Ÿ”„ Configures different alert patterns

- ๐Ÿšจ Triggers alerts based on sensor thresholds

- ๐Ÿ”‡ Provides methods to enable/disable alerts

๐Ÿ”Œ 3. Device Control

- Manages home appliances through relays

- ๐Ÿ”„ Implements on/off functionality

- ๐Ÿงฎ Handles device state management

- โฑ๏ธ Supports timed operations

๐Ÿ’ก 4. Status Indication

- Provides visual feedback through LEDs

- ๐Ÿ”„ Indicates system state and operation modes

- ๐Ÿšฆ Shows alert levels and conditions

- ๐Ÿ“Š Displays sensor reading status

๐Ÿ’ป Implementation Details

๐ŸŒก๏ธ 1. Sensor Reading Logic

The ADC module handles sensor readings:

void ADC_Init(ADC_Type ADC_Configuration) {
    // Configure ADC reference voltage
    switch(ADC_Configuration.Reference) {
        case AREF:
            CLR_BIT(ADMUX, REFS0);
            CLR_BIT(ADMUX, REFS1);
            break;
        case AVCC:
            SET_BIT(ADMUX, REFS0);
            CLR_BIT(ADMUX, REFS1);
            break;
        case INTERNAL:
            SET_BIT(ADMUX, REFS0);
            SET_BIT(ADMUX, REFS1);
            break;
    }
    
    // Configure ADC adjustment
    if(ADC_Configuration.Adjustment == LEFT) {
        SET_BIT(ADMUX, ADLAR);
    } else {
        CLR_BIT(ADMUX, ADLAR);
    }
    
    // Configure prescaler
    ADCSRA &= 0xF8;
    ADCSRA |= ADC_Configuration.Prescaler;
    
    // Enable ADC
    SET_BIT(ADCSRA, ADEN);
}

๐Ÿ”” 2. Buzzer Control System

The buzzer module provides alert functionality:

void BUZ_Init(BUZ_Type BUZ_Configuration) {
    GPIO_SetPinDirection(BUZ_Configuration.Port, BUZ_Configuration.Pin, 
                         PIN_OUTPUT);
}

void BUZ_On(BUZ_Type BUZ_Configuration) {
    if (BUZ_Configuration.Active_Status == ACTIVE_HIGH) {
        GPIO_SetPinValue(BUZ_Configuration.Port, BUZ_Configuration.Pin, 
                         LOGIC_HIGH);
    } else if (BUZ_Configuration.Active_Status == ACTIVE_LOW) {
        GPIO_SetPinValue(BUZ_Configuration.Port, BUZ_Configuration.Pin, 
                         LOGIC_LOW);
    }
}

void BUZ_Off(BUZ_Type BUZ_Configuration) {
    if (BUZ_Configuration.Active_Status == ACTIVE_HIGH) {
        GPIO_SetPinValue(BUZ_Configuration.Port, BUZ_Configuration.Pin, 
                         LOGIC_LOW);
    } else if (BUZ_Configuration.Active_Status == ACTIVE_LOW) {
        GPIO_SetPinValue(BUZ_Configuration.Port, BUZ_Configuration.Pin, 
                         LOGIC_HIGH);
    }
}

๐Ÿง  3. Decision Making Logic

The main application implements intelligent decision making:

// Example decision making logic (conceptual)
void ProcessSensorData() {
    u16 temperature = ADC_GetReading(TEMP_SENSOR_CHANNEL);
    u16 humidity = ADC_GetReading(HUMIDITY_SENSOR_CHANNEL);
    u16 light = ADC_GetReading(LIGHT_SENSOR_CHANNEL);
    
    // Temperature control
    if (temperature > TEMP_HIGH_THRESHOLD) {
        // Turn on cooling
        Device_TurnOn(COOLING_DEVICE);
        // Activate alert if very high
        if (temperature > TEMP_CRITICAL_THRESHOLD) {
            BUZ_On(tempAlertBuzzer);
        }
    } else if (temperature < TEMP_LOW_THRESHOLD) {
        // Turn on heating
        Device_TurnOn(HEATING_DEVICE);
    } else {
        // Normal temperature range
        Device_TurnOff(COOLING_DEVICE);
        Device_TurnOff(HEATING_DEVICE);
        BUZ_Off(tempAlertBuzzer);
    }
    
    // Similar logic for humidity and light control
    // ...
}

๐Ÿ”ง Development Environment

- ๐Ÿ”Œ Atmel Studio โ€” for code development

- ๐Ÿ“Ÿ Proteus โ€” for circuit simulation

- ๐Ÿ”„ AVR-GCC โ€” for compilation

- ๐Ÿ“ฅ AVRDUDE โ€” for microcontroller programming

๐Ÿš€ How to Use

๐Ÿ”ง 1. Hardware Setup

- Connect sensors to ADC pins as specified in the configuration

- Connect buzzers and LEDs to the designated GPIO pins

- Connect relay modules to control pins for appliance control

- Power the ATMega32 with appropriate voltage (5V)

๐Ÿ’ป 2. Software Setup

- Clone the repository

- Open the project in Atmel Studio

- Configure sensor thresholds in the configuration files

- Build the solution

- Program the ATMega32 using a suitable programmer

๐ŸŽฎ 3. Operation

- The system starts monitoring automatically after power-on

- LEDs indicate the current status of the system

- Buzzers activate when sensor readings exceed thresholds

- Appliances are controlled automatically based on environmental conditions

- Manual override is possible through connected switches

๐Ÿ‘จโ€๐Ÿ’ป Author

๐Ÿง‘โ€๐Ÿ’ป Ahmed Waleed Ahmed

๐Ÿ“œ License

This project was developed as an embedded systems application using the ATMega32 microcontroller.

๐Ÿ“˜ Note: For full implementation details and circuit diagrams, please refer to the simulation files and source code.

About

This project showcases the complete implementation of a Smart Home system using the ATMega32 microcontroller

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors