Skate-o-Meter

I'm a student NMCT at Howest (Kortrijk)

Intro: Skate-o-Meter

I'm a student at Howest Kortrijk. To show our skills to the lectors we needed to build a project, I did chose to create a odometer and speedometer for my skateboard with an RFID scanner. In this instructable I'm goig to say how I did made this project.

I came up with this idea because I like to skate and cruise around. While I'm cruising it would be handy to see how much distance I've travelled and see my speed.

Keep in mind this is a prototype.

Step 1: Components

Components

I used the following components to create this project:

  • Skateboard
  • Potentiometer
  • LCD
  • Hall effect sensor
  • 10k Ohm Resistor
  • Raspberry pi
  • Arduino Nano
  • Jumper wire (Female to male)
  • Jumper wire (Raspberry Pi)
  • Jumper wire (Male to male)
  • PCB
  • RFID scanner
  • RFID badge
  • Powerbank

See BillOfMaterialsfor links and price

Step 2: Wiring

The hall has 3 pins: a VCC, a GND and a output.
The ground goes to a GND. The VCC to 3.3V and the output in this example goes to GPIO 26. A 10K Ohm resistor pulls the output high.

I use serial communication over the USB between the raspberry pi and arduino nano to read the badges.
--> This is not in the picture, but is required!

D9 --> RST (Reset)
D10 --> SDA(SS) (SPI SS)
D11 --> MOSI (SPI MOSI)
D12 --> MISO (SPI MISO)
D13 --> SCK (SPI SCK)
GND --> GND
3.3V --> 3.3V

Step 3: Database Scheme

My database has 3 tables:

  • Users
  • Session
  • Data

Every user can track data separtly. A session has data so you know how fast you went on certain points while the session was going on.

Step 4: Configure Arduino Nano

First put your arduino nano in your pc via the usb cable. Select the right arduino and the right usb port to upload.

Next we need to add the library I use for reading the RFID badge. Download 'rfid-master' and go to sketch, include library and then add .ZIP library. Go to the zip you just downloaded and use this one, it will install automaticly. After that download my edited 'RFID_Read.ino' press ctrl + O add the same time and go to this file and open it.

If you did all these steps above you can verify the file. If it bugs the first time, just try it once more. If this is succeed you can upload it to your arduino. By using the shortcut ctrl+shift+m you can open the serial monitor. You can test the file here. If the test is succeed you can unplug the arduino and plug it in an usb port of the raspberry pi

Step 5: Configure the Raspberry Pi

In these steps we gonna setup the raspberry pi as database and webserver.

IN THIS EXAMPLE I USE THE USER 'me' IF YOU USE ANOTHER USER YOU NEED TO CHANGE CONFIG FILES, KEEP THIS IN MIND!

1. Create a user:

  • Create a variable
pieter@rpipieter:~ $ user=me
  • Making the user sudo and adding to all groups
groups=$(id pi -Gn | sed 's/^pi //g' | sed 's/ /,/g')<br>sudo useradd ${user} -s /bin/bash -m -G ${groups}
sudo sed "s/^pi/${user}/" /etc/sudoers.d/010_pi-nopasswd | sudo tee "/etc/sudoers.d/011_${user}-nopasswd"
sudo passwd ${user}
  • Login to the account
pieter@rpipieter:~ $ su - me
Password:
me@my-rpi:~$

2. Connect with the WiFi

me@rpipieter:~ $ sudo -i<br>root@rpipieter:~# echo 'Password' | wpa_passphrase 'Networkname' >> /etc/wpa_supplicant/wpa_supplicant.conf
root@rpipieter:~# wpa_cli -i wlan0 reconfigure
root@rpipieter:~# logout
  • Check whether the internet is working
root@rpipieter:~# wget google.com


3. Making the raspberry pi up-to-date and installing needed packages

me@my-rpi:~$ sudo apt update
me@my-rpi:~$ sudo apt upgrade
me@rpipieter:~ $ sudo apt install -y python3-venv python3-pip python3-mysqldb mysql-server uwsgi nginx uwsgi-plugin-python3 git<br>me@my-rpi:~$ sudo reboot -h now<br>


4. Clone my github repository

me@rpipieter:~ $ git clone https://github.com/PieterThomas/skate-o-meter
me@rpipieter:~ $ cd skate-o-meter/skateometer/


5. Making the virtual environment

Whilst doing these commands there will be installed a lot of packages, this may take some time.

me@rpipieter:~/skate-o-meter/skateometer $ python3 -m pip install --upgrade pip setuptools wheel virtualenv
me@rpipieter:~/skate-o-meter/skateometer $ python3 -m venv --system-site-packages env
(env) me@rpipieter:~/skate-o-meter/skateometer $ python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib pyserial pyjwt RPi.GPIO


