/rad_raspberry

Primary LanguagePythonMIT LicenseMIT

rad_raspberry

This is a CLI tool that runs on Linux and macOS that will read badge swipes from a card reader via standard input to take attendance and record the data to Supabase.

Installation

This tool is designed to be deployed on Raspberry Pis running in headless mode, which you can setup through the Raspberry Pis’ system settings. Install this tool using pip:

pip install -U git+https://github.com/sxg/rad_raspberry

Note: you might need to add the --break-system-packages flag at the end to install the tool globally. You can confirm the installation and version with pip show rad_raspberry.

Config

A config.ini file is required and located at ~/.config/rad_raspberry/config.ini. Here are the required values in a sample config.ini file:

[API]
supabase_url = <Supabase URL>
supabase_api_key = <Supabase API Key>
supabase_username = <Supabase Username>
supabase_password = <Supabase Password>

[Operation]
# When to stop accepting swipes (24 hr time in local timezone)
close_time = 09:00
location = HUP

close_time specifies when the script stops running for the day. location is a text description that uniquely identifies the Raspberry Pi. This is represented as an enum in the Supabase attendance table, so if you want to use a new value here, be sure to also add it to the defined enum in Supabase.

Updates

You can update this tool with the same command you used to install it:

pip install -U git+https://github.com/sxg/rad_raspberry

This will install the latest committed version on the main branch. Remember to update the version number of the tool in setup.py.

Automatic Reboot

Since the Raspberry Pi will typically be connected to a guest WiFi network, it's at risk of periodically being kicked off the network. To workaround this, set a cron job to automatically and periodically restart the Raspberry Pi. Use sudo crontab -e to edit the cron job file, and add this line:

0 4 * * * /usr/sbin/shutdown -r now

This will automatically restart the Raspberry Pi every day at 4 am, and on startup, it should automatically reconnect to the same WiFi network with a fresh connection.