I am a student at HoWest Kortrijk who studies New Media and Communication Technology(NMCT)
For our module Project we had to make an raspberry or Arduino based prototype who collects data via sensors and stores this in a MySQL database.
In this instructable I will guide you through each step so you can recreate this prototype for yourself.
Step 1: Materials: What Do You Need
- HC-SR505 mini PIR Motion sensor
- MCP 3008
- 5mm LDR
- Jumper Wires M/M
- Raspberry Pi 3
- Servo Motor
- Wood & Tools
All of these items you can buy at your local shop or on Ali express, amazon, kiwi electronics,... .
A detailed list of parts with a link to the shops is given below in the BOM.
Step 2: Wiring
For the wiring i used Fritzing to have a nice overview of how my wiring should be done. You can find the file below.If you need to save GPIO pins You can hook up the 2 PIR sensors to the MCP3008.
I didn't do that because i am not so familiar to the MCP3008 and the PIR Sensor works perfectly fine without the MCP 3008.
As you can see on the second photograph everything fits nicely in the housing.
Step 3: Database Using MySQL
One of the major task we had to implement in this project is the connection with a MySQL database.
Every time a light goes on or a door is opened via the PIR sensor this is registered and written to the database.
below you can find a .xml file where you have a overview of how the database is setup.
Install MySQL database on the Raspberry Pi
Start with checking if you have the latest software with this command:
sudo apt-get update &&sudo apt-get upgrade
install MySQL server:
sudo apt-get install mysql-server
install the MySQL Client:
sudo apt-get install mysql-client
For the connection you need to create a user. This can be done if you follow the following screenshot:
When you've done this you can use the dump file i included and use the database.You still have to install the connector in your raspberry with the following command.
sudo apt-get install python3-mysql.connector
Step 4: Coding
you can download the code via Github:
The code for the sensors is included in this project and can be found with the names
- MotionGarage(Pir Sensor1 and Servo1)
- MotionDeur(Pir Sensor2 and Servo2
- TempLicht(Temperature and light sensor)
- LED(Led + PushButton)
Don't forget to change the DBClass.py to your settings so it can connect with your created database and user.
Step 5: Housing
For the housing i used a replica of the well known Simpson house. It is realy handy because the door and garage door are hinged so that was a little bit easier to use with my servo's.
I included a ZIP file with the CAD file so you can laser cut your own house.
I used four 3x400x650mm plywood plates, that was the maximum dimension the laser cut machine could handle.
Once this was lasered out is was really easy to put all the pieces together as you have a nice how-to pdf file(also included). I used normal wood glue who doesn't expand during it dries.
when you are finished with puzzling all you have to do is build al your sensors in the house and you are set to go .
I Hope you all enjoy this project as much as i did and wish you al the best with it.
We have a be nice policy.
Please be positive and constructive.