TASK 8.2 SIT 210
Published: 2021-06-07 13:59:44

***Important watch the tutorials linked at the bottom to understand the hardware and process to make IFTTT applet
SIT 210







11.2 Project Artefact

Intrusion System

by: Ekam Behl







1.	Overview:

Background:
The problem is based on a real-life issue. In 2019 there were 11,775 more cases (as compared to previous year) of robbery in Australia, increasing by 16% from the previous year. This was the fourth consecutive annual increase and the highest recorded number of victims since 2012.
Other estimates show that 2.4% of all Australian households experienced a break in i.e. a whopping 231,000 cases in just one year. As the number of cases are on rise, there arises a need to protect the house from the such break-ins.

Problem statement:
There are a lot of industry options available. They cost a huge sum of money and are not reliable and use one sensor or they just use a keypad/camera which in today’s high-tech world is not enough.
To provide with a cheap alternative/ solution, I have built a RPi project which provides with the best motion sensing and has excellent scalability option putting all the best parts of industry solutions into one cheap but effective product.
Requirements:
•	Software requirements: IFTTT website, Raspberry Pi OS, IDE to write the code (Preferably Thonny IDE), VNC viewer (in case of no screen available), Python (2.8 and above)
•	Hardware requirements: Jumper Wires (Male to female), PIR motion sensor, Raspberry Pi 3 or higher, LED, breadboard, Power Source for the Raspberry Pi, Buzzer. resistor






2.	Design Principles:


 
KEEP IT SIMPLE! After seeing the industry solutions as well as other students in this unit. While giving the feedbacks I realised they had overused sensors which really didn’t fit the project. That’s why I used only those sensors which made sense in this project.
Using PIR instead of the supplied ultrasonic sensor was also a crucial choice as Using ultrasonic sensor would have increased complexity for no reason
DRY (Don’t Repeat Yourself): This principle states that the code must be reusable. I tried making functions where possible to minimise the re occurrence of the code.
Connectivity and ease of use: This principle involves the use of IFFFT to send mails to the owner to let them know if any motion was detected or not.                                      	 The ability to just plug the RaspberryPi to a socket. It also brings in the portability of the RaspberryPi making it one of the smallest computers powering our system.





3.	Prototype Architecture:
Hardware Architecture:
I used raspberry Pi, PIR motion sensor 
•	PIR motion sensor has three PINS: VCC, GND, OUT.
I connected the VCC pin to 5v (as its specification says so), GND pin to ground pin and OUT pin to any GPIO pin on RaspberryPi.
•	The Buzzer has two ends i.e. positive and negative end. The positive end needs to be connected to a GPIO Pin and the negative end needs to be connected to a GND Pin on the RaspberryPi.
•	LED (Light emitting diode) needs to be connected like the buzzer with negative end connected to GND pin and positive end connected to GPIO pin via a resistor to make sure that the bulb doesn’t explode. 
•	The all would be connected via male to female wires with male side connected to the sensors via the breadboard and female side connected to the RaspberryPi pins
•	The breadboard houses all the components and allows for easy setup.
•	To power the raspberry Pi an adaptor of type usb B.

Software architecture and How they were used:
CODE:
•	First, we need Python IDE on raspberry Pi to write all our code.
•	First, I setup all the pins via GPIO.setup command and set PIR motion sensor as an input pin and set the others (LED AND BUZZERS) as an output pin
•	After that I initialised the mode as BCM which would then allow me to use RaspberryPi pins.
•	Then I made a continuous loop to keep on checking if any motion which is detected.
•	If any motion is detected LED turns on (using GPIO.output(LED, GPIO.HIGH))
•	 The buzzer also turns on if any motion is detected raising an alarm (USING GPIO.output(buzzer, GPIO.HIGH))
•	It also sends a request TO IFTTT to do actions based on events .IT sends a mail to the owner if a motion is detected using command
(r = requests. Post ('https://maker.ifttt.com/trigger/motion_detected/with/key/dm9_XXXXXXXXXXXX, params={"value1":"none","value2":"none","value3":"none"}))
4.	Prototype Code:
https://github.com/EkamBehl/Task11.2.git


5.	Testing the system:
To test the system, I did a lot of things which are as follows:
•	First, I tried to swing the door (which had motion sensor near it) as fast as I could and checked if the sensor sensed any motion or not. To tweak this problem the best way was to place the sensor vertical to the door such that it senses a change irrespective of the speed.
•	The next thing to test was to check if double motion of the door is captured or not because if we use it in a kid’s room which a parent comes to check we don’t need to turn the buzzer on this case. It would still register an intrusion and send a mail, but it shouldn’t do so if a third motion is detected in just an interval of 3 seconds.
•	I tested it over 10 times and ensured that I get a mail every time a motion is registered and ensured that the buzzer as well as light turn on every time the motion is sensed.

6.	User Manual:
Hardware:
 
#PINS Number on RASPBERRY PI CAN BE SEEN FROM TASK 5.1 TASK Sheet
•	Take a breadboard and connect a buzzer to it using a male to female jumper wire connect the positive end (bigger end) to the GPIO 3 pin on the raspberryPI. connect negative end to the GND pin on raspberry pi
•	Take a pir motion sensor and connect VCC pin 5.5V pin ,connect GND to GND pin ,connect the last pin(out pin) to GPIO 14.
•	Take an LED connect one end(smaller end ) to GND and larger end to the GPIO pin 23.
                  SOFTWARE:
•	Open raspberry Pi and open Thonny IDE and put the github code in it.
•	Open IFTTT website and make a new applet and call the event as motion_detected. Click on explore and search webhook and click on documentation and copy your “key” paste the key in r=requests code on github where it says to paste your key.
•	Make sure that the event name in matches the event name given in your webhook. 
•	In then that select gmail and then select send yourself a mail to send one regarding the intrusion.


7.	   Conclusion:
It was a wonderful experience as it required us to make our own project from the whole setup to the coding. It involved such great concepts of using different sensors to make the best possible project. I made a project using PIR motion sensor and it turned out to be fully functional. It felt great to have made a project on my own .I faced quite some issues . At first I was going to use ultrasonic sensor but I soon realised that I really don’t need to calculate the distance between the intruder and the sensor. So I had to learn to use the PIR sensor. I had limited knowledge about GPIO library and had to learn about all the required functions of it.
I also had to order a pir motion sensor which made it quite difficult to do the project as I was low on money due to Covid.
If was given a second chance to do the task gain provided my financial condition is better I would have added a few extra sensors which would give the ability to click a photo of the intruder.
I would have also made an app which stores all the information and updates about the system and would have provided the functionality to call the police with just a click.




LINK TO TUTORIALS: How to make the applet:https://youtu.be/q00tvRDlgyA
How to make the hardware for the project:https://youtu.be/R2STWT91a_E
How the project will work:https://youtu.be/el4c-S_zjkA