Skip to content
Snippets Groups Projects
Select Git revision
  • 242067d059a21860a84cce9507d1ddd4f08fa44b
  • master default protected
  • config
  • piezo
4 results

stechuhr-client

  • Clone with SSH
  • Clone with HTTPS
  • stechuhr-client

    Stechuhr client is python3 service that runs on a client box on the entrance. If somebody swipes their mifare card onto the reader, stechuhr-client reads the input, verifies it and then sends a request to the server. If the response is 200 OK a LED lights up green, if the card is rejected, the server isn't reached or the server denies the card the LED will light red.

    One stechuhr should be placed at the entrance, one at the exit to check in and check out.

    The application is completely multithreaded, that means requests, reading, led blinking etc all run on their own threads and don't block each other.

    LED blinking colors, patterns and timings can be customized in the config, for card verification a list of Regexes (logical OR) can be used.

    Physical Buildup

    A stechuhr client consists of:

    • 1x Raspberry Pi (version 1)
    • 1x WS2812b Module (with a single RGB LED)
    • 1x Meanwell SNT RS 15 5 Netzteil (5VDC, 3A)
    • 1x BOPLA M 238 G Gehäuse mit transparentem Deckel
    • 1x Neutrik NE8FDP-R
    • 1x Power chord + strain relief
    • 1x USB Micro B cable for Power
    • 1x M301 Mifare Card Reader with USB mini B
    • 1x USB mini B to USB A cable
    • 1x short RJ-45 patch cable
    without raspi + reader

    Cable Connections

    What From To Cable
    L, N, PE (230 V~) Power Chord Meanwell PSU Power Chord
    5V for Raspi Meanwell PSU Raspi USB Micro B Input USB Micro B Cable with stripped ends
    Network Neutrik Network connector Raspi Network Connector Short RJ-45 Patch cable
    Mifare Reader USB A jack Raspi USB mini B jack Mifare reader USB-A to USB mini-B cable
    LED module 5V Raspi GPIO 5V 5V WS2812 Module (if more than 1 LED is used consider connecting this to the external PSU 5V) Jumpercable with female pinheader on one side, soldered on the other
    LED module GND Raspi GPIO GND 5V WS2812 Module Jumpercable with female pinheader on one side, soldered on the other
    LED module PWM Raspi GPIO 10 D2 WS2812 Module Jumpercable with female pinheader on one side, soldered on the other

    Installation

    Make sure SPI is enabled on the raspi (raspi-config > Interfacing Options)

    Install the dependecies

    apt install python3 python3-venv python3-dev python3-rpi.gpio

    Run using poetry

    This needs to run with sudo because this is needed for GPIO:

    sudo python3 /home/pi/.poetry/bin/poetry run stechuhr-client

    Run using venv

    python3 -m venv env
    source env/bin/activate
    pip install -r requirements.txt
    python3 stechuhr_client/client.py

    Configuration

    Location, Entrance & Direction

    in config.toml there are three keys that identify a stechuhr.:

    key example values comment
    location main building or main building/cafeteria what place is entered or exited by checking in and out? A sub location is seperated by a forward slash
    direction in or out is the location entered or exited?
    entrance main door, back door, ceiling hatch purely informational to help logging and debugging

    ID verification

    in config.toml you can add a list of regex patterns that stechuhr (both on server and on client!) uses to verify the Card IDs. These two patterns for example allow upper/lowercase hex strings with lengths either between 6 and 16 characters OR exactly 24 characters:

    id_patterns = [
        "^[A-Fa-f0-9]{24}$",
        "^[A-Fa-f0-9]{6,16}$",
    ]

    If in doubt consider testing your regexes here

    LED blinking patterns

    LED blinking patterns can be defined with a list of RGB-tuples. If any of the lists (success_color, success_off_time, success_on_time) is shorter than the number of repitions it is just looped over again.

    success_color  = "[(0, 255, 0), (0, 255, 255), (0, 0, 255), (255, 0, 255), (255, 255, 0)]"
    success_repetitions = 5
    success_off_time = "[0.05]"
    success_on_time = "[0.05]"