SKEE1103: EMBEDDED SYSTEMS GROUP
PROJECT REPORT
PROJECT TITLE: Multi-Functional Smart Home Automation and Security System
COURSE CODE: SKEE1103
PLATFORM: Arduino Uno (ATmega328P Microcontroller)
PROGRAMMING LANGUAGE: Embedded C
EXECUTIVE SUMMARY
This report details the engineering design, physical assembly, and software logic for a smart
home automation and security prototype. Designed to fulfill the SKEE1103 project requirements,
the system uses an Arduino Uno to process three input peripherals—a DHT22
temperature/humidity sensor, an HC-SR04 ultrasonic sensor, and a rotary potentiometer. It
drives multiple outputs, including a 16x2 I2C LCD, an active piezo buzzer, a multi-LED status
array, and a 5V DC cooling fan.
To keep the system responsive, we programmed a non-blocking Finite State Machine (FSM) in
C. Users can cycle through three distinct operational modes using a debounced push button:
● Mode 1 (Climate Control): Monitors ambient temperature and automatically triggers
active cooling and a localized alarm if the temperature exceeds 37.0°C.
● Mode 2 (Perimeter Security): Functions as a proximity tripwire, sounding an intrusion
alarm when an object breaches a 20.0 cm boundary.
● Mode 3 (Analog Dimmer): Bypasses the sensors to map continuous potentiometer
inputs to a variable PWM duty cycle, allowing for manual lighting control.
We housed the entire circuit inside a custom-cut, dual-compartment enclosure (repurposed from
a Puma shoebox) to ensure stable wiring and a clean user interface. The result is a practical,
scalable prototype that demonstrates core embedded systems concepts.
1. INTRODUCTION
As home automation becomes increasingly common, reliable embedded systems are required
to process environmental data, user inputs, and security threats simultaneously. The challenge
is handling all these tasks without system lag.
This project demonstrates a localized smart home ecosystem programmed in Embedded C on
the ATmega328P. We focused heavily on software architecture—specifically, isolating functions
into a state machine and avoiding blocking functions like delay()—to ensure the CPU remains
free to poll security sensors and read tactile inputs instantly. The final prototype effectively
balances automated environmental control, security monitoring, and analog user inputs.
2. PROJECT OBJECTIVES
To meet the SKEE1103 technical guidelines, this project achieved the following milestones:
1. Multi-Input Integration: Interfaced digital sensors, an analog transducer, and tactile
buttons to feed data into the microcontroller.
2. Multi-Output Actuation: Programmed the system to drive visual interfaces (LCD,
LEDs), sound transducers (buzzer), and mechanical loads (DC motor).
3. Structured Enclosure: Transitioned from a raw breadboard circuit to a self-contained,
deployable consumer product model with an exposed front panel.
4. Finite State Firmware: Engineered a bug-free, non-blocking C program that seamlessly
shifts peripheral roles based on the active state, avoiding memory leaks or floating-pin
read errors.
3. HARDWARE ARCHITECTURE & CIRCUITRY
The Arduino Uno serves as the central processing unit. Our hardware layout was designed to
prioritize accurate sensor placement while isolating inductive loads (like the DC fan) to prevent
voltage spikes from resetting the microcontroller.
3.1 Hardware Component Mapping
The table below outlines our compliance with the course hardware constraints, mapping each
peripheral to its specific pin and function.
Classification
Hardware
Component
Pin
Assignment
Role / Operational
Description
Input 1
DHT22 Sensor
Pin 12 (Digital
I/O)
Measures ambient
temperature via a
single-bus digital protocol.
Input 2
HC-SR04
Ultrasonic
Trig: 2, Echo: 3
Emits/receives acoustic
waves for proximity
detection.
Input 3
Rotary
Potentiometer
Pin A0 (Analog
In)
Adjustable voltage divider
feeding 0 V to 5 V to the
ADC.
Input 4
Mode Button
Pin 7 (Input
Pull-up)
Tactile momentary switch
to cycle the active FSM
state.
Input 5
Fan Toggle
Button
Pin 8 (Input
Pull-up)
Tactile switch to manually
override the cooling fan in
Mode 1.
Output 1
I2C LCD (16x2)
SDA: A4, SCL:
A5
Displays real-time
parameters, status, and
alerts.
Output 2
Green Alert LED
Pin 4 (Digital
Out)
Indicates "System Normal"
or "Secure Perimeter".
Output 3
Red Alert LED
Pin 5 (Digital
Out)
High-visibility flashing
hazard beacon during
alarms.
Output 4
Blue Status LED
Pin 6 (Digital
Out)
Visual indicator
representing the active
operating mode.
Output 5
PWM LED
(Dimmer)
Pin 9 (PWM
Out)
Brightness-modulated LED
controlled by the
potentiometer.
Output 6
Active Piezo
Buzzer
Pin 10 (PWM
Out)
Generates dynamic alert
tones (1800 Hz and 2500
Hz).
Output 7
5V DC Cooling
Fan
Pin 11 (Digital
Out)
Mechanical actuator for
localized active cooling.
4. DESIGN AND PHYSICAL CONSTRUCTION
Rather than submitting a messy breadboard, we prioritized physical integration. The system is
mounted inside a robust enclosure, securing internal wires while presenting a clean, interactive
front panel for the user.
Plaintext
+-------------------------------------------------------+
|
[PUMA LOGO]
| <- Top Cover
+-------------------------------------------------------+
|
|
|()
(B) [DHT22]
(G/R)
[HC-SR04] | <- Front Panel
| Pot. Blue
Temp
LEDs
Ultrasonic |
| Dial LED
Sensor Indicators Sensor |
+-------------------------------------------------------+
4.1 Internal Compartmentalization and Wiring
● The Breadboard Matrix: We used a dual-breadboard bus structure to manage wire
routing. This allows us to distribute clean +5 V and GND reference lines directly from the
Arduino, eliminating floating voltages.
● Power Isolation: We included an independent rechargeable battery pack. By isolating
power, we ensured that high-current draws from the inductive DC fan motor do not
trigger a brown-out reset on the ATmega328P.
● Cable Management: All internal jumper wires are routed in a low-profile loom to avoid
physically interfering with the panel-mounted sensors.
4.2 External User Interface (Front Control Panel)
We precision-cut the front wall of the enclosure to expose the necessary interactive
components:
1. Potentiometer Dial: Mounted on the far left for easy analog tuning.
2. DHT22 Ventilation Port: Positioned centrally to allow unimpeded ambient air circulation
for accurate thermal readings.
3. Bi-Color Indicator Port: Houses the Green and Red LEDs for immediate visual status
checks.
4. Acoustic Transceiver Windows: The HC-SR04 transmitter and receiver cylinders sit
flush against the cardboard. This prevents the acoustic waves from clipping the edges of
the box and scattering.
5. EMBEDDED SOFTWARE IMPLEMENTATION
The core of the software is its non-blocking execution loop. Relying on an FSM ensures that
state transitions are instantaneous and that old states are completely cleared out upon
switching.
5.1 Mathematical Algorithms in Software
Ultrasonic Distance Calculation
To measure distance, the Arduino sends a 10 µs trigger pulse to the HC-SR04. The sensor
emits an ultrasound wave, which bounces off an object and returns. The time ($t$) of this round
trip is recorded in microseconds. Using the speed of sound in air (approximately 340 m/s or
0.034 cm/µs), the distance is calculated as:
$$d = \frac{t \times 0.034}{2}$$
Note: We divide by 2 because $t$ represents the total time for the wave to travel out and back.
Potentiometer Voltage Mapping and PWM Generation
The potentiometer sweeps a continuous analog voltage ($V_{\text{in}}$) between 0 V and 5 V.
The microcontroller's internal 10-bit Successive Approximation ADC converts this into an integer
between 0 and 1023:
$$\text{ADC Reading} = \left\lfloor \frac{V_{\text{in}}}{5.0} \times 1023 \right\rfloor$$
To control the brightness of the Blue LED, this 10-bit value must be scaled down to an 8-bit
PWM duty cycle ($D$), ranging from 0 to 255:
$$D = \left\lfloor \frac{\text{ADC Reading}}{1023} \times 255 \right\rfloor$$
Writing this value via analogWrite() adjusts the average voltage delivered to the LED:
$$V_{\text{avg}} = \frac{D}{255} \times 5.0$$
For better user feedback, we also mapped the ADC reading to a simple percentage ($P$)
displayed on the LCD:
$$P = \left\lfloor \frac{\text{ADC Reading}}{1023} \times 100 \right\rfloor$$
6. OPERATIONAL SYSTEM MODES
Plaintext
+---------------------------------------------+
|
Main Loop
|
+---------------------------------------------+
|
[Read Pin 7 Button]
|
Is Button Pressed (Debounced)?
/ \
YES NO
/
\
[Increment Mode] [Keep Current Mode]
[Reset Actuators]
|
v
Check Mode Value
/
|
\
/
|
\
v
v
v
MODE 1 MODE 2 MODE 3
(Climate) (Security) (Dimmer)
6.1 Mode 1: Environmental Climate Control
● Objective: Prevent overheating by automating localized cooling and signaling
high-temperature alarms.
● Logic: The system polls the DHT22. If the temperature is safe (T ≤ 37.0°C), the Green
LED stays on. The user can manually toggle the fan via Pin 8. If the temperature spikes
(T > 37.0°C), the system overrides manual control. The fan is forced HIGH, the Green
LED shuts off, the Red LED flashes, the buzzer emits a steady 1800 Hz tone, and the
LCD warns: HIGH TEMP!.
6.2 Mode 2: Proximity Perimeter Security
● Objective: Act as an intrusion detection system.
● Logic: The HC-SR04 scans the perimeter. To prevent the LCD from flickering constantly
due to micro-fluctuations, we programmed the screen to update only if the distance
changes by more than 1.0 cm. While the area is clear (d ≥ 20.0 cm), the screen reads
System Secure with the Green LED on. If an object breaches the boundary (d < 20.0
cm), a sharp 2500 Hz alarm triggers, the Red LED flashes, and the LCD displays !!
INTRUDER !!.
6.3 Mode 3: Manual Analog Dimming
● Objective: Provide direct analog control over lighting.
● Logic: Entering this mode disables all automatic security and climate alarms. The
Arduino reads the Pin A0 potentiometer voltage and outputs a proportional PWM signal
to Pin 9, dimming the LED smoothly. The LCD displays the brightness dynamically from
0% to 100%.
7. RESULTS AND DISCUSSION
7.1 System Responsiveness and Calibration
During testing, the push-button state-switching proved to be highly responsive. By implementing
a 50 ms software debounce window, we entirely eliminated contact bounce, preventing
accidental double-skips between modes.
● Climate Testing: We tested Mode 1 using localized warm air. Exactly at 37.1°C, the
system successfully forced the fan on and triggered the alarm within a single processor
cycle.
● Security Calibration: The ultrasonic sensor maintained accuracy between 2 cm and
400 cm. The 20.0 cm boundary trigger was consistent, and our 1.0 cm delta-update logic
successfully stopped the LCD from flickering.
● Dimmer Control: The ADC-to-PWM math functioned perfectly, resulting in smooth,
flicker-free dimming across the entire physical rotation of the dial.
7.2 Safety Features & Code Robustness
We engineered several safeguards into the firmware to protect the hardware:
● Sensor Error Recovery: If the DHT22 data line gets disconnected or fails, it returns a
"Not-a-Number" (NaN) value. Instead of letting this crash the system or trigger false
alarms, our code catches the NaN, prints Error on the LCD, and defaults the fan to a
safe OFF state.
● Actuator Protection: We wrote a resetActuators() function that fires during every state
transition. This ensures that a ringing buzzer or spinning fan from Mode 1 immediately
shuts off when switching to Mode 2, preventing phantom power drains.
8. CONCLUSION AND FUTURE WORK
This Multi-Functional Smart Home Automation System successfully fulfills the SKEE1103 Group
Project requirements. By relying on a software-defined state machine, we proved that multiple
inputs and outputs can be handled concurrently on an 8-bit microcontroller without lag or
overlapping bugs. The physical shoebox enclosure brings the circuit together into a neat,
deployable prototype.
Future Recommendations
If this project were scaled up for commercial deployment, we would recommend:
1. EEPROM Integration: Saving user override preferences in the ATmega328P’s
non-volatile memory so settings persist after a power outage.
2. IoT Connectivity: Adding an ESP8266 Wi-Fi module to push real-time threshold alerts
to a mobile dashboard.
3. AC Mains Switching: Swapping the 5V DC fan for an optically isolated relay, allowing
the microcontroller to safely operate standard 240V AC home appliances.
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )