Skip to main content

Tafy RDOS Wiring Diagrams

This document provides wiring diagrams for connecting hardware components to build Tafy RDOS compatible robots.

SAFETY FIRST: Always disconnect power before making connections. Double-check polarity. Use appropriate fuses.

Table of Contents

  1. Basic Motor Control Setup
  2. Sensor Connections
  3. Complete Robot Wiring
  4. Power Distribution
  5. Common Issues

Basic Motor Control Setup

ESP32 to L298N Motor Driver

ESP32 DevKit                L298N Motor Driver
┌─────────────┐ ┌──────────────────┐
│ GPIO12├──────────┤IN1 (Motor A) │
│ GPIO14├──────────┤IN2 │
│ GPIO27├──────────┤IN3 (Motor B) │
│ GPIO26├──────────┤IN4 │
│ GPIO13├──────────┤ENA (PWM Speed A)│
│ GPIO25├──────────┤ENB (PWM Speed B)│
│ GND├───────────┤GND │
└─────────────┘ │ │
│ OUT1 ──── Motor A +
│ OUT2 ──── Motor A -
│ OUT3 ──── Motor B +
│ OUT4 ──── Motor B -
│ │
│ +12V ← Battery Pack
│ GND ← Battery GND
│ +5V → ESP32 VIN (optional)
└──────────────────┘

Pin Definitions

// In ESP32 firmware
#define MOTOR_A_IN1 12
#define MOTOR_A_IN2 14
#define MOTOR_B_IN1 27
#define MOTOR_B_IN2 26
#define MOTOR_A_PWM 13
#define MOTOR_B_PWM 25

Alternative: DRV8833 (Lower Power)

ESP32                    DRV8833
┌─────────────┐ ┌────────────┐
│ GPIO12├────────┤AIN1 │
│ GPIO14├────────┤AIN2 │
│ GPIO27├────────┤BIN1 │
│ GPIO26├────────┤BIN2 │
│ 3.3V├─────────┤VCC │
│ GND├─────────┤GND │
└─────────────┘ │ │
│ AOUT1/2 → Motor A
│ BOUT1/2 → Motor B
│ │
│ VMOT ← Battery (2.7-10.8V)
└────────────┘

Sensor Connections

HC-SR04 Ultrasonic Sensor

ESP32                    HC-SR04
┌─────────────┐ ┌──────────┐
│ 5V*├─────────┤VCC │
│ GPIO5├─────────┤Trig │
│ GPIO18├─────────┤Echo │
│ GND├─────────┤GND │
└─────────────┘ └──────────┘

* Note: Use voltage divider for Echo pin (5V → 3.3V):
Echo ──[2.2kΩ]──┬──[3.3kΩ]── GND

└→ GPIO18

VL53L0X ToF Sensor (I2C)

ESP32                    VL53L0X
┌─────────────┐ ┌──────────┐
│ 3.3V├─────────┤VIN │
│ GPIO21├─────────┤SDA │
│ GPIO22├─────────┤SCL │
│ GND├─────────┤GND │
└─────────────┘ └──────────┘

Multiple sensors: Use XSHUT pins with different addresses

MPU6050 IMU (I2C)

ESP32                    MPU6050
┌─────────────┐ ┌──────────┐
│ 3.3V├─────────┤VCC │
│ GPIO21├─────────┤SDA │
│ GPIO22├─────────┤SCL │
│ GND├─────────┤GND │
└─────────────┘ │ │
│ Optional:│
│ INT → GPIO│
└──────────┘

I2C Pull-ups: 4.7kΩ on SDA/SCL to 3.3V

Complete Robot Wiring

Basic Differential Drive Robot

                           Raspberry Pi 4
┌───────────────┐
│ │ USB → Camera
│ │ USB → Power Bank
│ │
│ │ GPIO → Status LED
│ │
└───────┬───────┘
│ USB

ESP32 DevKit
┌─────────┐ ┌──────────────┐ ┌─────────┐
│ Battery ├──────────────┤ ├──────────────┤ L298N │
│ Pack │ │ │ │ Motor │
│ (6V) │ │ GPIO Pins │ │ Driver │
└─────────┘ │ │ └────┬────┘
│ │ │
┌─────────┐ │ I2C Bus │ ┌────┴────┐
│MPU6050 ├──────────────┤ │ │ Motors │
└─────────┘ │ │ │ (2x) │
│ │ └─────────┘
┌─────────┐ │ │
│VL53L0X ├──────────────┤ │
│(Front) │ │ │
└─────────┘ │ │
│ │
┌─────────┐ │ │
│HC-SR04 ├──────────────┤ │
│(Side) │ └──────────────┘
└─────────┘

Pin Assignment Table

