Howest CTAI: KeepyUppyBox

by MaksymCTAI in Circuits > Raspberry Pi

56 Views, 0 Favorites, 0 Comments

Howest CTAI: KeepyUppyBox

ChatGPT Image Jun 16, 2026, 11_08_28 AM.png

Do you enjoy tennis or badminton? Have you ever lost track of how many times the ball bounced during a rally or training session? If so, this project might interest you!

I've created a smart device that uses AI and computer vision to detect and count ball bounces automatically. A camera monitors the game while the software analyzes the footage and keeps track of every bounce in real time.

In this Instructable, I will show you how I built the system, the hardware and software behind it, and how you can create your own version.

Supplies

For this project you will need:


Raspberry pi 5

16x2 LCD screen

GPIO extension board + breadboard 400 pin(preferred for simplicity)

Set of male to male + male to female jumper wires

USB webcam(preferred EMEET C60E)

RFID scanner RC522

Passive buzzer

5x 2-pin buttons

4mm thick material for box - MFD, Plywood or other material(or own box design)

Preparing Pi

What You Need

  1. Raspberry Pi
  2. Micro SD card (16 GB or larger recommended)
  3. PC or laptop
  4. Micro SD card reader
  5. LAN cable
  6. Power supply for the Raspberry Pi


Open Raspberry Pi Imager on your computer. Insert the micro SD card into your PC using a card reader.

In Raspberry Pi Imager, choose your Raspberry Pi model and select an operating system Raspberry Pi OS (64-bit). Next, select your micro SD card as the storage device and click Next.

When prompted, customize the OS settings. Set a hostname, username, and password, and configure your network settings if needed. Enable SSH so you can access the Raspberry Pi remotely. Save the settings and write the OS image to the SD card.

Once the imaging process is complete, insert the micro SD card into your Raspberry Pi. Connect the Raspberry Pi to your network using a LAN cable and power it on. After the device has booted, connect to it via SSH from your computer to continue the setup.

Hardware Wiring

photo_5303404473436806917_y.jpg
photo_5303404473436806918_y.jpg
photo_5303404473436806919_y.jpg

To make circuit connect all hardware to listed pins. You can change GPIO for buttons/buzzer to your own if you wish.


5 buttons:

  1. Power button located on the bottom panel is connected to J2 next to Type-C connector on R-pi 5.
  2. Most left button (menu) is connected to GPIO 26 and GND
  3. 2-nd left button (back) is connected to GPIO 16 and GND
  4. 3-rd button (next) is connected to GPIO 20 and GND
  5. 4-th button (confirm) is connected to GPIO 21 and GND


16x2 LCD 4 pin:

  1. GND
  2. VCC - 5V
  3. SDA - (GPIO 2 / SDA1)
  4. SCL - (GPIO 3 / SCL1)


Passive buzzer 3 pin:

  1. GND
  2. VCC - 3.3V
  3. S - GPIO 5


RFID 8 pin:

  1. SDA (SS) - GPIO 8 (CE0)
  2. SCK - GPIO 11 (SCLK)
  3. MOSI - GPIO 10
  4. MISO - GPIO 9
  5. IRQ - Not connected
  6. GND
  7. RST - GPIO 25
  8. 3.3V


Camera connects via USB.

Designing Box

For the box you will need cutouts for buttons, LCD, camera, power supply and buzzer. Leave enough space inside for wiring.


You can download my .svg here:

Quick Start (if You Don't Want to Code and Train Model)

You can download all code and trained model from this github repo:

https://github.com/howest-mct/2025-26-projectone-ctai-Skereg


After you've successfully downloaded open that folder - navigate to /Project and duplicate .env.example - rename it .env(you can change postgres database login/password here). Then open /Project/api and duplicate .env.example as well.


Navigate to /Project and run listed command in terminal:

docker compose up -d --build


Build will take 20-30 minutes.

After its done app should start - there will aslo be wifi ip displayed if there is one so you can connect to browser page wirelessly if needed.


Browser links:

<your-pi-ip>:7860 - Gradio website

<your-pi-ip>:8080 - Database

<your-pi-ip>:8000/docs - API


If you want to replace the model with your own follow the next step, then replace best_ncnn_model with your own and rebuild "app" container.

Training Model

image_2026-06-17_185539784.png
image_2026-06-17_185712776.png

First you need to collect data - film yourself or others playing tennis, badminton. You should use camera that you will be using with pi, otherwise results will be worse.


Go to https://roboflow.com - login and create a new project, choose Yolo26n model or newest available. Upload your videos/photos - go to annotation and start labeling it.


You will have 4 classes:

racket, shuttlecock, tennis_ball, tennis_pad


After you labeled data go to versions and create new - recommended settings:

Split 70/20/10

480x480 stretch images

Augmentation blur 0.9px


Train model with your api key on 100-150 epochs, imgsz=480.

After training you'll get a best.pt file(if not set to export ncnn during training) - export it to ncnn for better performance on r-pi.


Link to my roboflow project:

https://app.roboflow.com/trebobo/keepyuppy

Database

image_2026-06-17_185231797.png

We need a simple database to store users and their game sessions.

Coding

I used python 3.11.5.


All code can be found in my GitHub repository:

https://github.com/howest-mct/2025-26-projectone-ctai-Skereg

App Guide

When device is just turned and "Scan RFID" message is displayed you have to place your RFID tag/card to the scanner and hold for 2-3 seconds to login into your user profile.

With next/back button you can select gamemode - B: indicated best score, L: indicates last score. Press confirm to start game - after last buzzer you can start playing, game wont start untill first ball hit, game will end once no bounce detected for 2 seconds(after first hit) or if you press confirm button again.

On the left there is menu button - here you can view your games history or reset all your games history.


You can change users at any time by placing different RFID card to RFID sensor.