Monday, October 2, 2023

Wireless Security System Using PIR Sensors

Ashutosh M. Bhatt is M.Tech in embedded systems. Currently, he is lecturer of electronics and radio engineering at Government Polytechnic, Jamnagar, Gujarat

- Advertisement -

Serial data output from 434 RF Rx module is given to data input pin 14 of HT12D decoder.
Address pins A0 through A7 of HT12D are connected to ground to set same address 00 (0000 0000b) as encoder. LED5 is connected to VT (valid transmission) pin, which blinks to indicate that data is received. The same VT output is inverted using T5 and given to external interrupt pin EX1 (pin 13) of AT89S52. Data output pins D8 through D11 are connected to port pins P1.0 through P1.3, respectively.

LCD1 data pins D0 through D7 are connected to port P0 of IC6. Control pins RS and EN are connected to port pins P2.0 and P2.1 of IC6, respectively. Pin R/W is connected to ground to enable LCD1 write. Preset VR1 is connected to pin 3 to vary LCD1 brightness. Backlight LED pins 15 and 16 are connected to +5V via R23 and ground, respectively, to turn on LCD1 backlight.

There are two multivibrator circuits. Both are built using IC NE555 and configured in astable mode. Reset pin 4 of both multi-vibrators are controlled by MCU port pins P2.2 and P2.3.

- Advertisement -

A 12MHz crystal is connected to crystal pins 18 and 19 of IC6 along with two 33pF capacitors (C2 and C3). This circuitry provides clock signal to the MCU for its internal operations. Capacitor C1 in parallel with resistor R16 and push button S1 are connected to RST pin 9 to provide manual reset to the MCU.

When any sensor detects motion, data is transmitted through RF Tx. This is received and demodulated by RF Rx module. This data is sent to RF decoder HT12D (IC5), which detects valid address indicated through the blinking of LED5. Then, the decoder latches the data, which is made available across data pins D8 through D11 of IC5. When valid address is received, VT pin of IC5 goes high and the MCU gets an interrupt signal. It gets bit pattern on port P1. As per data bits, any one pin (out of four) will be low and rest will be high.

Based on which pin is low, the MCU identifies the sensor that detects motion and indicates the direction of the intrusion. This is listed in Table II.

As per Table II, the MCU immediately decides and displays the message “intruder detected from xxxx side” on LCD1. It also enables both multivibrators by applying high input on RST pin.

The multivibrator (IC7) that flashes LED6 has a flashing rate of 2Hz. Component values for R19, R20 and C7 are chosen in a way that output frequency is around 2Hz.

Another multivibrator (IC8) generates 1kHz audio tone as siren through speaker (LS1). Component values for R21, R22 and C5 are chosen in a way that output frequency is around 1kHz.

When sensor PS1 (or any sensor) detects motion, its output remains high for around five to ten seconds because of a slower response. The siren sounds and LED6 continues flashing for about ten seconds. The message on LCD1 shows the side where motion is detected.

After sensor output becomes stable (low), both the siren and LED6 turn off.

Software program for Wireless Security System

Complete system operation is carried out based on the program embedded into the internal flash of AT89S52. The program performs the following tasks:

1. Decides where motion is detected

2. Displays warning and other messages on LCD1

3. Displays side where motion is detected

4. Flashes LED6 and turns on siren when motion is detected

The program is written in C language for 8051 family of controllers. It is compiled in Keil IDE software. The complete program is a combination of many different functions, including:

lcd_delay() generates delay for the LCD to get ready to accept a new command or data byte
lcd_send_cmd() sends command byte to LCD
lcd_send_data() sends character to be displayed on LCD
lcd_display_string() displays various strings and messages on LCD
lcd_init() configures and initialises LCD
ext_int() is an interrupt sub-routine function that gets input from port P1
delay_10s() generates approximately 10-sec delay
main() compares digital input of P1 and detects which port pin is low. It also displays on LCD1 the side of motion or intrusion detection

Download Source Folder

Construction and testing

An actual-size PCB layout for the transmitter section of the wireless security system is shown in Fig. 5 and its components layout in Fig. 6.

PCB layout of transmitter circuits
Fig. 5: PCB layout of transmitter circuits
Components layout for transmitter PCBs
Fig. 6: Components layout for transmitter PCBs

Cut the PCB across the dotted lines for four transmitter sets. Enclose each transmitter section in separate boxes, including 6V battery. Connect the four PIR sensors in each transmitter PCB assembly. Install these at the four locations of your home or office.

An actual-size PCB layout of the receiver unit is shown in Fig. 7 and its components layout in Fig. 8.

PCB layout of receiver unit
Fig. 7: PCB layout of receiver unit
Components layout for receiver PCB
Fig. 8: Components layout for receiver PCB

Download PCB and component layout PDFs: click here

After assembling the circuits on the PCBs, if everything is correct, burn the program (pir.hex) into the MCU using a suitable programmer. Insert AT89S52 on IC base soldered on the PCB. Enclose the PCB, switch and connectors in a suitable box. Connect 5V to operate the circuit. Your circuit is now ready to use.


 

17 COMMENTS

SHARE YOUR THOUGHTS & COMMENTS

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components

Calculators