Prerequisites
Before starting, ensure you have:- ESP32 development board (NodeMCU-32S or similar)
- Arduino IDE 1.8.x or 2.x
- USB cable (usually USB-A to Micro-USB)
- WiFi network with 2.4 GHz support (ESP32 doesn’t support 5 GHz)
Arduino IDE Configuration
Install ESP32 Board Support
Add the ESP32 board manager URL:
- Open Arduino IDE
- Go to File → Preferences
- Add this URL to “Additional Board Manager URLs”:
- Go to Tools → Board → Boards Manager
- Search for “esp32” and install “esp32 by Espressif Systems”
Install Required Libraries
Install these libraries via Sketch → Include Library → Manage Libraries:
Adafruit VL53L0X(for sensor communication)ArduinoJson(for JSON parsing)HTTPClient(usually pre-installed with ESP32 core)
WiFi Configuration
Creating secrets.h File
The firmware uses aarduino_secrets.h file to store sensitive credentials. This file is not committed to version control.
Configuration Parameters
Your WiFi network name (SSID). Must be a 2.4 GHz network.
WiFi password for authentication.
Cloud Run URL for the
ingest-parking-data function. Used to send sensor status updates.Cloud Run URL for the
get-parking-status function. Used to retrieve reservation status.Unique identifier for this parking spot (e.g., “A-01”, “B-12”). Must match the spot ID in your Firestore database.
WiFi Connection Logic
The firmware implements robust WiFi connection fromS-Parking.ino:205-228:
Connection Behavior
- Retry Logic: Attempts connection 20 times (10 seconds total)
- Auto-Restart: If connection fails, ESP32 restarts automatically
- Station Mode: Uses
WIFI_STAmode (not AP mode) - Serial Feedback: Prints connection status to Serial Monitor at 115200 baud
Flashing Firmware
Compile and Upload
- Click the Verify button (checkmark) to compile
- Fix any compilation errors
- Click the Upload button (arrow) to flash
- Wait for “Done uploading” message
Common Upload Issues
Port not found
Port not found
- Windows: Install CP210x or CH340 USB drivers
- macOS: Driver usually automatic, check System Report → USB
- Linux: Add user to
dialoutgroup:sudo usermod -a -G dialout $USER
Failed to connect to ESP32
Failed to connect to ESP32
- Hold the BOOT button while clicking Upload
- Try reducing upload speed to 115200
- Check USB cable (some cables are power-only)
Brownout detector triggered
Brownout detector triggered
- Power supply insufficient (use USB 3.0 port or powered hub)
- Reduce WiFi power: Add
WiFi.setTxPower(WIFI_POWER_19_5dBm);afterWiFi.begin()
WiFi won't connect
WiFi won't connect
- Verify SSID and password are correct
- Ensure 2.4 GHz WiFi (not 5 GHz)
- Check if network has MAC filtering or captive portal
- Move ESP32 closer to router during testing
Secrets Structure Reference
Thearduino_secrets.h file structure:
Testing Connectivity
After flashing, verify the system works:- Check Serial Monitor for WiFi connection confirmation
- Verify LED lights up green (if no car present)
- Place hand over sensor - LED should turn red immediately
- Check cloud logs in GCP console for incoming requests
- Monitor state synchronization every 15 seconds
Next Steps
Sensor Calibration
Calibrate distance thresholds for accurate detection
LED Indicators
Wire and configure RGB LED indicators