Kiosk

Kiosk is a small software project that is intended to be a cash register system for a vending machine.

MIT License

Stars
2

Kiosk

Kiosk is a small software project that is intended to be a cash register system for a vending machine. Using a Raspberry Pi, an NFC reader and a lock, any fridge or cabinet can be transformed into a small vending machine for friends and colleagues.

📋 Table of Contents

🚀 Quick Start

Kiosk is a Python application and uses CustomTkinter as UI. I used poetry as a dependency manager. To start the application you can simply run poetry install and then poetry run python3 src/main.py.

Normally the logging of the application is set to INFO, but if something should fail at startup or during runtime, the logging can be set a little more finely in the log manager. To do this, the corresponding code must be adjusted in the logmgr.py: Line 19.

⚠️ Important!

Both the library for controlling the GPIO pins (gpiod) and the library for the pn532 NFC chip (pn532lib) can only be used on a raspberry pi. If you want to develop on another system, the corresponding parts of the software must be commented out or bypassed in some other way.

✨ Features

The kiosk is intended to be a small application to simplify the use of a communal refrigerator or other goods cupboard for a group of people.

Each user is stored with an NFC ID. You can either use your own cards or dongles or use existing access cards or similar. A user can then select products using a barcode scanner and the costs are deducted from their (internal) account.

An admin can manage the stock and users and, of course, buy something themselves.

Future plans

Here are a few ideas on how to expand the software:

  • 🎵 Play sounds on successful or unsuccessful checkout
  • 📊 More precise evaluation of the purchasing behavior of individual persons
  • 📧 E-mail notifications for admins when product stock is low or for users when credit is low.
  • ...

🛠️ Service

I use a service so that the kiosk software starts every time the Pi is started. My configuration looks like this:

[Unit]
Description=Kiosk
After=graphical.target

[Service]
ExecStart=/home/<user>/.local/bin/poetry run python3 /home/<user>/Kiosk/src/main.py
WorkingDirectory=/home/<user>/Kiosk
User=<user>
Environment=DISPLAY=:0
Restart=always

[Install]
WantedBy=graphical.target

I have stored this file under /etc/systemd/system/. As soon as the graphical user interface of Raspberry Pi OS has finished loading, the kiosk application starts.

💾 Backup

As i have already painfully discovered, it makes sense to back up the database. If you decide to use a Postgres, MariaDB or other SQL database, I recommend using the respective program such as pg_dump.

In my case I use a SQLite database. This is simply backed up via a cronjob. The script for this looks like this:

#!/bin/bash

# Path to the SQLite database file
DB_FILE="/home/<user>/Kiosk/src/database/kiosk.db"
BACKUP_DIR="/home/<user>/DB-Backup/"

# Create the backup directory if it doesn't exist
mkdir -p ${BACKUP_DIR}

# Set the filename for the backup
BACKUP_FILE="${BACKUP_DIR}/database_$(date +\%Y-\%m-\%d).db"

# Copy the database file
cp ${DB_FILE} ${BACKUP_FILE}

I call this script via cronjob once a day. Another script then takes care of deleting old backups. This script runs about an hour after the first one and looks like this:

#!/bin/bash

# Backup directory
BACKUP_DIR="/home/<user>/DB-Backup/"

# Find and delete backups older than 30 days
find ${BACKUP_DIR} -type f -name "*.db" -mtime +30 -exec rm {} \;

This ensures that I always have backups of the last 30 days and can simply restore them if the worst comes to the worst.

🔧 Components

I used the following components for my setup:

📐 3D-Model

I myself use an official Raspberry Pi display. The resolution of the software is adapted to this. In the folder 3D model you will find a model that offers space for a Pi as well as the display, an NFC reader and a 5V relay.

🤝 Contributing

Contribution are very welcome, my software is not perfect and I am happy about everyone who wants to contribute something.