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.
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.
Gate Opener works in the following manner:
- 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.
- 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.
- 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:
|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 GND||READER 1 GND, READER 2 GND …|
- 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
- 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.
- To connect to the Raspberry Pi, we recommend you use PuTTY.
- On your computer, open PuTTY and enter the Host Name as raspberrypi.local and press open.
- If everything goes according to plan, you’ll be prompted with a security prompt. Press “Yes”
- 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.
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:
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 system
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo systemctl enable docker
sudo docker info
The following set of commands will install docker-compose to the device.
sudo apt install libffi-dev libssl-dev python3-dev python3-pip
sudo pip3 install docker-compose
sudo docker-compose --version
Download the Gate Opener App and unzip it. The application content should be as shown below:
# Expected output:
# Dockerfile README.md configDir docker-compose.yml parkpowGateOpener.py requirements.txt test_parkpow_gate_opener.py
The configuration file needs to be created manually from
configDir/config.sample.json. Here's an example
configDir/config.jsonwith 2 gates and each has its own list of vehicle tags and camera names that are configured with the ParkPow application:
After the file is created, now the content of the folder would look like this:
| |-- config.json
| |-- config.sample.json
pscp -r . [email protected]:/home/pi/parkpow-app
We will now start Gate Opener with the following commands inside the PuTTY shell.
# it is recommended to run the app as a non-root user. www-user is a non-root user and is available in the distro by default.
sudo chown -R www-data:www-data .
# now build the docker image
sudo docker-compose build --build-arg USER_ID=$(id -u www-data) --build-arg GROUP_ID=$(id -g www-data)
# 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 -d
sudo docker-compose up
Configure Gate Opener
<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.
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.
- Inside ParkPow Settings > Manage Vehicles, you can upload a spreadsheet with the license plate, Vehicle Tag and other information you want to include.
- You can also add a new vehicle with specific Vehicle Tag one at a time.
- 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.
Each gates have its own set of camera names and IO-pin numbers to control them.
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
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.
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.
Number of seconds to wait before closing the gate again.
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
parkpow_gate_opener.py. For example, you could do the following:
Send Vehicle Information
- Install Stream. Please refer to the Stream Installation Guide.
- Configure it to send webhooks to Gate Opener. In Stream Configuration, go to Webhooks and add a new webhook with the following details:
webhook_targets = gate-opener
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.
If you do not plan to use Stream, you can use the Gate Opener REST API to send visit data.
It should have data in the webhook format. Gate Opener is using these specific fields: