Introduction: Smart Security System
Do you ever feel unsafe in your own home, or do you need to protect your company? Maybe you could make a security system so all of these problems gets solved. In this instructable i tell you how. I mounted all the parts on a wooden plank for demonstration purposes, you should mount it where you need it (the arduino part at the wall where you can reach it, the main board somewhere out of direct range, the siren and the strobe where you want it and the sensors in the rooms you want to protect.
To follow this instructable you should have knowledge about:
- raspberry pi
And if you want to change the code:
Step 1: BOM (what You Need)
In this list is everything you need to make the security system, most of the things you can buy on aliexpress but some things like the adafruit pn532n and the pi you should buy elsewhere. The key safe you could buy in a local hardware store.
Step 2: Schematic
This is the schematic of the project, there are 2 parts: the part you badge has an rfid reader and a i2c lcd, there's also a buzzer in here. The other part is the mainboard, this has headers to connect the sensors (its capable for a max of 10 sensors), a 2 relay module to switch the strobe and the siren and 2 pins to connect a tamper switch, if you have one: connect it, I had one laying around but i dont know where you could buy it. On the mainboard there are also pins for a pan tilt module but i havent implemented it yet. I designed PCB's, i ordered them by JLCPCB, they are cheap and they work like expected.
Step 3: Solder the Pcb's
Its time to solder the pcb's, note that your arduino pcb may look diffirent cause i have an old version of it. In no case solder the buttons in, cause you would short your pi if you press them, these buttons were only for testing purposes and aren't essential for the system
Step 4: Lasercutting
I had my case lasercuted at school (Howest kortrijk Belgium), you could order it at ponoko, the file includes the arduino case, the baseplate for the main board(you should redesign this cause you probably gonna have another key safe) and some housings for the pir sensors.
Step 5: Assembling the Case (arduino)
Now were gonna asseble the arduino case, its like a puzzle, you have to put all pieces together, you cant do anything realy wrong, just note the orientation of the pieces, i used a bit of tec7 in all corners to hold it together, while the glue was drying i put a rubber band around it.
in the same way assemble the sensor housings (if you want them)
Step 6: Mount Everything in the Key Safe
i lasercutted a piece where i mounted everything on top by drilling 3mm holes and using nylon spacers, i drilled also much holes in the key safe and used cable grommets to protect the cables from the sharp edges.
Step 7: Mounting the Arduino, Rfid Reader and the Lcd
Mount the rfid reader like shown in the picture, use m3 nuts as a spacer between the lid and the reader, do the same for the lcd(make sure its the right way up).
Mount the arduino on a location you prefer, use jumper cables or make a cable with shrink terminals to connect everything.
Step 8: Setting Up the Pi
Write a fresh raspbian image to the sd card, boot up the pi, connect over ssh (username=pi, password=raspberry, change it asap)
sudo apt install -y python3-venv python3-pip python3-mysqldb mariadb-server uwsgi nginx uwsgi-plugin-python3
now we gonna activate a Virtual environment
python3 -m pip install --upgrade pip setuptools wheel virtualenv mkdir project1 && cd project1 python3 -m venv --system-site-packages env source env/bin/activate python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib
Step 9: Building the Database
create 3 database-users: project1-web, project1-sensor and project1-admin with unique passwords
create a database called project1
grant all privileges to the admin and SELECT, INSERT, UPDATE and DELETE to the other 2 users
import the sql file onto the pi
Step 10: Uploading the Code
git clone github.com/NMCT-S2-Project-I/project-i-emielvansteenbrugge
fill in your database credentials in the code (in sensor.py at line 47 and 64, and in web.py at line 41)
to add a website user that can't be removed: at the bottom of the code there's a line commented out: adduser(root, your password). Fill in your password of choice and run the code afterwards comment out the line and remove the password
upload the code to your arduino