Skip to the content
2 layers120 × 75 mmSelf Balancing Bot, the printed circuit board in 3D

Self Balancing Bot

Shantu-2580/Prototypes

A two-wheeled self-balancing robot using ESP32, MPU6050 (accelerometer + gyroscope), TB6612FNG motor driver, and Bluetooth gamepad control via Bluepad32.

Size
120 × 75 mm
Copper layers
2
Thickness
1.6 mm
Parts
11
Nets
47
Pads
79
Tracks, vias
104, 3
Pours
1
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
18 Mar 2026
Updated
31 Jul 2026

Overview

Self Balancing Bot is an open-source printed circuit board by Shantu-2580, from the Shantu-2580/Prototypes repository on GitHub. It is a 2-layer board of 120 × 75 mm with 11 parts on 47 nets, routed with 104 tracks and 3 vias.

It is built around the ROB-14450 and L7805. Its parts include 4 ICs, 3 connectors, 2 capacitors and 2 resistors. It belongs with the robots and motor control boards and the ESP32 boards of this library.

Main components

2

README

ESP/Self_Balancing_Bot/README.md

Self-Balancing Bot

A two-wheeled self-balancing robot using ESP32, MPU6050 (accelerometer + gyroscope), TB6612FNG motor driver, and Bluetooth gamepad control via Bluepad32.

Hardware Requirements

ComponentNotes
ESP32 DevKit30+ GPIO pins
MPU6050I2C address 0x68 (SDA=21, SCL=22)
TB6612FNGDual H-bridge motor driver
2x DC MotorsWith encoder support (optional)
LiPo Battery2S-3S (7.4V-11.1V) with voltage regulator
Bluetooth GamepadTested with Xbox/PS4/8BitDo controllers

Pinout

text
ESP32          TB6612FNG          MPU6050
────────────────────────────────────────────
GPIO 33   →    PWMA
GPIO 14   →    AIN1
GPIO 15   →    AIN2
GPIO 32   →    PWMB
GPIO 26   →    BIN1
GPIO 27   →    BIN2
GPIO 21   →    SDA
GPIO 22   →    SCL
3.3V      →    VCC
GND       →    GND

Firmware Files

Codes/P1/P1.ino — Original Version

Status: Reference implementation (has placeholder values)

Features:

  • Basic PID balance control (100Hz loop)
  • Complementary filter for sensor fusion (MPU6050 accel + gyro)
  • Bluetooth gamepad control via Bluepad32
  • TB6612FNG motor driver interface
  • Fall detection safety cutoff (>45°)

Known Issues:

  • ❌ Kp, Ki, Kd, base_setpoint set to Add_Values_Later — won't compile
  • ❌ No calibration routine — base_setpoint must be manually tuned per robot
  • ❌ No integral anti-windup — causes overshoot after disturbances
  • ❌ No motor deadband compensation — motors stall at low PWM
  • ❌ No gamepad deadzone — joystick drift causes unwanted movement
  • ❌ No controller watchdog — robot keeps moving if controller dies
  • ❌ No MPU6050 verification — silent failure if sensor disconnected
  • ❌ No serial telemetry — blind PID tuning

Codes/P1/Program2.ino — Optimized Version

Status: Production-ready with all fixes

All Original Features Plus:

CategoryImprovements
CompilableReal PID defaults: Kp=25.0, Ki=0.8, Kd=1.2
Calibration2-second startup routine averages accelerometer to find base_setpoint automatically
Anti-WindupDual protection: integral clamped at ±400 + integration pauses when output saturates (±255)
Motor DeadbandMIN_PWM=25 ensures TB6612FNG overcomes static friction
Gamepad DeadzoneIgnores joystick input < 20 (prevents center drift)
WatchdogAuto-stops motors if controller disconnects >500ms
Sensor VerifyChecks WHO_AM_I register (0x68) at startup, halts if missing
DLPF ConfigHardware low-pass filter set to 44Hz (accel) / 42Hz (gyro)
Telemetry1Hz serial output: angle, setpoint, PID terms for tuning
I2C OptimizedSingle 14-byte read transaction per loop

PID Tuning Guide (Program2)

Open Serial Monitor at 115200 baud. You'll see:

text
Angle: 0.12 | Setpoint: 0.00 | Out: -15.3 | P: -3.0 I: -0.2 D: -12.1

Tuning Order:

  1. Kp only (set Ki=0, Kd=0): Increase until sustained oscillation, then reduce ~30%
  2. Kd: Add to dampen oscillations (start ~0.5-2.0)
  3. Ki: Small value (0.5-2.0) to eliminate steady-state drift

Tips:

  • Hold robot upright during 2-second calibration (LED on ESP32 blinks during this)
  • Test on carpet first — smoother surface = easier balance
  • If robot falls backward consistently, increase base_setpoint slightly (or add weight forward)
  • Kp typically 20-50, Kd 0.5-3, Ki 0.5-2 for this hardware

Building & Flashing

Arduino IDE

  1. Install ESP32 board package: https://dl.espressif.com/dl/package_esp32_index.json
  2. Install Bluepad32 library via Library Manager
  3. Open Program2.ino, select board ESP32 Dev Module, upload

