Europe/Istanbul
All Projects

Balancer Robot — Self-Balancing Two-Wheel Platform

From a wobbly breadboard and cheap DC motors to a clean CAD, modular battery pack, and a stable control loop. What we built, how it evolved, and what I personally learned and shipped.
August 8, 2025
Robotics
Self-balancing
PlatformIO
Arduino Nano
ESP32
Control
Bluetooth
ESP-NOW
3D Printing
“If it balances for one second, it will balance for ten — as long as your loop is honest.”
A self-balancing robot is an unforgiving teacher: noisy sensors, actuator dead-zones, and real-time math in a tiny MCU.
We started this project to master closed-loop control end-to-end — sensing, estimation, control, actuation, and power — on hardware we could design and print ourselves.

  • Arduino Nano + breadboard wiring.
  • Cheap DC motors, no gearbox models tuned for learning.
  • 6-DoF IMU (MPU-class), raw complementary filter.
  • Survived the first “it moves!” moment and taught us where the noise lives.
3D printed chassis with straight wheels + DC motors
  • Cleaned up wiring, moved to a dual H-bridge motor driver.
  • Printed PLA frame; repeatable motor placement and gear mesh.
  • Proper rate limiting + actuator linearization; first hands-free recoveries.
Isometric CAD render of the target model
  • Full SolidWorks assembly with serviceable bays, wire channels, and IMU isolation standoffs.
  • Parameterized wheelbase and battery location for quick CoM experiments.
Battery module render (18650-based concept)
  • Rounded wheels (TPU tire + PLA hub) for smoother contact transitions.
  • Modular battery pack (18650-based concept) with protected BMS and quick swap rails.
  • Switched control MCU to ESP32 for more headroom (telemetry + OTA).

Sensors → Estimation → Control → Actuation:
  • IMU (6-DoF): fused angle estimate via complementary filter (tested EKF later).
  • State: pitch angle θ and angular rate ω.
  • Controller: cascaded PI + PD (position loop optional).
  • Actuators: dual DC motors via H-bridge; dead-zone compensation and feed-forward for step torque.
// PlatformIO (Nano/ESP32) — core loop sketch
void loop() {
	const float dt = microsUpdate();                 // ~1–2 ms
	float ax, gy; readIMU(ax, gy);                   // raw accel & gyro
	theta = alpha* (theta + gy*dt) + (1-alpha)*accAngle(ax);   // complementary
	float u = kp*theta + kd*gyroLPF(gy) + ki*integrate(theta); // PD(+I)
	u = applyDeadzoneFF(u, dz, ff);                  // compensate
	setMotorVoltage(constrain(u, -Umax, Umax));      // H-bridge PWM
	sendTelemetryIfNeeded(theta, u);                 // ESP-NOW/BLE
}
				
Key idea: keep the loop timing predictable, filter only what you must, and treat motor dead-zones explicitly.
  • MCUs: Arduino Nano (early), then ESP32 (final) under PlatformIO.
  • Motor driver: dual H-bridge module (high-current version in v3).
  • Power: LiPo pack with buck/boost regulators for MCU and logic rails; separate high-current path for motors; common ground with star routing.
  • Safety: main fuse, reverse-polarity protection, e-stop connector pads on the side panel.

  • Bluetooth UI for quick gains and trims in the field.
  • ESP-NOW telemetry stream (angle, control effort, battery) to a handheld ESP-dashboard.
  • PlatformIO tasks for flashing Nano/ESP, unit tests for math helpers, and serial logging.

  • 3D printing: PLA for structural parts, TPU for tires and soft mounts (IMU isolation).
  • Threaded inserts (M3 heat-set) to avoid self-tapping fatigue.
  • Wheel hubs reinforced with cross-ribs; bearing seats printed undersized and reamed.

Although the team iterated together, I personally delivered these pieces end-to-end:
  • Control loop implementation (sensor fusion, PID tuning, actuator linearization).
  • PlatformIO project setup for Nano and ESP32, build profiles, logging.
  • Motor-driver bring-up, current-limit tuning, and thermal checks.
  • Power distribution: LiPo pack integration, regulators, wiring harness, and safety fuse layout.
  • SolidWorks CAD for v2/v3 chassis and the modular battery concept.
  • Bluetooth and ESP-NOW control/telemetry.

  • Stable balance with gentle disturbances; smooth recovery with rounded TPU wheels.
  • Clean startup sequence (no motor kick), predictable fall-back to safe stop.
  • Repeatable prints; field repair under 10 minutes with spare hubs and tires.

  • Port the estimator to a small EKF for better tilt under acceleration.
  • Add wheel encoders and a velocity loop for tight position hold.
  • Close the mechanical loop on the battery module (spot-welded 18650 carrier + BMS).

TL;DR for hiring managers: I designed and shipped the core control loop, electronics, power, and CAD for a self-balancing robot, moving from Arduino Nano to ESP32 under PlatformIO, integrating H-bridge motor control, LiPo power distribution, Bluetooth/ESP-NOW comms, and 3D-printed hardware (PLA/TPU). It balances — and I can explain exactly why.