Do you use a paper based tally sheet to count your team's coffee consumption? Throw it away and use coffeebuddy!
Coffebuddy uses uv to manage its python dependencies.
-
Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh -
Install dependencies
- RaspberryPi 4
- External SSD to store database
The server runs postgresql and uses certificated based authentication on client side. Details are described in Setting up postgresql database.
- RaspberryPi 3
- 7" touchscreen with 1024x600 pixel resolution
- Identiv uTrust 1401f PCSC cardreader
- 3D printed housing (see doc/housing.md) including:
- a PIR for presence detection (see coffeebuddy/pir.py)
- a multicolor LED for status indication (see coffeebuddy/illumination.py)
-
Install cardreader dependencies If using a PCSC cardreader and a Debian based distributions:
sudo apt install swig libpcsclite-dev pcscd pcsc-tools
-
Install Python dependencies
uv sync
This installs all dependency groups (
coffeemaker,rpi,pcsc,dev). Unneeded groups can be skipped, e.g.:uv sync --no-group rpi
-
Start
productionenvironmentuv run ./bin/run.py
The development environment can be run using
FLASK_DEBUG=1 uv run ./bin/run.pyRun tests with uv run pytest -v tests
The final application uses a Raspberry Pi attached to a 7" touchscreen. Thus, the HTML an CSS is optimized for a display with a resolution of 1024x600.
-
Flash latest RapberryPi OS
-
Fix screen resolution:
# /boot/firmware/config.txt [all] max_usb_current=1 hdmi_force_hotplug=1 hdmi_group=2 hdmi_mode=87 hdmi_cvt 1024 600 60 3 0 0 1 hdmi_drive=2 start_x=1
And change
dtoverlay=vc4-kms-v3dtodtoverlay=vc4-fkms-v3d -
If display has to be rotated by 180° adjust
/etc/X11/xorg.conf.d/40-libinput.confSection "InputClass" Identifier "libinput touchscreen catchall" MatchIsTouchscreen "on" MatchDevicePath "/dev/input/event*" Driver "libinput" Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1" EndSection
Rotate the display by using an autostart file
# ~/.config/autostart/rotate.desktop [Desktop Entry] Name=Rotate Type=Application Exec=xrandr --output HDMI-1 --rotate inverted
-
Install required or helpful packages:
sudo apt install swig libpcsclite-dev pcscd pcsc-tools vim screen unclutter
-
Start chrome once and disable translation option.
-
Clone this repo and install requirements:
git clone https://github.com/hackenbergstefan/coffeebuddy.git cd coffeebuddy curl -LsSf https://astral.sh/uv/install.sh | sh uv sync
-
Create and copy certificates for database connection:
scp coffeebuddyserver:~/coffeebuddy/database/certs/ca/root.crt coffeebuddy01:~/.postgresql/ scp coffeebuddyserver:"~/coffeebuddy/database/certs/client_coffeebuddy01/postgresql.*" coffeebuddy01:~/.postgresql/
-
Create and adjust
config_<client>.py. -
Enable autostart:
mkdir ~/.config/autostart cp raspi/coffeebuddy.desktop ~/.config/autostart/
-
Enable gpio service:
sudo systemctl enable pigpiod
Coffeebuddy works with PCSC reader and with SPI RFID module "RC522". Latter is supported on Raspi by several python modules. Although mrfc522 is widely used it leads to a high CPU consumption when polling for card. pi-rc522 uses interrupt based SPI communication.
Both modules can be used and selected in config.py.