Smart Shuffle Board

by IbeDemortier in Circuits > Raspberry Pi

337 Views, 0 Favorites, 0 Comments

Smart Shuffle Board

019526_1_1.jpg

Intro

As a student Multimedia & Communication technology in Howest Kortrijk, I had to make my own project called 'ProjectOne'. This would combine all of the modules followed in the first year into one big project.

When playing with my shufle board I always had the issue of always needing to count the points myself which always made it pretty boring. So I decided to make a smart shuffle board which would count the points for me.

Smart Shuffle Board is a Raspberry PI powered device which shows the points on a website and who wins and loses.

I will be referring to this Github quite a bit in this instructable so make sure to check it out!

My github: Github

Bill of Materials

20220620_101928.jpg

Main computing units

-Raspberry PI

This is the main controller of the whole thing.

-5V powersupply

Power supply for all the components.

-2Breadboards with jumper wires

-A set of resistors

-Different colors of 0.2mm wires

-Raspberry Pi t-cobbler

Sensors and modules:

-RFID RC522

-4x KY- 024

-PCF8574

-LCD screen 2x16

-KY-008 and laser reciever modules

-2x Level shifter

-30cm of WSB2812 LED strip

Tools used in the project

-Soldering iron and solder

-Glue

-Drill

-3D-printer

-...

The Housing

3ddesign.PNG

The first thing i did is make a 3D design of the case that i wanted to print.

I chose to 3D print the case bacause i already have a lot of experience with 3D printing and it's really easy to do. You just need to have acces to a computer and a 3D printer.

An other important part is the shuffle baord itself. I bought a smaller version so i can transfer it more easy. Than i just needed to drill some holes to mount everything and the housing was done.

Fritzin

schematic.PNG

Before we can start on anything else, we need to get a "prototype plan" ready. In this case we are making a fritzing scheme. This way we will know how everything is connected and we can use this as a guide.

A few tips for fritzing:
- make the breadboard and schematic separate as the fritzing program makes it very hard to switch in between without a mess

- if you don't have a component in your fritzing folder, there are many on the internet!

- makes sure your ground and voltage are always connected correctly, avoid shortages!

Normalised Database

Dataabse.PNG

To log and store data and users i designed my own database which contains 5 tables.

The EER diagram is shown in the image above

1. Device

In this table I give every sensor and actuator an ID this way i can know which data comes from which sensor.

2. Historiek

Here I keep all the data i receive from the sensors

3. User

To store all the players i made this table here i save the name and the ID of every player.

4. spel_has_user

In this table I keep the score i player got per game. So every game I keep a max of 4 players

5. spel

In this table i just keep the id of the game and the ID of the winner.

Writing the Code

website.jpg

Installing Python packages

Before we try to run anything, we need to install some packages for python first. Head into the terminal of your RPi and type the following commands:

- pip install mysql-connector-python-rf

- pip install flask-socketio

- pip install flask-cors

- pip install gevent

- pip install gevent-websocket

- pip install selenium

- pip install rpi_ws281x adafruit-circuitpython-neopixel

- pip install mfrc522

Raspi-config
We will have to enable different interfaces and to do that we first have to typ following code:

sudo raspi-config

The things we need to enable are in the interfacing section. We need to enable following interfaces:

- SPI

- I2C

That was everything we needed to do with raspi-config

Writing the backend
I used Visual Studio Code for my whole backend, you just need to make sure your Visual Studio project is connected to your Raspberry Pi, this means your LAN cable has to be connected to your RPi and to make an SSH connection.

(info on how to create a remote connection can be found here: https://code.visualstudio.com/docs/remote/ssh)

I used my own classes and these are also all included in my GitHub. In my backend file, I used different classes, so everything can be used separately and so that my main code isn't a mess with all the different threads. I used threading to run all the different classes at once. And at the bottom, you got all the routes so we can easily get data in our frontend.

check out my github for the full code

Writing the frontend
Now that the backend is done, we can start writing the full front-end.Do your best to make it mobile first and then add media queries for the desktop version. You can design your dashboard in any way you want to, i'll just leave my code and design here, you can do whatever you like! In javascript be ready to work with a few GET's from your backend routes, tons of event listeners and some socketio structures to get the data from the sensors displayed on the website.

check out my github for the full code