// Debug and synchronize communication between the robocar main controller (Heltec WiFi LoRa 32) and camera module (ESP32-CAM)
| name | dual-controller-sync |
| description | Debug and synchronize communication between the robocar main controller (Heltec WiFi LoRa 32) and camera module (ESP32-CAM) |
Apply this skill when the user:
┌─────────────────────┐ I2C ┌─────────────────────┐
│ Main Controller │◄────────────►│ Camera Module │
│ Heltec WiFi LoRa │ │ ESP32-CAM │
│ │ │ │
│ - AI decisions │ │ - Image capture │
│ - Motor control │ │ - Vision analysis │
│ - LoRa comms │ │ - I2C slave │
└─────────────────────┘ └─────────────────────┘
# Build main controller
make robocar-build-main
# Build camera module
make robocar-build-cam
# Or build both
make robocar-build-all
Open two terminals and monitor both:
Terminal 1 - Main Controller:
make robocar-monitor-main PORT=/dev/cu.usbserial-0001
Terminal 2 - Camera Module:
make robocar-monitor-cam PORT=/dev/cu.usbserial-0002
If unsure which device is which:
ls -la /dev/cu.usbserial-* /dev/ttyUSB*
Look for:
| Symptom | Possible Cause | Solution |
|---|---|---|
| No response | Wrong address | Verify 7-bit address format |
| Timeout | Missing pull-ups | Add 4.7K resistors on SDA/SCL |
| Corrupted data | Speed too fast | Reduce I2C clock frequency |
| Intermittent | Loose connection | Check wiring |
Ensure both controllers use the same address:
Main controller (master):
#define CAMERA_I2C_ADDR 0x55 // 7-bit address
Camera module (slave):
#define I2C_SLAVE_ADDR 0x55 // Must match master
Main Controller Camera Module
SDA (21) ◄──────────► SDA (GPIO)
SCL (22) ◄──────────► SCL (GPIO)
GND ◄──────────► GND
Pull-up resistors (4.7K) on SDA and SCL to 3.3V.
Enable verbose I2C logging in both projects:
esp_log_level_set("i2c", ESP_LOG_DEBUG);
Look for matching transactions:
If commands arrive too fast:
Add delay between commands:
i2c_master_cmd_begin(I2C_NUM, cmd, pdMS_TO_TICKS(100));
vTaskDelay(pdMS_TO_TICKS(10)); // Wait for slave to process
# Flash main controller first
make robocar-flash-main PORT=/dev/cu.usbserial-0001
# Then flash camera (requires GPIO0 to GND)
# Connect GPIO0 to GND on ESP32-CAM
make robocar-flash-cam PORT=/dev/cu.usbserial-0002
# Disconnect GPIO0 from GND and reset
For rapid iteration:
make robocar-build-allmake robocar-flash-mainmake robocar-flash-camSymptoms:
Debug Steps:
Symptoms:
Debug Steps:
Symptoms:
Debug Steps:
# Show system info
make robocar-info
# Check environment
make check-environment
# Clean and rebuild
make robocar-clean
make robocar-build-all
# Full dev cycle for main
make robocar-develop-main PORT=/dev/xxx
# Full dev cycle for camera
make robocar-develop-cam PORT=/dev/xxx