Skip to main content

Overview

Building a Donkeycar requires assembling hardware components on an RC car chassis. This guide covers the recommended components and assembly process.

Computing Platform

Raspberry Pi (Recommended)
  • Raspberry Pi 4 (2GB+ RAM recommended)
  • Raspberry Pi 3 B+ (minimum)
  • Compatible with RaspberryPi OS
  • Powers the car’s AI and control systems
The Raspberry Pi is the preferred on-board computer for Donkeycar. If you’re new to Raspberry Pi, set it up using Raspberry Pi Imager and familiarize yourself with raspi-config before building your car.

Camera Options

Donkeycar supports multiple camera types: Raspberry Pi Camera (PICAM)
  • CSI interface camera
  • Low latency, reliable
  • Most common choice
  • Set CAMERA_TYPE = "PICAM" in config
USB Webcam
  • Standard USB camera
  • Easy to connect
  • Set CAMERA_TYPE = "WEBCAM" in config
Advanced Options
  • CSIC: High-speed CSI camera (e.g., Arducam)
  • D435: Intel RealSense D435 with depth sensing
  • OAKD: Luxonis OAK-D with depth and IMU
  • CVCAM: OpenCV-compatible camera

Motor Controllers

PCA9685 PWM Driver (Most Common)
  • 16-channel PWM controller
  • I2C interface (address typically 0x40)
  • Controls both steering servo and ESC (Electronic Speed Controller)
  • Requires calibration of PWM pulse values
Alternative Controllers
  • RoboHat MM1: Integrated controller for Raspberry Pi
  • Direct PWM Pins: Using Raspberry Pi GPIO
  • PiGPIO: Hardware PWM using pigpio daemon

Drive Train Types

Your configuration depends on your chassis: Standard RC Car (PWM_STEERING_THROTTLE)
  • Steering servo + ESC
  • Most common setup
  • Typical PWM range: 200-500 (12-bit values)
DRIVE_TRAIN_TYPE = "PWM_STEERING_THROTTLE"
Differential Drive (DC_TWO_WHEEL)
  • Tank-style steering
  • Two motors (left/right)
  • Uses H-Bridge motor driver (L298N)
Other Options
  • DC_STEER_THROTTLE: DC motor for steering
  • SERVO_HBRIDGE_2PIN: Servo + 2-pin H-Bridge
  • SERVO_HBRIDGE_3PIN: Servo + 3-pin H-Bridge
  • VESC: VESC motor controller

Chassis

Recommended RC car platforms:
  • Exceed Desert Monster: Popular choice
  • Magnet 1/16 Scale Rally Car: Affordable option
  • Traxxas: Higher-end, durable
  • Custom 3D-printed chassis: For advanced users
Make sure your chassis has enough space for the Raspberry Pi, motor controller, and battery. A 1/10 or 1/16 scale RC car is ideal.

Additional Components

Required
  • Power supply (5V for Pi, battery for motors)
  • MicroSD card (16GB+ for Pi)
  • Jumper wires and connectors
Optional Sensors
  • IMU (Inertial Measurement Unit): MPU6050 or MPU9250
  • LIDAR: RP or YD LIDAR for obstacle detection
  • GPS: For path following
  • Encoders: For odometry and speed measurement

Assembly Steps

