Skip to main content

Gate Opener on Raspberry Pi

This How To Guide lists out the steps required to successfully run Plate Recognizer Gate Opener on a Raspberry Pi. Additional components are required and described in this document below. The server application is designed to be run on Raspberry Pi for receiving ParkPow webhooks and opening gates.

note

Gate Opener on Raspberry Pi is licensed only to be used with an active subscription to Plate Recognizer Stream, Plate Recognizer Snapshot SDK or ParkPow. Any usage or integration of Gate Opener outside of these applications is a violation of Plate Recognizer and ParkPow Terms and Conditions.

Architecture Overview#

Gate Opener works in the following manner:

  1. This application takes license plate readings from Plate Recognizer Stream. Whenever a vehicle plate is detected, Stream sends the LPR readings via webhooks to the Gate Opener.
  2. The Gate Opener compares the license plate against a local whitelist database. If the LPR reading matches against the whitelist, then Gate Opener will trigger the gate to open by initiating the appropriate input pin.
  3. ParkPow maintains the whitelist of vehicles. Gate Opener periodically pings ParkPow for the latest list of vehicles and updates the local whitelist database accordingly.

Set Up the Hardware#

Gate Opener is intended to interface with the Nexus 220 through the reader input terminals.

It does this by setting the RTE pin to HIGH or LOW.

  • LOW -> indicates that the relay should close and the gate should open.
  • HIGH -> indicates that the relay should remain open and the gate should close.

Each IO Pin is mapped to a reader input. For example:

PinInput
GPIO 5 (Gate 1)READER 1 INPUT(RTE)
GPIO 6 (Gate 2)READER 2 INPUT(RTE)
GPIO 13 (Activity Pin)May function as an "Activity" light Pin goes HIGH when the server is refreshing it's access lists. An LED may be connected with a series resistor.
Raspberry Pi GNDREADER 1 GND, READER 2 GND …
tip
  • If you plan to use a wire connection, please insert the Ethernet cable.
  • It does not matter which GND pins you connect to the READER INPUTS. It only matters that the GND pins on both READER INPUTS are connected to the GND pins on the Raspberry Pi.

Configure Stream#

To configure Stream, feel free to refer to the Stream Installation Guide.

  1. The Gate Opener on the Pi receives ParkPow data through port 8010.
  2. To forward data, you should modify Stream to forward all LPR results to the Raspberry Pi's IP Address and Port.
  3. For example, if Pi is at IP Address 192.168.86.25 then the config.ini should have the following:
    webhook_target = http://192.168.86.25:8010/postJson
  4. We recommend adding a field so that images are not forwarded to the Gate Opener:
    webhook_image = no

Connect to the Raspberry Pi#

  1. You will first have to find the IP address on the Pi. If your device is connected to the same network then you can use multicastDNS to automatically find the IP address.
  2. To connect to the Raspberry Pi, we recommend you use PuTTY.
    1. On your computer, open PuTTY and enter the Host Name as raspberrypi.local and press open. Putty Configuration
    2. If everything goes according to plan, you’ll be prompted with a security prompt. Press “Yes”
    3. This will open a terminal and ask for a Username and Password. The username is “pi” and the password is “raspberry“. After entering the credentials, you’ll get logged on to the Raspberry Pi terminal. Putty PI Shell

Install Gate Opener on Raspberry Pi#

Install Docker and Docker-Compose on the device. The following series of commands install the docker to the device:

  1. On your computer, open PuTTY and enter the Host Name as raspberrypi.local and press open.

    sudo apt-get update# a convenient script that installs docker to the systemcurl -fsSL https://get.docker.com -o get-docker.shsudo sh get-docker.shsudo systemctl enable dockersudo docker info
  2. The following set of commands will install docker-compose to the device.

    sudo apt install libffi-dev libssl-dev python3-dev python3-pipsudo pip3 install docker-composesudo docker-compose --version
  3. Download the Gate Opener App and unzip it. The application content should be as shown below:

    wget https://app.parkpow.com/static/gateserver.zipunzip gateserver.zipcd gateserverls# Expected output:# Dockerfile  README.md  configDir  docker-compose.yml  parkpowGateOpener.py  requirements.txt  test_parkpow_gate_opener.py

    screenshot

  4. The configuration file needs to be created manually from configDir/config.sample.json. We will create a config file for the example shown in Table 1 to the path configDir/config.json

    {"poll-frequency": 20,"pp-update-toggle": true,"gate-open-period": 2,"activity-io-pin": 13,"gates": [{    "cameras": [    "gate1_cam1",    "gate1_cam2"    ],    "tags": [    "gate1_tag1",    "gate1_tag2"    ],    "io-pin": 5},{    "cameras": [    "gate2_cam1",    "gate2_cam2"    ],    "tags": [    "gate2_tag1",    "gate2_tag2"    ],    "io-pin": 6}],"pp-api-token": "<token>"}

    In the above example, we have 2 gates and each has its own list of vehicle tags and camera names that are configured with the ParkPow application. The configuration variables are explained this table.

NameNotes
poll-frequencyThe frequency (in seconds), in which the access-list is updated from Parkpow API server.
pp-update-toggleWhether to update vehicle access-list from the Parkpow API server.
gate-open-periodNumber of seconds to wait before closing the gate again.
activity-io-pinOptional activity monitoring (LED) pin number. In case of updating access-list from API server, the activity is shown using this pin.
gatesEach gates have its own set of camera names and IO-pin numbers to control them.
pp-api-tokenThe <token> should be replaced with the correct token which is used to fetch details from ParkPow REST APIs. Go here to locate the ParkPow API Token.
  1. After the file is created, now the content of the folder would look like this:

    |-- Dockerfile|-- README.md|-- configDir|   |-- config.json|   |-- config.sample.json|-- docker-compose.yml|-- parkpowGateOpener.py|-- requirements.txt|-- test_parkpow_gate_opener.py
  2. We will now copy the application to the Pi using the command pscp which comes installed with the PuTTY shell.

    pscp -r . pi@raspberrypi.local:/home/pi/parkpow-app
  3. We will now start Gate Opener with the following commands inside the PuTTY shell.

    cd /home/pi/parkpow-appsudo docker-compose build# Verify that the app can be run.sudo docker-compose run --rm app pytest# Start the app service.# To start the app in the background, do sudo docker-compose up -dsudo docker-compose up

Configure Gate Opener#

  1. In the Gate Opener gates.tags configuration file, make sure to appropriately indicate the “tags”. In the example below, all vehicles that are tagged as “Management, Tenant and Visitor” in ParkPow will trigger the gate to open.

    screenshot

    1. Inside ParkPow Settings > Manage Vehicles, you can upload a spreadsheet with the license plate, Vehicle Tag and other information you want to include.
    2. You can also add a new vehicle with specific Vehicle Tag one at a time.
    3. When you click on a specific vehicle in the Main Dashboard and go into the Vehicle Details Page, you can also edit an existing vehicle’s Vehicle Tag.
  2. The Gate Opener application pulls data from ParkPow based on the poll-frequency variable. In the example below, it is every 20 seconds.

    tip

    Whenever Gate Opener pings ParkPow, it rewrites the accessList.csv. So this means that the new data pull will replace all of the existing plates in the Gate Opener database. In other words, the access.List.csv file is refreshed every 20 seconds.

    screenshot

  3. You can also manually edit the whitelist. To do so, just change the contents in the accessList.csv.

    tip

    You will need an active ParkPow subscription to in order to edit the accessList.csv. You can sign up for a free trial of ParkPow and get the ParkPow API Token.

    screenshot