v2.0

Hardware

The scale model: one gate and two bays on a 3D-printed car park, wired to two Arduino boards and an ESP32-CAM, run from a laptop. This page is the short version; the full step-by-step guide lives with the source code, which is kept private.

Circuit diagram drawn in Tinkercad. Top: Arduino Uno R3 with four IR sensors and two common-cathode RGB LEDs, each LED with a 220 ohm resistor. Middle: ESP32-CAM, connected to power only. Bottom: Arduino Uno R4 WiFi with the RFID-RC522 reader, one RGB LED with a 220 ohm resistor, and the MG90S servo.
The circuit, drawn in Tinkercad. The ESP32-CAM is connected to power only; it talks over Wi-Fi.

Parts

QtyPartJob
1Arduino Uno R4 WiFiGate controller
1Arduino Uno R3Bay controller
1ESP32-CAM (AI-Thinker) and a USB programmer for itPlate and face camera, Wi-Fi stream
1RFID-RC522 reader, 13.56 MHz cards or fobsDriver's card
1MG90S micro servoBarrier arm
4IR obstacle sensor modules (output LOW when blocked)Two per bay
3RGB LEDs, common cathode, and 3 × 220 Ω resistorsGate light, one light per bay
2Breadboards, jumper wires, two USB cablesWiring, power and data
1Laptop (macOS or Linux tested: macOS, Apple M1)Site computer

Wiring

Gate controller (Uno R4 WiFi)

PartPinBoard pin
RC522 readerSDA (SS)D10
SCKD13
MOSID11
MISOD12
RSTD9
3.3V3.3V (never 5V)
GNDGND
RGB LEDRed / Green / BlueD2 / D3 / D5
CathodeGND through 220 Ω
MG90S servoSignal (orange)D4
Power (red)5V
Ground (brown)GND

Bay controller (Uno R3)

BayIR sensor AIR sensor BLED redLED greenLED blue
A1 (standard)D2D3D4D5D6
A2 (accessible)D7D8D9D10D11

Sensors take 5V and GND from the board; each LED's cathode goes to GND through 220 Ω. D4 has no PWM on the Uno, so bay A1's red is on or off, which is all the light patterns need.

Flashing

With the Arduino IDE: open each sketch folder, choose the board, upload. Libraries: MFRC522 (Library Manager) and Servo (built in). From the command line:

arduino-cli compile --upload -p <port> --fqbn arduino:renesas_uno:unor4wifi firmware/gate_control
arduino-cli compile --upload -p <port> --fqbn arduino:avr:uno firmware/parking

The camera needs its Wi-Fi details first. Copy secrets.example.h to secrets.h in firmware/ESP32_CameraWebServer/ and fill it in (git ignores it), then upload with the board set to AI Thinker ESP32-CAM (esp32:esp32:esp32cam). The Serial Monitor prints the stream address.

One protocol for both ends

Firmware 2.0.0 speaks the framed protocol. The first build's host program (legacy/main.py) only understands the old firmware, so flash 2.0.0 together with the new site software, not with the old program.

Bench tests

Open the Serial Monitor at 115200 baud on each board, with no site software running.

Gate

  1. On reset the board prints $HELLO,GATE,2.0.0,2*.., then a heartbeat $HB,... every second. The light blinks slowly red: no computer.
  2. Type O: the arm sweeps up and the light turns green. Without the computer it comes back down after about 3 seconds (the silence watchdog).
  3. Type D: the light flashes red for about 2 seconds.
  4. Tap a card: one $RFID,<uid>*.. line, however long you hold it there.

Bays

  1. On reset: $HELLO,PARK,2.0.0,2*..; A1 green, A2 blue.
  2. Cover sensor A of bay A1: after a moment, $SLOT,0,PARTIAL,1,0*.. and the light turns orange. Cover B too: OCCUPIED, red.
  3. Wave a hand quickly over a sensor: nothing changes (150 ms debounce).

Whole system

.venv/bin/python -m smartparking doctor    # finds both boards and the camera, reports what is missing
.venv/bin/python -m smartparking run       # console on http://localhost:5001
Designed, built and tested by Mohammed Ahmed Al-Julandani. Last updated 17 November 2026.