CoinCent CTAI
CoinCent is my Project One prototype that helps people identify and use coins faster. The idea came from a simple problem: when you have a lot of coins, it becomes harder to know their exact value, sorting them takes time, and your wallet becomes heavier if you do not spend them.
With CoinCent, the user can place coins in front of the webcam, take a photo, and let the system recognise the coins. The prototype summarises the value of the coins and helps answer the question: Can I buy my favourite snack with these coins?
The project works as an AI coin assistant. It is made to give a clear overview of the coins the user currently has, make paying with coins easier, and reduce the time needed to count or sort them manually. The final prototype runs on a Raspberry Pi inside a laser-cut wooden box with a webcam, LCD, keypad, RGB LED feedback and buttons.
Supplies
- Raspberry Pi 5 - main device that runs and controls the prototype.
- Raspberry Pi 5 active cooler - used to keep the Raspberry Pi temperature stable.
- Full HD USB webcam with microphone - used to take photos for coin detection.
- Prototype box - wooden box made with laser cutting to hold the parts.
- LCD display - used to show information to the user.
- 4x4 keypad - used for direct control/input.
- RGB LED diode - used as visual feedback for the system.
- Dupont jumper wires - used to connect the electronics.
- Push buttons - used for system control such as shutdown or reset.
Wooden Box
For the housing I used a laser-cut wooden box. The goal was to keep the electronics inside the enclosure and only leave the user-facing parts visible: the webcam, LCD display, keypad, RGB LED and buttons.
The box was designed with openings for each hardware part. The LCD display is used to show information, the keypad gives the user direct input, the RGB LED gives simple visual feedback, and the buttons can be used for actions like shutdown or reset.
Inside the box there is space for the Raspberry Pi and wiring. I wanted the final prototype to look clean, so most of the cables stay inside the box instead of lying loose on the table. This also makes the prototype safer and easier to present.
Downloads
Collecting Dataset
For the AI part, I needed a dataset with pictures of euro coins. I collected images of coins in different positions and combinations. The goal was to teach the model to recognise coins even when there are multiple coins in one image.
In the dataset, the coins were labelled by value, for example 10 cent, 20 cent, 50 cent, 1 euro and 2 euro. It was important to make photos with different coin positions, lighting and backgrounds, because in the real prototype the user will not always place coins perfectly.
This step is important because the model can only learn from the examples it receives. If the dataset is too small or too clean, the model may work during training but fail in the real wooden box.
Training Model
After collecting and labelling the dataset, I trained a YOLO object detection model. I used YOLO because the project needs object detection, not only image classification. The model must detect each coin separately and recognise its value.
The model was trained with the labelled coin images. After training, I checked if the model could detect coins correctly and if it could handle multiple coins in one photo.
The trained model is later used on the Raspberry Pi. When the user takes a photo, the model predicts which coins are visible. Then the software calculates the total value from the detected coins and shows if the user can buy their favourite snack.
As a suggestion, it is better to place the camera above the coin area instead of at an angle. In my prototype, the camera is placed at an angle, but a top-down camera position would give a clearer view of the coin labels and could improve the prediction results.
Downloads
Setting Up Edge Devise
After the model part, I prepared the Raspberry Pi 5 as the main device for the project. The Raspberry Pi is the edge device, so it is responsible for running the system locally and connecting the hardware parts.
The hardware connected to the Raspberry Pi includes the USB webcam, LCD display, keypad, RGB LED and buttons. The webcam is used for taking photos of the coins. The LCD display shows short messages, such as the API status, total value or keypad results. The RGB LED gives visual feedback, and the buttons/keypad are used for direct control without needing a keyboard and mouse.
In the backend there are Raspberry Pi services for the display, keypad, buttons and hardware health. This makes the hardware part more organised, because the application does not talk to the GPIO pins directly from everywhere. Instead, the hardware logic is separated into services.
I also made the Raspberry Pi show useful information on the LCD, for example when the API is healthy or when the user needs to access the frontend from another device. This is important because the prototype should be usable as a physical object, not only as code running in the terminal.
Building Backend
For the backend I used FastAPI. The backend is the part that connects the AI model, database, Raspberry Pi hardware and frontend together.
The backend has different routes for the system, predictions, snacks, users, logs and settings. The most important part for CoinCent is the prediction route. When the user takes or uploads a photo, the backend sends the image to the YOLO model. The model detects the coins, and then the backend calculates the total value.
The backend also stores prediction data in PostgreSQL. The database keeps users, logs, actions, predictions, coins and prediction results. This makes it possible to save previous detections, show detected coin history, and connect the current coin amount to the user’s favourite snack.
I used Docker Compose for the backend setup. In Docker Compose, PostgreSQL runs as the database, Adminer can be used to inspect the database, and the FastAPI backend runs as the API service. The backend container also gets access to Raspberry Pi devices like I2C, GPIO and camera devices, because it needs to communicate with the real hardware
Frontend Design
For the frontend I used a Gradio interface. The frontend is the part where the user can interact with CoinCent without using the terminal.
The main page is the Operation page. On this page the user can use the camera or upload a photo, press Take & Predict, and then see the result. The result includes the total value, detected coins and whether the favourite snack can be bought. There is also a prediction check section where the user can mark if the prediction looks correct or wrong.
I also made a Snack page. On this page the user can choose a favourite snack, see the snack price, current balance, missing amount and whether they can buy it. This connects the coin detection to the main idea of the project: checking if the coins are enough for a snack.
The Data page shows more information about predictions, coin totals, detected value, history and snack readiness. This makes the project more than just one prediction button, because the user can also see what was detected before and how the coins are distributed.
The frontend communicates with the backend through API services. This keeps the frontend focused on the interface, while the backend handles predictions, database logic and hardware feedback.
Production
For production I made the project start with service files on the Raspberry Pi. This is useful because I do not want to manually start every part before a demo.
I used two systemd services:
- coincent.service - starts the backend part of the project.
- coincent-frontend.service - starts the Gradio frontend after the backend is ready.
The backend service starts the Docker stack, where the FastAPI backend and PostgreSQL database run. The frontend service waits until the backend is available and then starts Frontend/app.py.
The simplified production flow is:
- The Raspberry Pi boots.
- coincent.service starts the backend and database.
- coincent-frontend.service waits for the backend.
- The Gradio frontend starts.
- The user opens the frontend from another device.
- The camera, YOLO model, database, LCD, keypad, RGB LED and buttons work together.