You are on page 1of 12

Home Security System

Introduction

In these days it’s most important to have a home security system to protect your family and
belongings, but you may be hearing a lot of conflicting information on what you need and
don't need.

There are lots of options out there, and electronics dealers and home security specialists
always seem to want to sell you the fanciest, most detailed system. But is all that necessary?
In this project we will build a home security system ( burgular alarm ) that has a special
feature which is dialing the owner when the alarm is activated .

There are two options out there, dialing through the land line telephone and the use of mobile
telephone , we have choosed the mobile telephone as a safe way of communication as the
intruder can’t cut the telephone wires in this case.

Also we have choosed the most practical type of sensors which is the magnetic type that can
be fixed easily on the doors and winodws.

The system will be activated once any of these sensors are triggered , then it will turn an
audiable alarm ON, and indicated which door or window is opened through a list of LEDs.
Then call a predefined numbers stored on the mobile telephone itself.
Project components

The Magnetic sensor

When designing a security of safty system you will need a different types of sensors, the
sensors are the electronic or mechanical components that is triggered based on a certain
action, for example, you may want your system to sense if any of your doors or windows are
opened while you are away, in this case you need to have a magnetic sensor, it’s a something
like a switch and is closed or opened if you move a part of it away from it’s body

The moving part


The base unit fixed Fixed on the right
on the door itself edge of the door
Or you want to know if any person or subject is moving inside your house, in this case you
will need a sensor which can sense the movement it’s called “Moving detector” or “PIR”
“Passive Infrared”.

Another option is to sense who is moving arround the house using an Ultrasonic sensors
which acting like the Radar.

Any sensor can be used with this project, they are all different in function but have one
output , a signal sent to the main unit to tel it that there’s something wrong.

The Microcontroller board

This is the brain of this project, we have choosed one of the best microcontroller that is
widely used in the industiral, automotive and security systems.
It’s the 40-Pin Enhanced Flash Microcontrollers PIC16f877A
It’s running from a +5v supply and clocked with 4MHZ crystal oscilator

It has the following features

• Only 35 single-word instructions to learn


• All single-cycle instructions except for program branches, which are two-cycle
Operating speed: DC – 20 MHz clock input
• DC – 200 ns instruction cycle
• Up to 8K x 14 words of Flash Program Memory,
• Up to 368 x 8 bytes of Data Memory (RAM),
• Up to 256 x 8 bytes of EEPROM Data Memory

• 100,000 erase/write cycle Enhanced Flash program memory typical


• 1,000,000 erase/write cycle Data EEPROM memory typical
• Data EEPROM Retention > 40 years
Main board image :

Microcontroller
Fuse Regulator 5V

Power
in
12volts

Reset

PORTC PORTD PORTB PORTA

buzzer

LED 1 to 4 Sensor 2 Sensor 1


Mobile Socket Showing the connection connection
triggered sensor

Mobile driver
The circuit schematic
Microcontroller Code Logic

//A0 --> buzzer


//A1 --> Switch 1
//A2 --> Switch 2

unsigned short i;

void speed_dial3() {
PORTD.f1 = 1;
Delay_ms(2000);
PORTD.f1 = 0;
}

void speed_dial6() {
PORTD.f2 = 1;
Delay_ms(2000);
PORTD.f2 = 0;
}

void speed_dial9() {
PORTD.f3 = 1;
Delay_ms(2000);
PORTD.f3 = 0;
}

void Power_ON() {
PORTD.f0 = 1;
Delay_ms(2000);
PORTD.f0 = 0;
}

void clear() {
PORTD.f0 = 1;
Delay_ms(500);
PORTD.f0 = 0;
}

void alarm() {

for(i=0;i<50;i++) {
PORTA.f0 = 1;
Delay_ms(80);
PORTA.f0 = 0;
Delay_ms(80);
}
}
void beeb() {
PORTA.f0 = 1;
Delay_ms(100);
PORTA.f0 = 0;
}