6. Creating the database and users

We are using mysql database

pieter@rpipieter:~/skate-o-meter/skateometer $ cd
pieter@rpipieter:~ $ sudo mysql

Then copy, paste this

GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'som-data'@'localhost';<br>SET PASSWORD FOR 'som-data'@'localhost' = PASSWORD('sensor9810');
select * from mysql.user;
CREATE USER 'som-admin'@'localhost' IDENTIFIED BY 'admin9810';
CREATE USER 'som-web'@'localhost' IDENTIFIED BY 'web9810';
CREATE USER 'som-sensor'@'localhost' IDENTIFIED BY 'sensor9810';

CREATE DATABASE skateometerdb;

GRANT ALL PRIVILEGES ON skateometerdb.* to 'som-admin'@'localhost' WITH GRANT OPTION;
GRANT SELECT, INSERT, UPDATE, DELETE ON skateometerdb.* TO 'som-web'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON skateometerdb.* TO 'som-sensor'@'localhost';
FLUSH PRIVILEGES;

Next we going to add the existing database scheme with relations.

me@rpipieter:~/skate-o-meter/skateometer $ sudo mysql < sql/skateometerdb_dump-withoutdata.sql

7. Services

Here we copy our config files and reloading the folder so that we can enable the services

me@rpipieter:~/skate-o-meter/skateometer $ sudo cp conf/som-*.service /etc/systemd/system<br>me@rpipieter:~/skate-o-meter/skateometer $ sudo systemctl daemon-reload

Now we are going to enable the services so that everytime we start the raspberry pi these will automaticly start up with it.

me@rpipieter:~/skate-o-meter/skateometer $ sudo systemctl enable som-flask.service
Created symlink /etc/systemd/system/multi-user.target.wants/som-flask.service → /etc/systemd/system/som-flask.service.
me@rpipieter:~/skate-o-meter/skateometer $ sudo systemctl enable som-data.service
Created symlink /etc/systemd/system/multi-user.target.wants/som-data.service → /etc/systemd/system/som-data.service.

me@rpipieter:~/skate-o-meter/skateometer $ sudo systemctl start som-data.service
me@rpipieter:~/skate-o-meter/skateometer $ sudo systemctl start som-flask.service


8. NGINX

me@rpipieter:~/skate-o-meter/skateometer $ sudo cp conf/nginx /etc/nginx/sites-available/skateometer<br>me@rpipieter:~/skate-o-meter/skateometer $ sudo rm /etc/nginx/sites-enabled/default
me@rpipieter:~/skate-o-meter/skateometer $ sudo ln -s /etc/nginx/sites-available/skateometer /etc/nginx/sites-enabled/skateometer<br>me@rpipieter:~/skate-o-meter/skateometer $ sudo systemctl restart nginx.service

Step 6: Housing + Hall

Housing

First I made a hole in my skateboard for the LCD, the potentiometer and the buzzer. After that I did solder the LCD, the potentiometer and the buzzer on the PCB. Then I used a jumperwire for the RPI, the one with 40 pins. I put one side in the raspberry pi and the other half I cut, this side we are going to use to solder. In the file 'rpi-cable' you can see where you need to solder which wire.

For the casing I used an old curver box, I put some holes in it for an ethernetcable and for the jumperwire to come in the box.

I keep the box under the skateboard with some screw. Inside the box I arranged everything, so it would fit and also used screws and some rubbers to keep everything in place. This makes taking stuff out easier.

The RFID is mounted to the lit of the box and is held in place with ziptires, one problem I encountered was that sometimes it didn't scan, but with some changes I made it work.

Hall effect sensor

First I drilled a hole in my wheel and put a magnet in it.

For the hall is used 3 jumperwires (male to male) I did solder them on my PCB as well on the hall itself. I mounted the hall sensor on my truck with some ziptires. Make sure the magnet and sensor are aligned well, otherwise it will not always register the pulse.

Step 7: Starting the App

Step 1:

Plug the raspberry and power bank in.

Step 2:

Wait until the program starts, you can follow this on the LCD. You will see the IP-address, go to this IP-address.

Step 3:

Create an user, you can do so by registering. You need to scan the badge to see your UID of the badge on the LCD.

Step 4:

If you created a user you can scan your badge and a session will start.

Step 5:

Go cruise around

Step 6:

Scan the badge again to stop the session

Step 7:

Login to see your session and detailed data from the session

Share

    Recommendations

    • Optics Contest

      Optics Contest
    • Electronics Tips & Tricks Challenge

      Electronics Tips & Tricks Challenge
    • Audio Contest 2018

      Audio Contest 2018

    5 Discussions

    0
    None
    seamster

    3 months ago

    Clever idea, nice to see the details too :)

    1 reply