PlatformIO (Recommended)

ini
; platformio.ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
    ricardoquesada/Bluepad32 @ ^2.0.0
monitor_speed = 115200

Troubleshooting

SymptomLikely CauseFix
Won't compileUsing P1.inoUse Program2.ino
Falls immediatelyPID not tunedFollow tuning guide above
Drifts forward/backWrong base_setpointRe-calibrate (reset ESP32)
Oscillates violentlyKp too high / Kd too lowReduce Kp, increase Kd
Slow to correctKp too lowIncrease Kp
Motors hum but don't turnDeadband too lowIncrease MIN_PWM (try 30-40)
Controller doesn't pairBluepad32 keys storedBP32.forgetBluetoothKeys() runs on startup
MPU6050 not detectedWiring / I2C addressCheck SDA/SCL, try 0x69 (AD0=HIGH)

License

MIT — Feel free to use, modify, distribute.

Parts

11
QtyValueFootprintReferences
24.7KResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR1, R2
10.1uFCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC2
110uFCapacitor_THT:CP_Radial_D5.0mm_P2.00mmC1
1BatteryConnector_Phoenix_MSTB:PhoenixContact_MSTBA_2,5_2-G-5,08_1x02_P5.08mm_HorizontalJ1
1ESP32-DEVKITC-32DESP32-DEVKITC-32D:MODULE_ESP32-DEVKITC-32DU2
1L7805Package_TO_SOT_THT:TO-220-3_VerticalU1
1Motor_LConnector_Phoenix_MSTB:PhoenixContact_MSTBA_2,5_2-G-5,08_1x02_P5.08mm_HorizontalJ2
1Motor_RConnector_Phoenix_MSTB:PhoenixContact_MSTBA_2,5_2-G-5,08_1x02_P5.08mm_HorizontalJ3
1ROB-14450ROB-14450:MODULE_ROB-14450U3
1~MPU_Sensors:UntitledU4

More from Shantu-2580/Prototypes

1
  • 2 layers76.8 × 72.6 mmLM358 Audio Input Sensor, the printed circuit board in 3D

    LM358 Audio Input Sensor

    Shantu-2580/Prototypes

    A two-wheeled self-balancing robot using ESP32, MPU6050 (accelerometer + gyroscope), TB6612FNG motor driver, and Bluetooth gamepad control via Bluepad32.

    25 parts

Similar boards

  • 2 layers65 × 80 mmRobarm kicad, the printed circuit board in 3D

    Robarm kicad

    anbu-05/Robotic-Arm

    a modified-servo based robotic arm project, currently under works

    14 parts
  • 2 layers120 × 100 mmRoot, the printed circuit board in 3D

    Root

    GonzaCerv/noah-hardware

    This repo contains all the hardware description for the Noah project. Here lies 3D models, electronics PCB and Firmware software of the robot.

    127 parts28MIT
  • 2 layers102.6 × 82 mmFun, the printed circuit board in 3D

    Fun

    bonavirak/Line-Follower-Robot-Using-STM32F103C8T6-with-TCRT-5000

    Line Follower Robot powered by STM32F103C8T6 microcontroller, using TCRT5000 5-way sensors for line detection, HC-05 for Bluetooth communication, TB6612FNG motor driver, and N20 motors (1000 RPM).

    38 parts11MIT
  • 2 layers42 × 42 mmControllerBoardSingle v1, the printed circuit board in 3D

    ControllerBoardSingle v1

    0x23/BallJointEmbossingMachine

    A motorized linear embossing machine designed to precisely press ball joints. It was designed to automate the production of balljoint linkages for the Open-Micro-Manipulator.

    20 parts9MIT
  • 2 layers90 × 102 mmPL Toon, the printed circuit board in 3D

    PL Toon

    pl-toon/pl-toon-codes

    PL-TOON material

    39 parts7
  • 4 layers156.8 × 127 mmPayload PCB v3.1, the printed circuit board in 3D

    Payload PCB v3.1

    team-mountaineers-urc-2023/electronics

    Block diagrams, schematics, and PCB files related to the electronics subteam

    197 parts2BSD-3-Clause
  • 2 layers75.6 × 50.2 mmAutónomo, the printed circuit board in 3D

    Autónomo

    lionfer51/SkillBots

    Repositorio oficial de SkillBots (RAS-UNFV)

    20 parts1

Questions

How big is the Self Balancing Bot PCB?

It measures 120 × 75 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Self Balancing Bot use?

11 parts, built around the ROB-14450 and L7805. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Self Balancing Bot KiCad files?

From the Shantu-2580/Prototypes repository on GitHub, at the commit this page was made from: the board is ESP/Self_Balancing_Bot/Self_Balancing_Bot.kicad_pcb and its schematic ESP/LM358_Audio_Input_Sensor/LM358_Audio_Input_Sensor/LM358_Audio_Input_Sensor.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Self Balancing Bot design in my own project?

Its repository states no licence, so its author keeps all rights: ask Shantu-2580 before reusing the design.