Skip to content

A desk status display and check-in device; written in Python for the Raspberry Pi Zero

Notifications You must be signed in to change notification settings

jprusik/desk-status

Repository files navigation

Desk Status Display and Check-in

This project aims to create an accessible desk-oriented status and check-in system at a low cost at scale. This particular implementation leverages the Robin platform to retrieve and display desk availability information as well as (optionally) allow touch-less desk check-ins with user NFC/RFID cards/tags.

The code provided here is based on mini-ticker, which in turn is based on examples from the pi-rc522 and adafruit-circuitpython-ssd1306 projects.

Requirements

  • Raspberry Pi computer with installed header pins and power source
  • compatible microSD card
  • SSD1306-based 128x64 or 128x32 pixel OLED display
  • (Optional) RC522 module (for RFID/NFC communication)

Setup

Note: This project covers the software setup of your desk status device. For hardware models and assembly, see the desk-status-model project.

  • Install Raspberry Pi OS Lite (formerly, "Raspbian") on a microSD/SD card

  • Set up the Raspberry Pi to run headless and connect it to your network (guide)

    • Add a file named ssh to the root of the SD card.

    • (Optional) set up your network's wifi configuration by adding a file named wpa_supplicant.conf to the root of the SD card. The contents should look like:

      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1
      country=<Insert 2 letter ISO 3166-1 country code here>
      
      network={
       ssid="<Name of your wireless LAN>"
       psk="<Password for your wireless LAN>"
      }
      
    • (Optional) Update your device hostname by editing sudo nano /etc/hostname and /etc/hosts (from "localhost") to your desired name.

  • ssh into the Raspberry Pi:

  • Do sudo raspi-config and set up:

    • "Interfacing Options" > "Interfacing Options" > "I2C" > select "Yes"
    • (Optional) "Localisation Options"
    • set your device's timezone (if not set previously) with timedatectl (e.g. sudo timedatectl set-timezone America/New_York)
    • (Optional) "Change User Password" Important! Because we're using Raspberry Pi OS, the default user is pi with a password of raspberry - it is strongly advised to change the password, at minimum.
  • Install dependencies:

    sudo apt update && sudo apt-get install git python3-pip python3-dev libtiff5-dev libopenjp2-7-dev
  • Clone this repo and cd desk-status

  • Install required packages with pip3 install -r requirements.txt

  • (Optional) Edit /boot/config.txt at the line dtparam=i2c_arm=on and replace it with:

    dtparam=i2c_arm=on,i2c_arm_baudrate=400000
  • (Optional) If using an RC522 module for RFID/NFC communication, edit /boot/config.txt to include the following settings:

    device_tree_param=spi=on
    dtoverlay=spi-bcm2708
    dtparam=spi=on
    

Edit or create .env in the same directory as status_display.py with the following contents:

API_ACCESS_TOKEN="AABBCCDDEEFFGG" # Your Robin API access token
API_DOMAIN_URL="api.robinpowered.com" # The domain for Robin API calls
SEAT_ID=0 # The id of the Robin desk this display is running for
ORG_ID=0 # The id of your Robin organization
TIMEZONE_STRING="America/New_York" # The desk's tz database time zone name ('e.g. America/New_York')
API_POLL_INTERVAL=60 # How many seconds to wait before updating the desk status
RED_GPIO=14 # GPIO pin the red led is attached to
GREEN_GPIO=18 # GPIO pin the green led is attached to
BLUE_GPIO=15 # GPIO pin the blue led is attached to

Running the code

Once the status_display.py script is executed, it will continue to run until the process is terminated. You can manually execute the script on demand, or automatically execute on shell start by editing /etc/profile and appending the following to the end of the file:

python3 /home/pi/desk-status

Alternatively, run the script as a service:

  • Run sudo systemctl --force --full edit deskstatus.service and enter the config:

    [Unit]
    Description=Robin Desk status display
    Requires=network.target
    After=multi-user.target
    
    [Service]
    WorkingDirectory=/home/pi/desk-status
    User=pi
    ExecStart=python3 .
    ExecStopPost=python3 -c 'import status_display; status_display.shutdown()'
    
    [Install]
    WantedBy=multi-user.target
    
  • Enable the service with sudo systemctl enable --now deskstatus.service, and start it with sudo systemctl start deskstatus.service

Notes

  • This build assumes Raspberry Pi Zero hardware - no other Raspberry Pi hardware has been tested with this code.
  • Ubuntu Font Family is included in /fonts by default. If you wish to use a different font, add them to the /fonts directory and update the import references in status_display.py (note, line spacing currently presumes Ubuntu fonts and may require adjustments when using other fonts).
  • ProTip: You can access the the target pi on your network using the pi's network DNS reference (raspberrypi by default). This is particularly useful if your network has dynamic IP address assignment; you can simply ssh pi@raspberrypi.local)