Smart Bike Dashboard MCT Howest

by ArthurMeyfroidt in Circuits > Raspberry Pi

64 Views, 2 Favorites, 0 Comments

Smart Bike Dashboard MCT Howest

448195020_1648220326017724_3363144291446004250_n.jpg

I have developed a smart bike dashboard that measures your speed on any route and sends data to a database. It tracks your current location, speed, and routes. And then i shows it all of on a website where it is all summarized.

A second part of this dashboard includes a smart light that adjusts based if you are riding or not. It then adjust it to how dark it is (how darker how more light it will give), it als becomes brighter if your are braking with your bike.

In this Instructable, I will explain how to make it. If you ever get stuck, here is a link to my GitHub page with all my code and designs.

https://github.com/howest-mct/2023-2024-projectone-mct-MeyfroidtArthur.

Supplies

448418214_1203038327554877_3956019615280149404_n.jpg

Sensors:

  • GPS sensor: To determine your speed and to pinpoint your location.
  • LDR sensor: To automatically activate your light when needed and adjust its brightness.
  • Accelerometer sensor: To detect whether you are riding your bike.
  • RFID sensor: To identify you and save your data to your account.
  • On off button
  • button

Actuators:

  • 2 Neopixels: Front and back lights.
  • Servo motor: Displays current speed on dashboard.
  • LCD display: Shows speed in km/h and battery percentage.
  • Potentiometer: To control the brightness of the LCD screen

Regulators

  • MCP 3008: To read your LDR

Controller

  • RPi4: To run everything on
  • esp32: to communicate with the rpi to enbale the neopixels

Extra parts:

  • Mini breadboards: For easy connection of unsolderable wires and devices.
  • Powerbank: makes it possible to carry it around
  • GPIO extension: To place your devices easier on your RPi
  • Jumperkabels: To connect everything
  • Micro sd card: to place your img on for the RPi

If you are interested in where you can buy all of this and how much it costs, take a look at my bill of materials.

Make the Circuit

448317648_486197110548333_7205464204246676074_n (1).jpg
Schema_schema.jpg

To build the circuit for the Smart Bike Dashboard, just follow this Fritzing scheme that I made.

You can connect the ESP32 to the RPi via USB.

What do you need:

  • GPS sensor
  • LDR sensor
  • Accelerometer sensor
  • RFID sensor
  • Mini breadbord
  • Jumperkabels
  • 2 Neopixels
  • Servo motor
  • LCD display
  • Potentiometer
  • MCP 3008
  • RPi
  • esp32


Preparing the Raspberry Pi

After you have created the circuit, we can begin the next part: setting up the RPi.

What you need:

RPi Micro SD card

Step 1:

Open Raspberry Pi Imager. Insert the micro SD card into your PC.

Step 2:

Choose your Raspberry Pi model and operating system. I recommend RPi OS Lite 64-bit. Then select your storage device and continue.

Step 3:

Personalize the settings and continue.

Step 4:

Insert the SD card into your RPi. Connect your Raspberry Pi to your PC using a LAN cable. Connect through SSH.

If you can't connect, try to troubleshoot.

Creating Database

Smart_Bike_Dashboard_Database.png

Now connect to MySQL trough ssh and create this database according to my schema.

If you have problems or can't create the database, use my file Smart_Bike_Dashboard.sql.

You can find that on my GitHub page following this path: Database -> Smart_Bike_Dashboard.sql.

Coding the Project

447891504_3771768319763293_2309096618855921486_n.jpg

Front-end

To begin, design your website in Figma. If you do not want to design the whole website yourself, go to my GitHub page and follow this route: docs -> FA -> 1MCT2_Arthur_Project_1.fig and open it in Figma.

After you have created the design, you can begin coding the front end of the page.

Now that you have created the front end, we have a place to show all our data, so we can begin coding the sensors.

Backend Sensors

GPS Sensor

Let's begin with the easiest sensor, the GPS sensor. You just need the serial library. Use readline and look for the lines that start with $GPGGA (to know where you are) and $GPVTG (to know how fast you are going). After this, send the data to your database.

Accelerometer Sensor

You just need my class, which you can find on my GitHub page through backend -> helpers -> Acceleration_class.py. To start up the class, use the setup function. Then, you can use the versnelling function to see if the accelerometer is moving.

LDR Sensor

To start, call my Analog_Read_Class, which you can find under backend -> helpers -> Analog_Read_Class.py, along with the bus and the device. After this, you can use the read_channel method and specify which analog port you are using from the MCP3008.

RFID Sensor

Just install the SimpleMFRC522 library and set up the RFID by calling the class. After this, you can use id, text = reader.read_no_block() to get your RFID badge code.

Make it so that when you press a badge against the RFID sensor, it starts saving data to your database.

On/Off/On Button

Use an event handler on the normal button so that when it is pressed, it turns off. For the on/off/on button, keep checking which state it is in.

Backend Actuators

Servo Motor

Now that we know how fast we are going thanks to the GPS sensor, we can transform the km/h to a PWM signal. You can do this by using the formula: 12.5 - ((km / (your max km you want)) * 10).

Neopixels

Write the code to make your NeoPixels work on your ESP32. Then, program the Raspberry Pi (RPi) so that when the light is too dim, the RPi, via serial communication, increases the brightness of the NeoPixels. Additionally, when you brake, the NeoPixels should go to maximum brightness.

If the on/off/on button is in the left "on" position, the NeoPixels only work if the accelerometer is changing. If the button is in the right "on" position, the NeoPixels work normally.

If you have problems with coding this use this file backend -> esp_project1.ino

LCD

Use my class to show the speed from the GPS sensor on the LCD. The class is located at backend -> helpers -> LCD_Class.

Front-end JavaScript

Now that you have all the data from your sensors and actuators, you can begin showing it on your front end.

If somehow you have problems with teh coding you can find my coding w-file under backend->app.py

Building the Case

afbeelding_2024-06-17_001014785.png
448443090_1120426795682056_1546323216479454751_n.jpg

For building the case, use my 3D model that you can find on GitHub: docs -> 3D_Model_Case.shapr. To open it, use the free program Shapr3D.

After you have 3D printed it, put the mini breadboards on the case.

Putting Things Togheter

448303947_1098872071180528_590162696187932618_n.jpg
447907433_330891670111870_6514479847522016408_n.jpg

Now put the circuit in the case and attach it to your bike.

Now you can begin cycling and capture your cycling data. Enjoy!