β Perform a review and leave a comment here
β If you want to contribute, add a new record like here. This example is for my Tank Level Control project, but the idea is the same for any project.
β If this needs to be improved, create an issue here
The Project was done as a project for RTOS course at NTI.
Done by:
- Mahmoud Karam Emara ([email protected])
- Ahmed Abdelgawad Kamal ([email protected])
- Mina Ghobrial Abdulla ([email protected])
- Hossam Mostafa Abd El-Aziz ([email protected])
- Ahmed Mohamed Mannaa ([email protected])
Under the supervision of the great instructor: Eng. Eman khiary Mohamed ([email protected]): Embedded Software Engineer and NTI Instructor.
This is a simple smart home system, done using FreeRTOS and Atmega32 microcontroller.
The system consists of the following functions:
- Gas Sensor to sense the gas level in the house.
- Temperature Sensor to sense the temperature in the house.
- Keypad to enter the password to open the door.
- Motor to open/close the door when the password is correct.
- Buzzer to alert the user when the system is in alarm mode:
- The password is incorrect for 3 times.
- The gas level is above the critical level.
- LCD to display the system's data (temperature, door status, gas level).
We've worked on the application layer (code/main.c, code/main.h, code/main_cfg.c, and code/main_cfg.h) using the Components On the Shelf (COTS) approach (microcontroller drivers and the freeRTOS kernel).
The project is open source and you can use it for your own projects.
You can test it without any Hardware, it can be simulated as will be discussed in the next sections. So, you don't need any hardware to run this project.
- π Introduction
- Table of Contents
- π οΈ Development Tools Required
- Project Hierarchy
- β Working
- π― Results
- π Documentation
- π¬ What is next?
- πββοΈ Contribute
- π Contact me
- π Licenses
- π Credits
Read this guide to know what tools are required to develop this project.
The project contains some files and directories:
- code: Contains the code implemented using VS Code and eclipse SDK.
- docs: Contains the documentation files generated by doxygen and make, simulation test pictures, and some assets for README files.
- simulation: Contains the simulation files of Proteus8.11.
- README.md: The description of the project (What you are reading now).
- LICENSE: The license description of the project.
- Doxyfile: The configuration of doxygen application (Documentation generator).
- doxygen.mk: Contains the configuration and rules to be run using make to generate documents.
- tools.md: Contains HOW-TO-SETUP the tools required to run this project.
- version_log.md: Contains the history of the project.
The System has 5 tasks. These are:
-
Getting Password: This is done using the task (
taskGetPassword(void *pv )
). The password is entered by the user using the keypad. The user has 3 attempts to enter the password. If the password is incorrect, the system will be in alarm mode. If the password is correct, the system will be in normal mode and the door will be opened. -
Reading Sensors (Gas & Temperature): This is done using the task (
taskReadSensors(void *pv )
). It reads the gas level and temperature from the sensors. The gas level is measured by a potentiometer and the temperature is measured by the temperature sensor LM35. This task runs in Non-Blocking mode, which means that it will not block the main task. This is because it uses the ADC in the Non-Blocking mode (ADC_SetNotification(void)
). TheADC_SetNotification(void)
is called by the ADC ISR, and it only gives the semaphore to the taskReadSensors() to read the ADC registers.taskReadSensors(void *pv )
: will wait for the semaphore to be given by the ADC ISR.This task reads one sensor at a time, and when it reads the sensor, it will update the value of the specific sensor, then swap to the next sensor, and repeat this process.
-
Control Gas Level: This is done using the task (
taskControlGasLevel(void *pv )
). This task is responsible for controlling the gas level. It checks if the gas level is above the threshold and if it is:- Above: Open the window, and raise the flag to alert the user (buzzer).
- Below: Close the window, and downs the flag of the alert.
The gas level is read from the ADC using a potentiometer. It is converted to a percentage of the full scale.
-
Control Temperature: This is done using the task (
taskControlTemperature(void *pv )
). This task is responsible for controlling the temperature. It checks if the temperature is above the threshold and if it is:- Above: Open the fan.
- Below: Stop the fan.
Temperature is measured using the LM35 sensor. The LM35 sensor is connected to the ADC. The sensor gives 10mV for every degree Celsius. So, you can measure the temperature in degrees Celsius by dividing the ADC voltage value by 10mV.
-
Display System State On the LCD: This is done using the task (
taskDisplaySystemState(void *pv )
). This task is responsible for displaying the system's data. It displays:- The temperature.
- The door status.
- The fire alarm status.
- The door security status.
The most insteresting files for us are:
-
code/main.c: Contains main function, tasks implementations, functions used by either main or tasks.
-
code/main.h: Contains prototypes of tasks and functions used in main.c.
-
code/main_cfg.: Contains system configurations such as:
- Critical values of gas and temperature sensors,
- Fire, password, buzzer, and door flags,
- etc
-
code/main_cfg.h: Contains typedefs and macros definitions used inside code/main_cfg.c and code/main.c
To develop the project, you need to:
- YOU MUST HAVE eclipse SDK installed on your computer.
- Open the code directory.
- Click twice on .cproject file.
- It will open with eclipse SDK.
- Enjoy the development.
- You can build the project by clicking on CTRL+B key on keyboard.
NOTE: The code is documented as much as possible. Hope you will understand the code.
To simulate the project, you need to:
- YOU MUST HAVE Proteus8.11 installed on your computer.
- Open the simulation directory.
- Click twice on simulation.pdsprj file.
- It will open with Proteus8.11.
- The simulation works as the following:
- Enjoy the simulation.
- To stop the simulation: Press twice on ESC key from the keyboard.
NOTE: Click on the images below to start the animation.
The project is documented using the great doxygen application. There are 2 ways to see the documentation, inside the docs directory either:
- Open the docs/html/index.html file.
- Open the docs/code_documentation.pdf file.
To generate documentation:
- YOU MUST HAVE DOXYGEN AND MAKE INSTALLED ON YOUR COMPUTER.
- From the home directory of the project (smart-home), open the command prompt in your OS (cmd for Windows, bash for linux, ...)
- Run the following command:
make -f doxygen.mk all
- The documentation will be generated in the docs directory.
NOTE: the file doxygen.mk is configured to run on Windows OS. If you want to run it on Linux OS, you need to change the configurations by opening the file and search for the section:
ENVIRONMENT VARIABLES
and change each variable value depending on the OS you are using. Options are given in the comment before each variable. For example, to change the Shell name:
# Shell of the OS, Options are: bash for Linux, sh for MacOS, cmd for Windows
SHELL = cmd
Options for shell are:
- bash for Linux
- sh for MacOS
- cmd for Windows
This project will be always improved this project. So, if you have any suggestion, create an issue here and I will appreciate it.
If you want to contribute to the project, you can:
- Fork the project on your GitHub account.
- Develop the project on your own.
- Send a pull request to the project on GitHub.
- I will review your pull request and add it to the project.
All DOCUMENTS inside this work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
All SOURCE codes & BINARIES are licensed under Mit License.
All credits and external sources are listed inside the page and inside this repo, references themselves.