Skip to content

over-engineered checkin-system that can be deployed to a raspberry pi.

License

Notifications You must be signed in to change notification settings

d-rk/checkin-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

checkin-system

over-engineered checkin-system that can be deployed to a raspberry pi.

Raspi Board

Hardware

The system uses a raspberry pi with a custom shield to read RFID tokens and provide visual and acoustic feedback.

Building the raspi shield

For the shield the following parts are needed:

parts list

part description link
RC522 RFID Reader module module to read ids from cards or tokens https://www.amazon.de/gp/product/B01M28JAAZ
PCF8523 RTC module module to record correct timestamps https://www.amazon.de/gp/product/B07LGTX8M9
KY-012 active piezo buzzer acoustic feedback after rfid read https://www.amazon.de/gp/product/B07ZYVH6XM
green/red LED visual feedback after rfid read
2 resistors needed for LED circuits

Schematic

The shield can be build based on the following schematic:

Fritzing

Download the Fritzing File.

Install and configure the raspi

DietPi

The easiest way to install and configure a raspi is by using DietPi.

  1. Download DietPi Image from https://dietpi.com/#download
  2. Flash DietPi_RPi-ARMv8-Bookworm.img.xz to SD card
  3. Go to raspi/dietpi and patch the image ./patch.sh <folder-where-sd-card-is-mounted-to>
  4. After first boot of the PI, run /boot/checkin-system/post-install.sh locally.

After the setup the raspi is available via:

  1. USB Ethernet with ip 192.168.12.1
  2. WLAN Hotspot with ip 192.168.14.1

Manual

When installing a different distribution on the Raspi, the following steps describe the steps needed to get everything running.

Install dependencies:

sudo apt-get update
sudo apt-get upgrade

sudo apt-get install build-essential git python3-dev python3-pip python3-smbus i2c-tools
sudo pip3 install spidev mfrc522

Configure interfaces:

sudo raspi-config

Install docker:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

sudo usermod -aG docker $USER
newgrp docker

sudo pip3 install docker-compose

Software

The software consists of the following parts:

  • postgres database for persistence
  • backend that is attached to the database and provides rest and websocket api
  • frontend for the application, which talks via rest,websocket with the backend
  • python script to interact with the raspi-shield and send rfid reading to the backend

The software can be installed via Docker Compose.

installation

# clone the repository
git clone https://github.com/d-rk/checkin-system.git

# change to the repo dir
cd checkin-system

# build images yourself
docker-compose build --pull

# or pull them
docker-compose pull

# bring up the containers
docker-compose up -d

The frontend will then be accessible under http://localhost:3000/

Connecting to the RASPI

The raspi can be accessed via ssh or http. The WI-FI module of the raspi can be in one of two modes: Hotspot or Wlan Client.

After connecting via ssh you can switch to between Hotspot/Client mode with the following command:

wlan-switch

Via WI-FI (Hotspot)

When the device is in Hotspot mode, connect to the following network:

  • SSID: CheckInHotspot
  • Password: check1n!

Afterward, connect to the raspi:

# http
http://192.168.14.1

# ssh (password: see above)
ssh root@192.168.14.1

Via WI-FI (Client)

When the device is in Client mode, you can look up the ip of the raspi on your router. With this ip you can connect like in Hotspot mode.

Via USB

You can connect the raspi to a PC using a Micro-USB to USB-A Cable. Make sure to use the inner one of the two Micro-USB Ports.

For Windows: You have to install a special driver for this to work. see: https://github.com/d-rk/windows_10_raspi_usb_otg_fix

Afterward, connect to the raspi:

# http
http://192.168.12.1

# ssh (password: see above)
ssh root@192.168.14.1

development

this chapter discribes steps needed when developing the software.

local dev environment setup

  1. Create a postgres in docker:
docker run --name postgres \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=postgres \
    -e POSTGRES_DB=checkin-system \
    -p 5432:5432 -d postgres
  1. Create an .env file for the backend
cat > backend/.env <<- EOM

# sqlite db
#DB_DRIVER=sqlite3
#DB_NAME=checkin.db

# postgres db
DB_HOST=127.0.0.1
DB_DRIVER=postgres
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=checkin-system
DB_PORT=5432
DB_SSL_MODE=disable

CORS_ALLOWED_ORIGINS=*

# days after which checkIn will be deleted
CHECKIN_RETENTION_DAYS=100

# secret to sign bearer tokens with
API_SECRET=yoursecretstring

# token expiry duration
TOKEN_EXPIRY_MINUTES=60

# password for initial admin account
ADMIN_PASSWORD=secret
EOM
  1. Run backend
cd backend
go run ./...
  1. Create an .env file for the frontend
cat > frontend/.env <<- EOM
VITE_API_BASE_URL=http://localhost:8080
# optional admin credentials for auto login 
VITE_API_USER=admin
VITE_API_PASSWORD=secret
EOM
  1. Run frontend
cd frontend
npm start

simplify working with different raspis

To simplify connecting to different raspis via USB and avoiding host key check errors add the following to your ~/.ssh/config:

Host checkin
    HostName 192.168.12.1
    User root
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    Port 22

And then just use: ssh checkin

build/publish docker images

on an arm64 machine clone the repo an run:

# login to quay.io / user-settings / Generate Encrypted Password
export QUAY_IO_PASSWORD=xxx
echo $QUAY_IO_PASSWORD | docker login -u d_rk --password-stdin quay.io

# build and push 
docker buildx bake --push