FunctionESP32 PinConnected ToNotes
Motor A IN1GPIO12L298N IN1Direction
Motor A IN2GPIO14L298N IN2Direction
Motor A PWMGPIO13L298N ENASpeed
Motor B IN1GPIO27L298N IN3Direction
Motor B IN2GPIO26L298N IN4Direction
Motor B PWMGPIO25L298N ENBSpeed
I2C SDAGPIO21MPU6050, VL53L0XData
I2C SCLGPIO22MPU6050, VL53L0XClock
Ultrasonic TrigGPIO5HC-SR04Output
Ultrasonic EchoGPIO18HC-SR04Input
Status LEDGPIO2Built-in LEDOutput
Emergency StopGPIO0Button to GNDInput

Power Distribution

┌─────────────┐                    ┌─────────────┐
│ USB Power │ │ Battery Pack│
│ Bank │ │ (4xAA=6V) │
│ (5V, 2A+) │ │ or │
└──────┬──────┘ │ 2S LiPo 7.4V│
│ └──────┬──────┘
│ USB-C │
↓ │
┌─────────────┐ │
│ Raspberry │ │
│ Pi 4 │ │
└──────┬──────┘ │
│ USB │
↓ ↓
┌─────────────┐ ┌─────────────┐
│ ESP32 │ │ L298N │
│ (Logic) │ │ Motor Driver│
└─────────────┘ │ │
│ Motors get │
│ full battery│
│ voltage │
└─────────────┘

Single Battery with Buck Converter

         ┌─────────────┐
│ 3S LiPo │
│ (11.1V nom) │
└──────┬──────┘

┌───────┴───────┐
│ │
↓ ↓
┌─────────────┐ ┌─────────────┐
│ Buck Conv. │ │ L298N │
│ 11V → 5V │ │ (Direct) │
└──────┬──────┘ └─────────────┘

┌───┴────┐
↓ ↓
┌──────┐ ┌──────┐
│ Pi 4 │ │ESP32 │
└──────┘ └──────┘

Power Budget

ComponentVoltageCurrent (Typical)Current (Max)
Raspberry Pi 45V600mA3A
ESP323.3V/5V80mA250mA
Motor (each)6V200mA1A
HC-SR045V15mA20mA
VL53L0X3.3V20mA40mA
MPU60503.3V4mA10mA

Total: ~1.2A @ 5V (logic) + 2A @ 6V (motors)

Common Issues

1. Motors Don't Move

  • Check battery voltage (should be >5V for 6V motors)
  • Verify motor driver has power LED on
  • Test with multimeter across motor terminals
  • Check enable pins (ENA/ENB) are connected

2. ESP32 Keeps Resetting

  • Insufficient power - use separate power for motors
  • Add capacitors: 100µF across motor power
  • Check for shorts in wiring

3. Sensors Not Detected (I2C)

  • Add pull-up resistors (4.7kΩ) on SDA/SCL
  • Check with I2C scanner sketch
  • Verify 3.3V power to sensors
  • Common addresses:
    • MPU6050: 0x68 or 0x69
    • VL53L0X: 0x29 (default)

4. Ultrasonic Reading 0 or Max

  • Check voltage divider on Echo pin
  • Ensure clear path in front of sensor
  • Minimum range is ~2cm

5. WiFi Connection Issues

  • Keep ESP32 antenna away from motors
  • Add ferrite beads on motor wires
  • Use shielded cable for long runs

Best Practices

Wire Management

  • Use different colors:
    • Red: Positive power
    • Black: Ground
    • Yellow: PWM signals
    • Green: I2C SDA
    • Blue: I2C SCL
    • Orange: Digital I/O
  • Label connections
  • Use heat shrink tubing
  • Keep motor wires twisted

EMI Reduction

  • Separate motor and logic power
  • Add 0.1µF ceramic capacitors across motors
  • Keep high-current wires away from sensors
  • Use ferrite beads on motor leads

Safety

  • Include emergency stop button
  • Add fuses:
    • 3A for Raspberry Pi
    • 5A for motor circuit
  • Use polarized connectors
  • Insulate all connections

Testing Procedure

  1. Power Off Test

    • Check all connections with multimeter
    • Verify no shorts between power and ground
  2. Logic Power Test

    • Power only Raspberry Pi and ESP32
    • Check voltage levels
    • Test I2C communication
  3. Sensor Test

    • Run I2C scanner
    • Test each sensor individually
  4. Motor Test

    • Start with low PWM (30%)
    • Test one motor at a time
    • Check direction control
  5. Integration Test

    • Run complete system
    • Monitor power consumption
    • Check for overheating

Next Steps

  1. Complete wiring following these diagrams
  2. Upload ESP32 firmware from /firmware/esp32/
  3. Configure HAL for your specific pinout
  4. Follow software setup in QUICKSTART.md
  5. Test with example flows

Need Help?