Smart Training Room for Cyclists

by NielsOnderbeke in Circuits > Raspberry Pi

440 Views, 0 Favorites, 0 Comments

Smart Training Room for Cyclists

20200610_110743.jpg

As a cyclist I know how frustrating it can be to train inside on
your rollers. It often gets too hot inside and it's pretty boring.

So, I wanted to make a room that gives my indoor training a better experience.

There were a few things I really wanted for this room:

  • Good security (for the room and my bike) with RFID or password
  • Automatic cooling system
  • Speed monitoring
  • Heartrate monitoring

With these things my training experience will be less boring and less hot.

*The code for this project is in English but the documentation is in Dutch!

Supplies

For this project you definitely will need a Raspberry PI, Arduino and breadboard.

Get the Supplies

20200429_170155.jpg
20200429_170208.jpg
20200429_170236.jpg
20200429_170252.jpg
20200429_170310.jpg
20200429_170332.jpg
20200429_170342.jpg
20200429_170357.jpg
20200429_170415.jpg
20200429_170421.jpg
20200429_170439.jpg
20200525_142528.jpg

First of all you will need a lot of equiment to start. You can find all items in this Excel file!

Here you can see some pictures of the components I have used!

Soldering the Components

20200604_210708.jpg
20200606_102705.jpg
20200606_103451.jpg
20200606_110034.jpg
20200604_203706.jpg

Soldering the components at the start will prevent you from struggeling in the future. If all cables are long enough from the start you won't have problems with placing the circuit in it's housing.

Maken sure that the cables are long enough for these components (approximately 20cm for each cable):

  • Temperature sensor
  • Lights
  • DC motor
  • Buzzer
  • RFID scanner
  • LCD display

Some tips to do the soldering fast and good:

  • Make sure your soldering iron is hot enough
  • Dismantle the cables sufficiently
  • Use the right solder for your type of cable
  • Finish with heat shrink tubing

Make the Circuit

project1_fritzing_breadboard_bb.jpg

Here is the fritzing scheme of my circuit, I also included the electric scheme with some more details.

Make sure you use the same pins as on the breadboard scheme, otherwise you will have to adapt the code!

As you can see, I used an extra source (batteries), this is not necessarily necessary as long you can provide approximately 5 volts. I used this source because there can be some issues with the LCD display.

Download the Code From Github

codeRFIDLibrary.PNG

You can download all my code (front and backend) from my Github. Feel free to adapt the code to your preferences.

Link to my Github: https://github.com/howest-mct/1920-1mct-project1-...

You can place the backend code where you want on your Raspberry Pi but make sure the html folder is placed on this path /var/www/.

Download packages

You will have to install some packages to make the code work.

1. Go to the folder "project1"

2. Execute the following commands:

  • pip3 install mysql-connector-python
  • pip3 install flask-socketio
  • pip3 install flask-cors
  • pip3 install gevent
  • pip3 install gevent-websocket

Heartrate sensor

The code for the Arduino (used for the heartrate sensor) is placed below the backend folder! I used a library for this and adapted it to my own needs, you don't need to change or download anything. Just upload it to your Arduino. Library: https://github.com/WorldFamousElectronics/PulseSe...

RFID library

For the RFID scanner I have used a library. This link will help you to install the library: https://pimylifeup.com/raspberry-pi-rfid-rc522/ (I used GPIO pin 12 instead of GPIO pin 25 for the RST pin, don't forget to edit this in the MFRC522 file. SEE PICTURE).

One wire bus

I also recommend to activate the one wire bus in raspi-config! Otherwise the temperature can't be measured. (https://www.raspberrypi-spy.co.uk/2018/02/enable-1-wire-interface-raspberry-pi/)

Create the Database

databaseScheme.png

You will need this MySQL database on your Raspberry Pi, I used Maria DB as database management system on my Raspberry Pi (https://mariadb.org/).

I created my database scheme with MySQL Workbench (https://www.mysql.com/products/workbench/). This software is easy to use on your pc and you can work remote over a SSH connection with it. I also included my MySQL script with database structure and test data so you can test the code.

This link can help you:

Downloads

Test the Circuit With the Code From Github

dashboard.PNG
login.PNG

This is a really important step in the process. Now you will connect the hardware to the software. Make sure all power supplies are plugged in!

To start the program you will need to run app.py on your Raspberry Pi with python 3, this is the file that connects the front- and backend. You can reach the site in your browser via the IP adress displayed on your LCD display.

Login with ID 1 and password "test", these are test values! Make sure you use other credentials for a better security. You can do this in MySQL workbench in the table 'users'.

After this you can set the app.py file as a service so the code starts after every boot. This is a link that will show you how: https://www.raspberrypi.org/documentation/linux/usage/systemd.md.

Saw the Parts for the Housing

IMG_0001.jpg
IMG_0002.jpg
20200608_101746.jpg
20200608_101748.jpg
20200608_101802.jpg
20200608_101818.jpg
20200608_101828.jpg
20200608_101830.jpg
20200608_101846.jpg
20200608_101858.jpg
20200608_101901.jpg

When hardware and software are connected and work with eachother you can start making the housing.

The main material I used for this is OSB wood. I included the design of my own construction with all the dimensions. To saw the OSB plates you can go to a sawmill or do it your own, a sawing machine can help you a lot.

Paint the Housing

20200609_183228.jpg
20200610_090849.jpg
20200610_110752.jpg

You can paint the housing how you want. If you do, do it before you place the circuit into your housing! This will make it a lot easier to paint! (I did the painting afterwards and that was not really handy).

I used water-based paint, this is perfect for this type of wood and it dries quickly.

Connect the Parts of the Housing

20200608_103132.jpg
20200608_103704.jpg
20200608_115105.jpg
20200608_120239.jpg
20200608_120623.jpg

I recommend to drill the holes for the components before you connect the parts. Also before you connect the parts, place the electronic magnet and light switch on the right place, this makes it easier at the end.

Don't use too wide or long screws otherwise the wood will split!

Place the Circuit in It's Housing

20200608_123218.jpg
20200608_123224.jpg
20200608_124018.jpg
20200608_125244.jpg
20200608_125247.jpg
20200608_133950.jpg
20200608_134327.jpg
20200608_143049.jpg
20200608_143054.jpg
20200608_143057.jpg
20200608_143101.jpg
20200608_143334.jpg
20200610_110800.jpg
20200610_110806.jpg

With the soldered cables this will be an easy job. Make sure you are safe with the circuit!

After placing the circuit in it's housing check the circuit, loose cabels can and will cause problems!

I recommend to connect the components to the housing, this will make it safer and stable.

Enjoy Your Own Training Room and Platform!

20200610_110743.jpg
20200610_110818.jpg

Now you can make indoor rides without getting overheated and it will be less boring!