QR Code Solutions

QR Code Gate Automation System

A Practical Guide to Hardware Integration and API Validation

Learn how to build a secure access control barrier using unique QR codes, instant backend validation, and hardware relays. Perfect for parking decks, residential entrances, corporate campus checkpoints, and warehouses.

✓ Token-Based Entry Rules
✓ Sub-100ms API Verifications
✓ Direct Relay Signal Control

TL;DR

  • ✓ The flow: Generate encrypted QR passes with visitor ID, location, and expiration → deliver by SMS/email/wallet → scan at the gate → verify against your API → trigger the physical relay.
  • ✓ Hardware: An IP camera or scanner, a microcontroller (ESP32 or Raspberry Pi), and a relay module wired to the gate engine.
  • ✓ Backend: A Postgres/MySQL database plus a Node.js or Python API endpoint that validates each token before triggering entry.
  • ✓ Built for: Gated communities, paid parking garages, corporate campuses, and warehouse loading bays.

Table of Contents

System Overview & Architecture

How the Gate System Works

  1. 1. Create Unique Identifiers: We generate individual QR codes holding encrypted payloads containing visitor IDs, specific location parameters, and strict expiration rules.
  2. 2. Deliver the Pass: Your application distributes the code as an SVG or PNG to the user via SMS, Apple Wallet link, or automated email.
  3. 3. Scan at the Entry: The driver presents the QR code on their smartphone screen to an external scanner or specialized IP camera mounted at the entrance gate.
  4. 4. Call the Verification API: The scanning unit reads the raw token value and posts it to your central API endpoint over a secured LAN or WAN network.
  5. 5. Trigger the Physical Barrier: Your backend checks the token against the database. If correct, it returns a command to a local microcontroller to trigger the dry contact relay on the gate engine.
  6. 6. Save Logs: Write a row to your logs containing the exact hardware ID, validation speed, and entrance status. This creates a clear digital trail.

Hardware & Software Stack

  • • High-resolution focus cameras (e.g. Hikvision, Dahua)
  • • Microcontroller boards (ESP32 or Raspberry Pi)
  • • Central Postgres or MySQL database
  • • Node.js or Python API backend
  • • Local relay module hardware
  • • Admin interface and monitoring tools

Target Environments

  • • Gated residential neighborhoods
  • • Multi-tier paid parking garages
  • • Corporate campuses and offices
  • • Warehouses and logistics bays
  • • Event venues and concert arenas
  • • Storage unit check-in zones

QR Code Generation Strategy

QR Code Payload Structure

Avoid storing plain-text actions inside the code. Instead, generate a signed JSON schema to prevent tampering:

  • • Pass ID: UUIDv4 format representing the unique database record
  • • Holder ID: ID linking directly to the specific guest or employee profile
  • • Validity Windows: Exact ISO 8601 start and stop timestamps (e.g., 2026-03-01T08:00:00Z)
  • • Gate Group: An array of string keys representing authorized zones (e.g., ["zone_1", "dock_4"])
  • • Cryptographic Signature: An HMAC-SHA256 signature calculated using a secret key held only by your API

Batch Creation Steps

  1. 1. Parse Rules: Define start dates, limit scan count (e.g., single-use or multi-entry), and allowed gate IDs.
  2. 2. Create UUIDs: Write raw rows into your database containing these exact constraints.
  3. 3. Sign the Data: Hash the primary fields using a server key to ensure nobody can alter the expiration dates.
  4. 4. Render QR Images: Build standard high-contrast images with a high error-correction level (Level Q) to withstand phone screen scratches.
  5. 5. Deliver Assets: Send the resulting files instantly via SMS or secure download links.

Built-in Security Checks

  • • Cryptographically signed JSON payloads
  • • Dynamic, short validity windows
  • • Instant single-entry invalidation checks
  • • IP-based scanner rate limits
  • • Live rejection logging to catch card duplication

API Design & Database Schema

Database Design

We structure our database tables with indexes on access keys to support high-speed scanning:

Passes Table

  • id: UUID PRIMARY KEY
  • token_signature: VARCHAR(64)
  • starts_at: TIMESTAMP
  • expires_at: TIMESTAMP
  • usage_limit: INT DEFAULT 1
  • scans_recorded: INT DEFAULT 0
  • is_revoked: BOOLEAN DEFAULT FALSE

Access Logs Table

  • id: UUID PRIMARY KEY
  • pass_id: UUID FOREIGN KEY
  • scanned_at: TIMESTAMP
  • scanner_hardware_id: VARCHAR
  • was_allowed: BOOLEAN
  • rejection_reason: VARCHAR

API Endpoints

POST /v1/access/verify
Receives payload from scanner, verifies validity, and returns open/reject command.
GET /v1/admin/active-passes
Retrieves real-time active passes currently eligible for entry.
POST /v1/passes/issue-batch
Builds thousands of codes in one request for event scheduling.

Validation Rules

  1. 1. Read payload from scanner request.
  2. 2. Run HMAC-SHA256 signature check.
  3. 3. Fetch record from DB index matching token ID.
  4. 4. Confirm current timestamp falls within validity bounds.
  5. 5. Ensure the recorded scan count is lower than usage limits.
  6. 6. Increment DB scan counter and write log entry.
  7. 7. Output relay pulse commands to local hardware controller.

