over-engineered checkin-system that can be deployed to a raspberry pi.
The system uses a raspberry pi with a custom shield to read RFID tokens and provide visual and acoustic feedback.
For the shield the following parts are needed:
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 |
The shield can be build based on the following schematic:
Download the Fritzing File.
The easiest way to install and configure a raspi is by using DietPi.
- Download DietPi Image from https://dietpi.com/#download
- Flash
DietPi_RPi-ARMv8-Bookworm.img.xz
to SD card - Go to
raspi/dietpi
and patch the image./patch.sh <folder-where-sd-card-is-mounted-to>
- After first boot of the PI, run
/boot/checkin-system/post-install.sh
locally.
After the setup the raspi is available via:
- USB Ethernet with ip 192.168.12.1
- WLAN Hotspot with ip 192.168.14.1
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
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.
# 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/
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
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
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.
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
this chapter discribes steps needed when developing the software.
- 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
- 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
- Run backend
cd backend
go run ./...
- 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
- Run frontend
cd frontend
npm start
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
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