Skip to main content

Gate Opener on Raspberry Pi

This How-To Guide lists 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 a Raspberry Pi for receiving ParkPow webhooks and opening gates.

note

Gate Opener on Raspberry Pi is licensed only for use 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's 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 the whitelist, then the Gate Opener will trigger the gate to open by initiating the appropriate input pin.
  3. ParkPow maintains the whitelist of vehicles. The 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.

Install Gate Opener

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

All the following commands needs to be run on the PI

  1. Install Docker and Docker-Compose on the PI using official instructions available here

  2. Download the Gate Opener App and unzip it. The application content should be as shown below:

    wget https://app.parkpow.com/static/gateserver.zip
    unzip gateserver.zip
    cd gateserver

    Expected Structure:

    ├── configDir
    │   └── config.sample.json
    ├── conftest.py
    ├── docker-compose.yml
    ├── Dockerfile
    ├── parkpow_gate_opener.py
    ├── parkpow_gate_opener_test.py
    ├── README.md
    ├── requirements.txt
    └── test-fixtures
    ├── accessList.csv
    └── vehicles-api.json
  3. Create a configuration file by copying configDir/config.sample.json to configDir/config.json.
    Here's an example with 2 gates and each has its own list of vehicle tags and camera names that are configured with the ParkPow application:

     {
    "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>"
    }
  4. Start Gate Opener with the following commands inside the gateserver folder:

     sudo docker-compose up --build
    # To run in the background, include -d option

Configure Gate Opener

pp-api-token

The <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.

tags

In the Gate Opener 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.

gates

Each gates have its own set of camera names and IO-pin numbers to control them.

pp-update-toggle

Whether to update vehicle access-list from the Parkpow API server. You can also manually edit the whitelist. To do so, just change the contents in the accessList.csv. In that case, disable ParkPow sync with "pp-update-toggle": false.

screenshot

poll-frequency

The frequency (in seconds), in which the access-list is updated from Parkpow API server. The Gate Opener application pulls data from ParkPow based on the poll-frequency variable. In the example below, it is every 20 seconds.

tip

To sync ParkPow with accessList.csv, sign up for a free trial of ParkPow and get the ParkPow API Token. 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

gate-open-period

Number of seconds to wait before closing the gate again.

activity-io-pin

Optional activity monitoring (LED) pin number. In case of updating access-list from API server, the activity is shown using this pin.

Custom Gate IO

If the IO to control the gate requires customization, you can edit the function open_close_gate in parkpow_gate_opener.py. For example, you could do the following:

def open_close_gate(pin_num):
GPIO.output(4, True)
GPIO.output(5, True)
GPIO.output(6, True)

Send Vehicle Information

Configure Stream

  1. Install Stream. Please refer to the Stream Installation Guide.
  2. Configure it to send webhooks to Gate Opener. In Stream Configuration, go to Webhooks and add a new webhook with the following details:
config.ini
[[my-camera]]
webhook_targets = gate-opener

[webhooks]
[[my-webhook-1]]
url = http://192.168.86.25:8010/postJson
image = no
  • In this example, the vehicle details are sent to the Raspberry Pi with IP 192.168.86.25 and port 8010.
  • Images are not used by the Gate Server. We recommend setting image = no.

REST API

If you do not plan to use Stream, you can use the Gate Opener REST API to send visit data.

HTTP Request

POST /postJson

POST Parameters

json

It should have data in the webhook format. Gate Opener is using these specific fields:

  • hook.id
  • data.results[].plate
  • data.results[].orientation
Floating button icon
CTRL + .