First you will need to have the following:
4x IR break beam sensor
1x Raspberry Pi
Step 1: Electric Scheme
Now you will need to make the electric scheme of the alarm system.
Fritzing is a very handy and free tool for this.
Each IR sensor will need 1 control pin and each a Ground and 5V output (Resistors are advised).
The camera module is driven by the camera interface on the raspberry itself.
The buzzer and led need a Ground and a control pin.
Step 2: Website
Now you will make a website where you load in your database and watch the camera images.
Homepage: To see the camera images.
Functions page: Here you will need to enable, disable or reset the alarm system.
Statistics page: To see all the data that is required.
The data on this page shows:
How many times the system got disabled and alarmed per day/month and month/year.
The time when the system got activated and deactivated.
Step 3: Database
Now you will need to make a database according to the ERD norm and the good cardinalities.
You first of all need to make a prestudy to have an idea on front what data you will need to have.
Now ypou make your tables on pycharm and connect all tables on the good way with foreign keys and primary keys.
The tables to get data out of it are:
Time of Enabed
Time of Disabled
Amount of Times Alarmed
Amount of Times Deactivated
Step 4: Serverside
Now we are going for the server side scripting with flask.
First of all, we will make the approutes to each page
The approute to functions & homepage doesn't need a certain function.
For the page statistics, we will make a function to catch the data that needs to be displayed on the website. This will be realized with an SQL query.
The data of: Time of Enabed, Time of Disabled, Amount of Times Alarmed, Amount of Times Deactivated, needs to be show on this statistics page.
On the page statistics itself, you will have to call the function so you can display it there.
Step 5: Programming the Sensors
First we will make a script for the camera, that will make a snapshot each 4 seconds and overwrite the previous one. Then we will put this code in an autorun script located on /etc/rc.local.
Now we make a script to sound the alarm when the IR sensor(s) get triggered. When the sensor is triggered, a alarm will sound and a light will lit up on the same time.
Code on github: https://github.com/Defqon8/Project1-NMCT
Step 6: Testing
Before we will test everything, we are first going to construct the fence.
place in each corner an IR sensor, on each side of the fence, you need to become 2 Ir sensor facing towards eachother on the exact same height so the beam is connected.
Then you will bring all the wires to the breadboard and connect them according to the fritzing model.
Now, connect the camera.
Now we can test the system, send through the code and run it, try to break the beam, does the alarm sound?
does the website work? if you can answer "yes" everywhere then you are done.