ChronoWizard - a Running Race Timing Application

by jarivanmelckebeke in Circuits > Software

103 Views, 0 Favorites, 0 Comments

ChronoWizard - a Running Race Timing Application

chronowizard img.png

More and more people have a dream to once run a marathon and set up a training schedule to be ready for such a challenge. One of the key elements in these training schedules is participation in races which are considerably less long in distance than a marathon, they give the trainee an intermediate milestone on their Hellenic running quest as well as a familiar environment with friends.


In most cases, the staff of these races depend on an external company for handling the registrations, both 'on site' and 'prior to the race', as well as registering the times the participants run. At first glance this is fine, but the end results are often only received in a pdf (which does not allow further processing by the organisation) or even worse, just by paper.


In this instructable, I will explain how to build your own time registering tool, which I named 'ChronoWizard'.

Supplies

  • Raspberry pi
  • Barcode scanner
  • pcf8574 chip
  • LCD display (preferably with 4 lines, for example a 20x4 hd44780)
  • 5x7-segment display (or 4x7 + 1x7 segment display)
  • max7219cng chip
  • 2 potentiometers
  • [optional] Real time clock module (for example, pcf8523)
  • external (breadboard) 3.3V and 5V power supply
  • 2x 5.7 ohm resistor

Setup Your Raspberry Pi

raspberry-pi-logo.png

Starting from a clean OS

The very first step is to setup your Raspberry Pi and connect to it using ssh.

I recommend using this instructable to help you get started with that.

After logging in to your pi using ssh (explained in that same instructable), you are ready for the next step.


Installing required software

For the program to work, we need some software, type in the terminal:

sudo apt install -y git apache2

this should install git and apache2 (a web server) onto your raspberry pi.

Next up are some requirements for python:

pip install flask-cors flask-socketio mysql-connector-python gevent gevent-websocket

And a library for the distance sensor:

pip install git+https://github.com/pimoroni/VL53L0X-python.git


Install Docker

Finally, we need to install docker, I recommend using this tutorial to install docker compose.

Wiring the Components

chronowizard_bb.png
chronowizard_electric.png
IMG_20220608_115715.jpg
IMG_20220612_172301.jpg
IMG_20220617_105519.jpg
IMG_20220616_160950.jpg

The attached pdf's in this step provide an overview on how to wire the components.


I advise to start wiring it with a breadboard first to verify its workings before moving on to soldering the wires.

When unable to directly put a component onto the breadboard, I used some rather.... interesting.... techniques to verify they work (do...not...look at the fourth image), I do not endorse you to use these techniques.

A technique I really do advise is being creative with common house hold items. You don't want to know how handy clothespins, tweezers, and/or a combination of both are when soldering wires which go everywhere but the place you want it to go.

Assembling a Box to Put the Project In

FPTPT20L4LBNEIF.png
IMG_20220620_085707.jpg

Added to this step you can find a design for the 6 sides of the eventual box.


You can fabricate this yourself or you can use a laser cutter to do it for you. I would advise to make the cuts slightly bigger than how they are in the attached design.


After having the 6 sides, you can assemble the box using glue, tape (The Almighty) or a combination of both. Disassembled clothespins can be used for support.


After assembling the box and wiring all the parts in it, we are ready to get to the software side of the project.

Downloading the Code

GitHub-Emblem.png

Now we can copy the code that runs ChronoWizard to the raspberry pi, navigate to a folder you know (for example: `/home/pi/`) and run this command:

git clone https://github.com/howest-mct/2021-2022-projectone-jvanmelckebeke ChronoWizard

this should create a new folder ChronoWizard where you can find the code for this project.

Deploying the Code


Setting up the database

When you enter this ChronoWizard folder (cd ChronoWizard), you can find a file docker-compose.yml, this file manages the database. Run the following command to start it:

docker compose up -d

It might take some time before it actually starts the first time, but the next potential (re)starts should be much faster.


Setting up the front-end

Apache needs to know where to find your front-end, so we need to configure this in the settings.

In `/etc/apache2/sites-available/000-default.conf` there should be a line

DocumentRoot /var/www/html

edit this to:

DocumentRoot /path/to/ChronoWizard/folder/front-end

So in my case:

DocumentRoot /home/pi/ChronoWizard/front-end


Next, we need to enable some permissions, in `/etc/apache2/apache2.conf` find the lines

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Require all denied
</Directory>

And change it to:

<Directory />
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>


Finally, run the following line to apply your changes:

sudo service apache2 restart


Configuring the backend

when you navigate to the ChronoWizard/backend folder you might notice a config.ini file this is an internal settings file which looks

[mysql_connector]
user = root
host = 127.0.0.1
port = 3306
password = Str0ngDBP@55word!
database = rcdt


[hardware.vl53l0x]
active = True
bus = 22
address = 0x29
max_range = 2300

[hardware.5x7segment]
active = True
bus = 0
device = 1

[hardware.barcode-reader]
active = True

[hardware.lcd]
active = True

line_length = 40

pinE = 26
pinRS = 19

data_bits = 4
num_lines = 2
font = 1
display = True
cursor = False
blink = False
pcf = True
shift_pcf_up = True
pcf_address = 0x38

data_pins = [0,0,0,0]
; data_pins is not relevant when using a pcf8574, but must be a list of data_bits length


In here you can enable/disable any hardware component if it is not needed or if it is broken for example.


It is also possible to change GPIO ports etc.

Starting the Code

In the main directory (ChronoWizard/) you can find a file called run_backend.fish, you can use this file to start the backend.


Next navigate to your pi's web address using your favorite browser and everything should work.


Good luck.