Project One
Intro
As a student Multimedia & Communication technology in Howest Kortrijk, I had to make my own project called 'ProjectOne'. This would combine all of the modules followed in the first year into one big project.
For my project I'm making a car monitor for people who do car sharing. I've been sharing a car with my mom since I got my license but we didn't know who was driving what and how many miles we were driving. I wanted to change this with my project.
Supplies
- raspberry pi 4 4GB
- LCD1602
- fuel level sensor chevrolet trax 1,6 1,4 gas
- GY-NEO6MV2
- RC522 RFID Module
- mcp3008
- Visaton FR 7
- Voeding 5V 3A
- BTF-LIGHTING WS2812B LED Strip
- pi ups
- buck converter
Downloads
The Housing
For my enclosure it is made of a sheet of mdf and on all corners an aluminum rail of 1.5 cm by 1.5 cm for strength. The mdf is 3mm thick that was lasered to the right size.
Fritzin
Before we can start on anything else, we need to get a "prototype plan" ready. In this case we are making a fritzing scheme. This way we will know how everything is connected and we can use this as a guide.
A few tips for fritzing:
- make the breadboard and schematic separate as the fritzing program makes it very hard to switch in between without a mess
- if you don't have a component in your fritzing folder, there are many on the internet!
- makes sure your ground and voltage are always connected correctly, avoid shortages!
Normalised Database
To log and store data and users i designed my own database which contains 4 tables. With this database I store all my data including my coordinates, speed and fuel level.
The EER diagram is shown in the image above
1. User=gebruiker
Here the users are stored with their rfid tag.
2. rit
Here the rides and users are linked together and with a start date.
3. value = meetwaarde
Here, all values are recorded and stored with the ride to which they belong, which is also linked to a device.
4. device = toestel
Here are the devices displayed with a description there is also a wergeven if this is a sensor or actuator
Writing the Code
Installing Python packages
Before we try to run anything, we need to install some packages for python first. Head into the terminal of your RPi and type the following commands:
- pip install mysql-connector-python-rf
- pip install flask-socketio
- pip install flask-cors
- sudo pip install rpi_ws281x
- sudo apt install python3-dev python3-pip
Raspi-config
We will have to enable different interfaces and to do that we first have to typ following code:
sudo raspi-config
The things we need to enable are in the interfacing section. We need to enable following interfaces:
- SPI
- Serial Port
That was everything we needed to do with raspi-config
Writing the backend
I used Visual Studio Code for my whole backend, you just need to make sure your Visual Studio project is connected to your Raspberry Pi, this means your LAN cable has to be connected to your RPi and to make an SSH connection.
(info on how to create a remote connection can be found here: https://code.visualstudio.com/docs/remote/ssh)
I used my own classes and these are also all included in my GitHub. In my backend file, I used different classes, so everything can be used separately and so that my main code isn't a mess with all the different threads. I used threading to run all the different classes at once. And at the bottom, you got all the routes so we can easily get data in our frontend.
Writing the frontend
Now that the backend is done, we can start writing the full front-end.Do your best to make it mobile first and then add media queries for the desktop version. You can design your dashboard in any way you want to, i'll just leave my code and design here, you can do whatever you like! In javascript be ready to work with a few GET's from your backend routes, tons of event listeners and some socketio structures to get the data from the sensors displayed on the website.