How rokasbarasa1/esp32-self-balancing-robot works
This repository implements firmware for an ESP32 self-balancing robot. The main loop reads inertial and magnetic sensors, estimates orientation, applies pitch/yaw and wheel-speed PID control, and drives the motors; a compatible remote can provide movement and yaw commands over nRF24L01. The graph also preserves encoder, SPI, and calibration capabilities. Edges follow the main-loop excerpt, SOURCE INDEX references, or README; unsampled modules are not assumed to participate in the loop.
Main entry points: main.c Control loop · nrf24l01.c nRF24 radio · pid.c PID control · mpu6050.c IMU and fusion
Components 14
Balance control
- Control loop
src/main.c - PID control
lib/pid/pid.c
Sensors and motion
- IMU and fusion
lib/mpu6050/mpu6050.c - Magnetometer
lib/qmc5883l/qmc5883l.c - Optical encoders
lib/optical_encoder/optical_encoder.c - ADXL345 driver
lib/adxl345/adxl345.c
Hardware interfaces
- Motor driver
lib/TB6612/TB6612.c - nRF24 radio
lib/nrf24l01/nrf24l01.c - SPI interface
lib/util/spi/spi.c - ESP-01 interface
lib/esp_01/esp_01.c
Utilities and calibration
- NED coordinates
lib/util/ned_coordinates/ned_coordinates.c - Magnetometer calibration
lib/qmc5883l/calibration/calibration.md
Other components
- Robot operator
- Remote controller
Connections 11
- Robot operator → Control loop: starts robot
README.md - Control loop → IMU and fusion: reads IMU
src/main.c - Control loop → Magnetometer: reads heading
src/main.c - Control loop → Optical encoders: samples encoders
src/main.c - Control loop → PID control: computes control
src/main.c - Control loop → Motor driver: sets motor power
src/main.c - Control loop → nRF24 radio: receives commands
src/main.c - Remote controller → nRF24 radio: sends commands
README.md - nRF24 radio → SPI interface: uses SPI
- Control loop → NED coordinates: uses coordinates
src/main.c - Robot operator → Magnetometer calibration: follows procedure
README.md