I-track
Hey,
For my school project at MCT Howest Kortrijk, I made a smart GPS tracker for my electrical step. The devices has different sensors and 2 displays. The raspberry pi 4 runs everything on his own.
So now i will explain how i made this project ! If u have any questions please let me know and ill try to answer as quickly as possible.
my github : https://github.com/howest-mct/2023-2024-projectone-mct-VasilacheCosmin
Supplies
Raspberry Pi 4:
A powerful single-board computer with a quad-core processor, suitable for various projects ranging from simple automation to complex AI applications.
LCD 16x2:
A basic LCD screen capable of displaying 16 characters per line and 2 lines, commonly used for showing simple text information.
Display 7x4:
Likely referring to a 7-segment display with 4 digits, used for displaying numerical information.
GPS Neo 7M U-block:
A GPS module that provides precise location data, commonly used in navigation and tracking applications.
LDR (Light Dependent Resistor):
A sensor that changes its resistance based on light intensity, used in light sensing applications.
MPU6050:
A sensor module that combines a 3-axis gyroscope and a 3-axis accelerometer, used for motion tracking and orientation sensing.
Cables:
Various electrical wires and connectors used to establish connections between components.
74HC595:
An 8-bit shift register used to expand the number of output pins on a microcontroller, useful for controlling multiple LEDs or other outputs with fewer pins.
MCP3008:
An 8-channel 10-bit analog-to-digital converter (ADC), used for reading analog signals from sensors.
PCF8574:
An I/O expander that adds additional input/output pins to a microcontroller via the I2C bus, useful for expanding digital I/O capabilities.
Downloads
Schematic
For my schematic i used Fritzing, with this program u can make ur schematic aswell verry easyly.
Make sure u connect everything correctly !
Desgin Database
The database has 1 central ride where we make a new id each time when we have a run. The other tabels are the different sensors who are given this id eacht measurment.
U can do 1 table for all the sensors but i choose to split them beceause of the diffrence in datatype.
Preparing Raspberry Pi
Firstly u will need a configured raspberry pi. Therefor u need a 16GB SD card where u need to put an image of the raspberry software.
Software : https://www.raspberrypi.com/software/
Once u downloaded ur image on the pi u will need to configure it so we can use its different ways of cumminication.
Enable
- SPi
- I2C
- Serial
u can do this with this command :
sudo raspi-config
Update & upgrade the pi
sudo apt-get update
sudo apt-get upgrade
Install the MariaDB server:
sudo apt-get install mariadb-server
Writing the Backend
Now that the setup is complete, we can finally begin working on our project!
I used Visual Studio Code (VS Code) for the entire project. To do this, I started the VS Code server on my Raspberry Pi and connected to it via SSH. Ensure that your VS Code project is connected to your Raspberry Pi; this involves setting up the SSH connection properly and installing all the necessary packages on your Pi.
I wrote the code in Python, leveraging my own classes which you can find on my GitHub.
In my project, I utilized threading to allow different parts of the code to run concurrently without interrupting each other. At the bottom of the main file, you will find all the routes defined, making it easy to fetch data for the frontend.
Writing the Frontend
The HTML and CSS were straightforward to implement. I aimed to work mobile-first as much as possible since we typically connect via mobile devices. This makes it easier to control the device from a mobile dashboard.
You can design your dashboard in any way you prefer, but I'll share my code and design as a reference. Feel free to modify it to suit your needs!
Building the Case
The case made so it can fit everything even the powerbank!
In the first compartment fits the powerbank, raspberry pi , MPU6050 and the gps sensor. In the second compartement we have the breadbord , LDR, LCD , 7*4 segment display aswell as the 2 buttons and the wires. On top is a lid that fits perfectly for the displays.
Possible Problems
One of the most common issues i had was with the gps component. It sometimes didnt want to read anything even tho i was outside.
Enter this code
gpsmon /dev/ttys0 (or the divice where u run ur gps deamon)
cgps
If that doesnt work try to deinstall and reinstall. U could also try to update it but personally it didnt work by simply updating it.
sudo apt remove gpsd
sudo apt install gpsd