1
Prepare the Chassis
2
Start with a working RC car:
3
  • Test the car with its original radio controller
  • Remove the receiver (keep the ESC and servo)
  • Ensure the ESC and servo are working properly
  • 4
    Mount the Raspberry Pi
    5
  • Use standoffs or 3D-printed mounts
  • Position for easy access to ports
  • Ensure camera has clear forward view
  • Protect from vibration and impacts
  • 6
    Connect the Motor Controller
    7
    For PCA9685 Setup:
    8
  • Connect I2C to Raspberry Pi
    • VCC → 5V (Pin 2 or 4)
    • GND → Ground (Pin 6, 9, 14, 20, 25, 30, 34, or 39)
    • SDA → GPIO 2 (Pin 3)
    • SCL → GPIO 3 (Pin 5)
  • Connect to Servo/ESC
    • Channel 0: Typically for throttle (ESC)
    • Channel 1: Typically for steering (servo)
  • Provide power to PCA9685
    • Connect 5-6V to V+ terminal for servo/ESC power
    • Do NOT connect Pi 5V to V+ (they should have separate supplies)
  • 9
    Install the Camera
    10
    For Raspberry Pi Camera (CSI):
    11
  • Connect the ribbon cable to the CSI port on Pi
  • Mount camera with forward-facing view
  • Typical mounting height: 10-15cm above ground
  • Angle slightly downward (about 10-15 degrees)
  • 12
    Wire the Power System
    13
  • Raspberry Pi: Use a stable 5V power supply (recommended: USB-C power bank or DC-DC converter)
  • Motors: Use the RC car’s battery (typically 7.4V LiPo)
  • PCA9685: Can be powered from V+ terminal (5-6V)
  • 14
    Never connect the motor battery directly to the Raspberry Pi. Use a voltage regulator or separate 5V supply.
    15
    Test Connections
    16
  • Power on the Raspberry Pi
  • Verify I2C connection: i2cdetect -y 1
  • Should see PCA9685 at address 0x40
  • Test camera: raspistill -o test.jpg
  • Configuration Pin Mappings

    Standard PWM_STEERING_THROTTLE Setup

    PWM_STEERING_THROTTLE = {
        "PWM_STEERING_PIN": "PCA9685.1:40.1",   # Channel 1
        "PWM_STEERING_SCALE": 1.0,
        "PWM_STEERING_INVERTED": False,
        "PWM_THROTTLE_PIN": "PCA9685.1:40.0",   # Channel 0
        "PWM_THROTTLE_SCALE": 1.0,
        "PWM_THROTTLE_INVERTED": False,
        # Values below are set during calibration
        "STEERING_LEFT_PWM": 460,
        "STEERING_RIGHT_PWM": 290,
        "THROTTLE_FORWARD_PWM": 500,
        "THROTTLE_STOPPED_PWM": 370,
        "THROTTLE_REVERSE_PWM": 220,
    }
    

    Pin Format Explained

    The pin format "PCA9685.1:40.0" means:
    • PCA9685: Controller type
    • 1: I2C bus number
    • 40: I2C address (0x40 in hex)
    • 0: Channel number (0-15)

    Camera Configuration

    # Camera selection
    CAMERA_TYPE = "PICAM"
    
    # Image resolution (affects processing speed)
    IMAGE_W = 160
    IMAGE_H = 120
    IMAGE_DEPTH = 3  # RGB
    
    # Camera orientation
    CAMERA_VFLIP = False  # Vertical flip
    CAMERA_HFLIP = False  # Horizontal flip
    
    # Frame rate (should match DRIVE_LOOP_HZ)
    CAMERA_FRAMERATE = 20
    

    Verifying Your Setup

    1
    Check I2C Devices
    2
    sudo i2cdetect -y 1
    
    3
    Should show the PCA9685 at address 0x40.
    4
    Test Camera
    5
    # For Pi Camera
    raspistill -o test.jpg
    
    # For USB camera
    fswebcam test.jpg
    
    6
    Test Motor Controller
    7
    After creating your car application, test with the calibration tool:
    8
    donkey calibrate --channel=0 --bus=1
    

    Troubleshooting

    Camera not detected
    • Verify cable connection to CSI port
    • Enable camera in raspi-config
    • Check: vcgencmd get_camera
    I2C device not found
    • Enable I2C in raspi-config
    • Check wiring connections
    • Verify 5V power to PCA9685
    Motors not responding
    • Check battery charge
    • Verify ESC/servo connections to PCA9685
    • Ensure V+ on PCA9685 is powered (5-6V)
    • Test with original RC receiver first
    Servo jitters or behaves erratically
    • Add capacitor across PCA9685 power supply
    • Check for loose connections
    • Verify PWM frequency (typically 60Hz)

    Next Steps

    Once your hardware is assembled:
    1. Create your car application with donkey createcar
    2. Calibrate steering and throttle
    3. Start driving and collecting data

    Additional Resources

    Build docs developers (and LLMs) love