Quick Start Guide
This guide will walk you through setting up your first parking spot sensor, from hardware assembly to seeing live data on the web dashboard.Time Required: ~30 minutes
Difficulty: Intermediate (basic electronics and cloud platform knowledge required)
Difficulty: Intermediate (basic electronics and cloud platform knowledge required)
Prerequisites
Before you begin, ensure you have:Hardware Components
- ESP32 development board (any variant)
- Adafruit VL53L0X Time-of-Flight laser distance sensor
- RGB LED (common anode) with appropriate resistors
- Breadboard and jumper wires
- USB cable for programming
Software Tools
- Arduino IDE or PlatformIO
- Node.js v20+ and npm
- Google Cloud SDK installed and configured
- Firebase CLI (
npm install -g firebase-tools)
Step 1: Deploy the Backend Services
1.1 Deploy Cloud Run Service (Ingest Data)
First, deploy the data ingestion service that receives sensor readings:Save the Cloud Run URL from the output - you’ll need it for the firmware configuration.
1.2 Deploy Cloud Functions
Deploy the supporting Cloud Functions for status retrieval and reservations:1.3 Initialize Firestore Database
The backend services automatically create collections on first write, but you can manually create them:parking_spots- Current state of all parking spacesparking_zones- Zone definitions for organizing spotshourly_snapshots- Historical occupancy data for analytics
Step 2: Hardware Assembly
2.1 Wiring Diagram
Connect the components to your ESP32: VL53L0X Sensor (I2C):- VCC → 3.3V
- GND → GND
- SDA → GPIO 21 (default I2C)
- SCL → GPIO 22 (default I2C)
- Common pin → 3.3V
- Red → GPIO 13 (via 220Ω resistor)
- Green → GPIO 12 (via 220Ω resistor)
- Blue → GPIO 14 (via 220Ω resistor)
The firmware uses common anode logic where LOW = ON. If using common cathode, modify the
setColor() function in the firmware.2.2 Install Required Libraries
In Arduino IDE, install these libraries via Library Manager:Step 3: Configure and Flash Firmware
3.1 Create Secrets File
Copy the example secrets file and configure it with your credentials:arduino_secrets.h with your actual values:
3.2 Flash the Firmware
OpenS-Parking.ino in Arduino IDE:
- Select your ESP32 board from Tools → Board
- Select the correct COM port from Tools → Port
- Click Upload (or press Ctrl+U)
3.3 Monitor Serial Output
Open Serial Monitor (115200 baud) to verify the connection:HTTP 200 response means the data was successfully sent to Cloud Run and written to Firestore.
Step 4: Configure the Web Dashboard
4.1 Set Up Configuration File
Navigate to the web dashboard directory:config.js with your API endpoints:
4.2 Deploy to Firebase Hosting
Your dashboard will be live at
https://YOUR-PROJECT.web.appStep 5: Test the System
Access the Dashboard
Open your Firebase Hosting URL in a browser. You should see the Google Maps interface.
Verify Sensor Data
The sensor you configured (e.g., “A-01”) should appear on the map automatically when it sends its first reading.LED Behavior:
- 🟢 Green: Spot is available (no vehicle detected)
- 🔴 Red: Spot is occupied (vehicle within 400mm)
- 🟡 Amber (Red+Green): Spot is reserved but vacant
Trigger Occupancy Change
Place your hand or an object within 40cm (400mm) of the VL53L0X sensor. Within 500ms, you should see:
- LED turns red immediately
- Serial monitor shows:
Cambio físico detectado: 0 - Dashboard updates to show spot as occupied (within 2 seconds)
Understanding Sensor Logic
The ESP32 firmware implements intelligent state management:Detection Threshold
State Synchronization
The sensor reads locally every 500ms but only sends updates on state changes:This self-healing mechanism ensures the cloud state always reflects physical reality, even after network interruptions.
Troubleshooting
Sensor Not Appearing on Dashboard
- Check Serial Monitor for HTTP response codes (should be 200)
- Verify
SECRET_GCP_URL_INGESTmatches your Cloud Run URL exactly - Check Firestore console - a document with your
spot_idshould exist inparking_spotscollection
LED Not Changing Colors
- Verify wiring - common anode LEDs require LOW to turn on
- Check GPIO pin definitions match your physical connections
- Test individual LEDs with simple blink sketch
Dashboard Shows Stale Data
- Check browser console for errors (F12)
- Verify
GET_STATUS_API_URLin config.js - Clear localStorage:
localStorage.clear()in browser console - Check Page Visibility API isn’t pausing updates (click on the tab)
WiFi Connection Fails
arduino_secrets.h.
Next Steps
Add More Sensors
Clone your working sensor, change the
SECRET_SPOT_ID, and flash new ESP32s. Each sensor operates independently.Create Zones
Use the dashboard’s Builder Mode to organize spots into zones (North Lot, VIP Section, etc.)
Enable Reservations
Configure Firebase Authentication to allow users to reserve spots for specific durations.
View Analytics
Deploy the
save-hourly-snapshot Cloud Function with Cloud Scheduler to build historical occupancy data.Congratulations! You now have a working IoT parking sensor streaming real-time data to the cloud. Ready to dive deeper? Check out the Architecture Guide to understand how all the pieces fit together.