How remrc/self-balancing-cube works
Project type and purpose
• This is an embedded real-time control system (“Self-Balancing Cube”) that uses an ESP32 (or optionally an Arduino Nano) to read an IMU (MPU6050), run a balancing algorithm, drive three brushless motors (and encoders in the “esp32_cube_enc” variant), and provide a Bluetooth/serial interface for tuning control parameters and calibration.
File structure
• Top-level firmware variants:
• ESP32_cube/ (original ESP32 code)
• esp32_cube_enc/ (new ESP32 code with encoder support)
• arduino_cube/ (Arduino Nano version)
• Shared functional modules in each variant:
– ESP32.h or arduino_cube.h: low-level pin and peripheral definitions
– functions.ino: hardware‐abstraction functions (IMU read, motor drive, Bluetooth comms)
– main .ino file: setup(), loop(), balancing algorithm and serial/Bluetooth interface
• motors_test/: standalone sketch to verify motor wiring, rotation direction, encoders
README for additional insights
• Hardware: 3S LiPo battery → 5 V regulator → ESP32/Nano + MPU6050 + buzzer + six MOSFET motor drivers → Nidec 24H brushless motors (+ optional encoders)
• Bluetooth interface for live PID tuning (K1/K2/K3) and calibration (c+ / c– commands)
• Two balancing-point setting procedures (edges and vertex) stored in EEPROM