Currently, burglary remains a common problem in the homes of residents in theft-prone areas in large cities. Even though CCTV systems are installed, they sometimes fail to provide early alerts for suspicious activities by potential intruders. Conventional padlocks also carry the risk of being tampered with.
ObjectiveThe objective of creating this project is to reduce the likelihood of home burglaries and to provide dual protection for home security, particularly at the home's entry points, as the door serves as the primary and crucial access point to enter a house.
SolutionThe Double Protection System for homes is the solution offered in this project. Homeowners in this system have two keys: the first is the padlock key, and the second is the latch lock located behind the door inside the house.
- Above the front door, there is a PIR sensor: it is used to detect any motion when the system is activated or when the homeowner is away. If motion is detected, the system will sound an alarm, causing potential intruders to panic, and it will automatically activate a servo to lock the door with the slot from the inside, providing an additional layer of security.
- There is a concealed push button known only to the homeowner. When this push button is pressed, the door slot inside the house will unlock, allowing the homeowner to still open the door with the padlock key from outside the house
- Hall-effect magnetic sensor serves as a detector for whether the door is open or closed
1. Designing the Circuit Schematic 2. Creating the Power Circuit3. Developing a Double-Layer PCB Shield for PSoC6 WIFI BT4. Building the Mechanical Servo System with the Door Slot5. Testing and Coding Each Component with MicroPython6. Integration of the Software and Hardware
1. Designing the Circuit Schematic
To minimize errors during PCB layout, it is essential to create a circuit schematic to identify the pins used in the project. The pins used in this project are as follows:
- VIN (External Supply) = J17 = +5V
- Push button: P8_6
- Magnet Sensor: P10_0
- PIR Sensor: P10_1
- Servo: P9_4
- Buzzer: P8_3
2. Creating the Power Circuit
Due to the external power specifications for the PSoC6 (voltage), the voltage from a 9V battery needs to be reduced using a buck converter with the LM2596 module. The schematic is as follows:
3.Developing a Double-Layer PCB Shield
Below is the double-layer PCB I used for this project
4. Building the Mechanical Servo System with the Door Slot
After several trial and error attempts to ensure that the servo can effectively engage the door slot, the final mechanical setup looks like the diagram below:
5. Testing and Coding Each Component with MicroPython
Here, I am currently testing the Servo using PWM Pin P9_4.
codes:
from machine import PWM
import time
def deg2duty(x):
return (x - 0) * (8192 - 1638) // (180 - 0) + 1638
pwm = PWM('P9_4', freq=50) # view PWM settings
print(pwm)
while True:
time.sleep_ms(1000)
pwm.duty_u16(deg2duty(0))
print(pwm.duty_ns())
time.sleep_ms(1000)
pwm.duty_u16(deg2duty(90))
print(pwm.duty_ns())
Below is the coding and testing of the ADC data of PIR and Hall sensor
from machine import ADC, Pin
from time import sleep
adc = ADC(Pin("P10_0"))
while True:
val = adc.read_u16()
val = adc.read_u16() / 65535
analogValue = 3.3*val
print(f"The analog value obtained from connecting to a 3.3V supply is {analogValue}")
sleep(0.5)
Below is the data of PIR sensor, when the voltage is 3.299245 V, the sensor detects motion
And below is the data of S2GO_Hall_TLE4964-3M Sensor
When the analog value is 3.299245V there is no magnetic field, it means the door is open. And when the analog value voltage is about 0.12V, the door closed
6. Integration of the Software and Hardware
In this last process, I am combining the software and hardware components to ensure they work seamlessly together
Here the codes:
from machine import ADC, Pin
import time
from time import sleep
from machine import PWM
from machine import Pin
buz = Pin("P8_3") # LED pin for CY8CPROT-062-4343W
buz.init(Pin.OUT)
#buz.on()
adc = ADC(Pin("P10_1"))
#servo
def deg2duty(x):
return (x - 0) * (8192 - 1638) // (180 - 0) + 1638
pwm = PWM('P9_4', freq=50) # view PWM settings for servo
print(pwm)
#pb
pb = Pin('P8_6')
pb.init(Pin.IN)
while True:
val = adc.read_u16()
val = adc.read_u16() / 65535
analogValue = 3.3*val
print(f"The analog value obtained from connecting to a 3.3V supply is {analogValue}")
sleep(0.5)
if (analogValue > 1):
buz.off()
time.sleep_ms(1000)
pwm.duty_u16(deg2duty(90))
print(pwm.duty_ns())
else:
buz.on()
time.sleep_ms(1000)
if(pb.value() == 0): #active low
pwm.duty_u16(deg2duty(0))
print(pb.value())
ClosingWith this project, hopefully, it can inspire and assist in enhancing your home security system. This project is far from perfect and can be improved further. Thank you.
Comments