Gate Controller Integration

Physical Hardware List

Scanner Setup

  • • Fixed-focus scan engine (e.g. Grow GM65)
  • • Automated outdoor-rated IP dome camera
  • • Ethernet interface or onboard Wi-Fi chip
  • • IP66 outdoor-rated weatherproof casing

Controller & Board

  • • ESP32 NodeMCU or Raspberry Pi Zero
  • • 5V/12V solid-state relay modules
  • • Dry contact wiring harness connected to motor
  • • Optoisolated ground loop safety sensors

Physical Connection Process

Follow this general outline to hook up your physical access systems:

  1. 1. Wire the Scan Unit: Securely mount the QR scanner camera at vehicle-window height and run an active Ethernet connection.
  2. 2. Set Up the Microcontroller: Flash your ESP32 controller using an HTTPS client script. It should listen for verified open signals.
  3. 3. Link local script: Program the IP camera or scanner to send scanned barcode string events to your custom HTTPS route.
  4. 4. Configure Relays: Connect the controller relay outputs to your barrier gate motor board's standard exit loop terminal.
  5. 5. Wire Vehicle Detectors: Place ground loop detectors beneath the vehicle path to keep the gate arm from closing until vehicles pass safely.
  6. 6. Run End-to-End Tests: Present your generated code, verify backend latency, and measure relay trigger timing.

Security & Validation

Encryption Layer

  • • Signed token payloads via HMAC-SHA256
  • • Dynamic, rolling token options for high security
  • • End-to-end HTTPS backend traffic
  • • Encrypted token columns inside your Postgres DB

Access Safeguards

  • • Single-use enforcement mechanisms
  • • Strict 15-minute entrance windows
  • • Active anti-passback rules
  • • Instant blacklisting for compromised tokens

Defending Against Spoofing

Anti-Duplication Rules

  • • Set dynamic token durations to render screen photos useless.
  • • Apply quick anti-passback locks (e.g. deny reuse for 30 minutes).
  • • Watch for instant double-scans across two separate gates.

Network Security

  • • Keep scanning hardware inside a private VLAN subnet.
  • • Implement device certificates for all physical controllers.
  • • Use strict JSON schema validation for all API routes.

Step-by-Step Implementation

Step 1: Write Your Code Generation Logic

Set up a basic script in Node.js, Ruby, or Python to sign tokens and convert them to images:

  • • Use reliable libraries like Node's qrcode to generate files.
  • • Implement strong SHA256 hashes to prevent ticket forging.
  • • Set error correction to Level Q to handle dim screens.
  • • Generate clean SVGs for high-speed scanning.

Step 2: Initialize Database Schemas

Write SQL schema migrations containing indexed timestamp criteria:

  • • Put active indexes on UUID rows and timestamp boundaries.
  • • Set up automated cleanups for expired passes.
  • • Store metadata (such as guest name and gate ID).
  • • Set up automatic system backups.

Step 3: Program Your Verification Endpoint

Construct the logic parsing barcode scan data at entry points:

  • • Parse raw scanner data immediately.
  • • Check validity windows and cryptographic signatures.
  • • Block access if pass matches current revocation rules.
  • • Send immediate open signals to physical relay components.

Scaling & Performance

Speed Optimization

  • • Store active keys in Redis to process checks under 10ms.
  • • Index database search keys.
  • • Keep database connection pools open.
  • • Implement CDN routing for rapid QR downloads.

Scaling Under High Loads

  • • Scale backend instances across load balancers.
  • • Configure read replicas for large enterprise campuses.
  • • Queue non-blocking entry logs to avoid DB locks.
  • • Implement local database backups for offline operations.

Logging & Dashboards

Operational Stats

  • • Average validation speed in milliseconds
  • • Scanner online/offline status logs
  • • Peak entry and exit times

Security Metrics

  • • Expired pass entry attempts
  • • Bad signature rejections
  • • Failed attempt rates by gate

Hardware Audit Logs

  • • Camera connectivity charts
  • • Total physical gate open cycles
  • • Local relay trigger failures

Troubleshooting & Maintenance

Fixing Common Failures

Scanner Fails to Read Phone Screen

  • • Lower camera exposure times to counter bright phone backlights.
  • • Position a physical hood above the scanner to block outdoor glare.
  • • Verify code size on low-resolution phone screens.

High API Response Times

  • • Verify database connection pool health.
  • • Verify that indexed query paths on key identifiers are functional.
  • • Cache valid pass IDs directly inside memory storage like Redis.

Physical Relay Fails to Open Gate

  • • Test digital GPIO outputs with an electrical multimeter.
  • • Check your 12V/24V controller power line limits.
  • • Confirm ground loops aren't holding the gate engine closed.

Maintenance Checklists

Daily Inspections

  • • Review error logs for validation latency spikes.
  • • Monitor physical barrier opening delays.
  • • Check camera focus and hardware temperature metrics.

Weekly Inspections

  • • Clean physical dust from external camera lenses.
  • • Verify ground safety loop functionality.
  • • Apply latest backend security and library updates.

Build Your Gate Automation System Today

Generate secure QR passes, track gate scans, and keep physical entries protected.