Burglar/Intruder Alarm Using Wizfi-360 EVB Pico
The burglar alarm system uses a motion sensor (PIR Sensor) to detect intruders.
The system will flash the light and beep.
Burglar Alarm Using WizFi 360 EVB Pico
Introduction:-
Microcontrollers are often used in commercial security products such as burglar alarms.
Components -
- WizFi360 EVB Pico
- 330 ohm Resistor
- Buzzer
- Jumper Wires
- IR Sensor
- LED
Connections and Working -
Connect one of the breadboard’s ground rails to another GND pin on Pico. For a flashing light, insert an LED into the breadboard, its legs either side of the central divide. The shorter leg (cathode) should then be connected to the same ground rail. The longer leg (anode) of the LED needs to be connected to the GP15 pin via a resistor to limit the amount of electric current passing through it, which might otherwise damage the LED or the Pico.
On the breadboard, insert the Pico’s male pin headers into the holes at one end. Push it down firmly to ensure good connections – it should fit snugly. Then use female-to-male jumper wires to connect the PIR sensor to it: the VCC pin should be wired to Pico’s 5V VBUS, digital OUT to GP28, and GND to a GND pin (e.g, pin 3), as shown in the wiring diagram below.
Here, import the machine and utime libraries at the top. Next, set up objects for the PIR, LED, and buzzer – connected to GP28, GP15, and GP14 pins respectively.
At the bottom of the code, an IRQ (interrupt request) is set up to trigger the pir_handler function as soon as a signal is detected on the input pin (GP28) from the PIR sensor.
If the alarm is going off too easily, or not at all, you may need to adjust the sensitivity of the PIR sensor. The HC-SR501 has two plastic screws – usually labelled Sx and Tx – attached to two tiny potentiometers to adjust its settings.
Circuit Diagram:-
Code -
import machine
import utime
pir = machine.Pin(28, machine.Pin.IN, machine.Pin.PULL_DOWN)
led = machine.Pin(15, machine.Pin.OUT)
buzzer = machine.Pin(14, machine.Pin.OUT)
def pir_handler(pin):
utime.sleep_ms(100)
if pin.value():
print("Motion detected. Intruder alert!")
for i in range(50):
led.toggle()
buzzer.toggle()
utime.sleep_ms(100)
pir.irq(trigger=machine.Pin.IRQ_RISING, handler=pir_handler)
Make your own mobile intruder -
Once your intruder alarm is working to your satisfaction, you may well want to move it away from your computer. By saving the program as main.py, you can then disconnect it from the computer and connect a standard mobile power bank to its micro-USB port.