void main() {

// TRISA = 0b00000110; // A0 output, A1,A2 inputs


ADCON1=0b00000110; // set All portA I/O
//ADCON1 = 0xFF;
TRISA.f0 = 0;
TRISA.f1 = 1;
TRISA.f2 = 1;
TRISB = 0; // Configure PORTC as output
PORTB = 0; // Initialize PORTC
TRISD = 0;
PORTD = 0;

beeb();
// wait a little before opening the mobile
Delay_ms(10000);

// ON trun on the mobile if it was off


Power_ON();
Delay_ms(30000); // wait until mobile startups.

while (1) {

// Check for Sensors.


while(1) {

PORTB = 0xff; // ststus leds on


Delay_ms(500);
// Security triggered
if ((PORTA.f2 == 1)||(PORTA.f1 == 1)) {
PORTB=0;
if(PORTA.f1 == 1) {
PORTB.f0 = 1;
}
if (PORTA.f2 == 1) {
PORTB.f2 = 1;
}

alarm();
break;
}
PORTB = 0; // status led off
Delay_ms(500);
}

// This is to cancel any displayed sms or missed calls


delay_ms(1000);
clear();
delay_ms(1000);

// Call the first number


speed_dial3();
Delay_ms(20000);
clear(); // hang up

Delay_ms(10000);

// call the second number


speed_dial6();
Delay_ms(20000);
clear();

Delay_ms(10000);

// call the third number


speed_dial9();
Delay_ms(20000);
clear();

// delay one minute before re checking the switches


Delay_ms(50000);
Delay_ms(10000);

} // end while

} // end main

The Buzzer ( Or any loud alarm )

In this project we have used a simple buzzer with moderate audioble sound, but in the real
case usually a loud siren is used, we can use any type of alarms that is operated with 5v
through the alarm socket socket , if a louder sound is needed we can replace the transistor
with a bigger one that can supply higher currents.

Mobile Telephone driver circuit


The idea here is how can we interface the circuit with a mobile telephone , there are many
ways to accomplish this:
Using the mobile cable and communicate throught the RS232, but this model is restricyed to
a certain type of mobiles ( almost the old mobiles ) most of the new mobiles have different
protocols like the FBUS used in Nokia phones.

In this project we came with a new easy way to interface the microcontroller with any type of
cell phones, we connect the output lines to the phone keyboard directly, in other words, we
simulate the “key press” we make the microcontroller connects the phone button terminals

We have used the speed dial feature of the cell phone, this function is found in most cell
phones, so when dialing Number1, just connect the terminals of the button 3, then button6
and finally button 9.

We used the Quad electrnoic switch IC, named MC4066 and is controlled with the PIC portD

Mobile Phone

PIC877A

1 2 3

4 5 6

7 8 9

The mobile Telephone

In this type of projects we usually choose a simple cell phone, not only to lower the cost but
mainly to be easily interfaced and to have longer battery life.

We used the Alcatel Model OT-E101, a text mode simple phone and it’s modifed to connect
wires to the buttons 3,6,9, we have choosed these buttons specifically to have a shorter wires
as they are at the phone edge.
Mobile phone

Connection to
microcontroller

Basic Operation

1. First put the simcard in the mobile phone, then put the battery
2. Adjust the date and time
3. Then trun off the mobile
4. Connect the mobile to the circuit
5. Connect the power to the circuit
6. After 10 seconds the mobile will turn on automatically
7. After 30 seconds the operation will start ( the detection mode ), in this mode the green
led will start blinking means that the system is ready.
8. Now you can pick the magnetic edge away to trigger the alarm
9. You will hear an alarm from the buzzer for about 20 seconds
10. Then the system will start calling the first Number stored in the mobile memory, then
wait for 20 seconds then hang up
11. Then it will call the second number then the third number
12. Then the System will wait 1 minute until it return to the detection mode again

To Shutdown the system, please do the following:


1. While the circuit is on, remove the mobile socket
2. Then power off the circuit by removing the power socket
3. Then power off the mobile phone.

References:

PIC16f877A datasheets
http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf

Quad Electronic Switch 4066


http://www.alldatasheet.com/datasheet-pdf/pdf/106691/MICRO-
ELECTRONICS/MMC4066.html

ping me if you have any questions

hosam_eldin@hotmail.com

You might also like