This paper presents the hardware implementation of a modular two-wheeled self-balancing robotic platform designed to support multiple real-world applications through a swappable sensor and module architecture. The system employs a dual-controller design where an ESP32 microcontroller executes a cascaded PID control algorithm for real-time balance stabilisation, using tilt angle data acquired from an MPU6050 Inertial Measurement Unit. DC motors fitted with incremental encoders provide closed-loop speed feedback, enabling precise wheel actuation. A Raspberry Pi serves as the high-level controller, handling computer vision tasks independently from the balancing loop, ensuring that processing overhead does not affect stability. A line-following module is demonstrated as a practical application, implemented using OpenCV on the Raspberry Pi, which relays directional commands to the ESP32 via I2C communication. The physical platform follows a three-tier modular chassis design fabricated from mild steel that allows application-specific hardware to be integrated or removed without modifying the core control system. Experimental results confirm stable balancing and reliable autonomous line-following behaviour, validating both the control strategy and the modular hardware concept. The platform offers a cost-effective and reconfigurable foundation for applications spanning smart agriculture, service robotics, and autonomous navigation.
Introduction
The paper focuses on the development of a low-cost two-wheeled self-balancing robot designed for educational and research purposes. Self-balancing robots are important in robotics research because they represent the classical inverted pendulum problem, requiring continuous feedback and dynamic stabilisation to maintain balance. Existing commercial and research-grade platforms are often expensive and inflexible, limiting their accessibility in resource-constrained environments. To address this gap, the study proposes an affordable and modular robotic platform that separates real-time balancing tasks from higher-level processing functions.
The robot uses a dual-controller architecture. An ESP32 microcontroller manages time-critical balancing operations through a cascaded PID control system using real-time orientation data from an MPU6050 Inertial Measurement Unit (IMU). A Raspberry Pi acts as a high-level processor, handling computer vision tasks such as line following using OpenCV without interfering with the balancing loop. DC motors with incremental encoders provide closed-loop speed feedback for precise wheel control. The system is built entirely with widely available and low-cost components, making it practical and reproducible for educational institutions and researchers.
The study highlights the relevance of the project to Sustainable Development Goals (SDG 4 and SDG 9) by promoting accessible robotics education and inclusive technological innovation. The literature review discusses existing approaches to self-balancing robots, including PID-based controllers, advanced fuzzy logic and hybrid control systems, and application-oriented robotic platforms. While previous studies improved balancing accuracy and autonomous capabilities, many relied on expensive hardware or lacked a clear separation between real-time control and application-level processing. The proposed platform addresses this research gap by combining affordability with an efficient dual-controller design.
The system architecture is divided into four major subsystems: power, sensing, control, and actuation. A Lithium Polymer battery powers the robot, with voltage regulation handled through a buck converter. The sensing subsystem relies on the MPU6050 IMU for tilt estimation and a webcam for visual line detection. The ESP32 continuously executes the balancing PID algorithm, while the Raspberry Pi processes image data and sends movement commands through an I2C interface. Actuation is achieved using DC motors controlled by a BTS7960 motor driver, which offers higher efficiency and current handling than conventional drivers. The mechanical design uses a three-tier mild steel chassis with an elevated center of mass, enabling stable inverted pendulum dynamics necessary for self-balancing behavior.
Conclusion
This paper presented the design and hardware implementation of a low-cost two-wheeled self-balancing robotic platform built around a dual-controller architecture. The system addressed a practical gap in existing literature by demonstrating a clean and deliberate separation between real-time balance control and higher-level vision-based task execution within an affordable embedded hardware framework. An ESP32 microcontroller was dedicated entirely to cascaded PID-based tilt stabilisation, processing orientation data from the MPU6050 DMP at a fixed sampling rate, while a Raspberry Pi handled OpenCV-based line following independently without imposing any computational burden on the balancing loop. DC motors with incremental encoders provided closed-loop wheel speed feedback, and the BTS7960 motor driver delivered reliable high-current actuation throughout operation.
Simulation-based validation in CoppeliaSim, Proteus 8, and Tinkercad confirmed the viability of the control strategy and motor selection prior to hardware assembly. Physical testing demonstrated stable balancing performance and successful autonomous line following on a structured track, validating both the control implementation and the dual-controller communication model over I2C. The mild steel three-tier chassis provided a rigid and well-organised mechanical platform accommodating all subsystems within a compact footprint.
Beyond its technical contributions, the platform demonstrates that meaningful control systems complexity — including sensor fusion, cascaded feedback control, closed-loop motor regulation, and computer vision — can be realised at low cost using widely available components. This makes it a genuinely practical tool for undergraduate robotics and control systems education, directly contributing to the goals of SDG 4 on Quality Education and SDG 9 on inclusive technological innovation.
References
[1] A. Abdelgawad, T. Shohdy, and A. Nada, “Model- and data-based control of self-balancing robots: Practical educational approach with LabVIEW and Arduino,” arXiv preprint arXiv:2405.03561, 2024.
[2] H. Khabazi and M. Shariyat, “Control and simulation of autonomous navigation of a self-balancing robot,” in Proc. 12th RSI Int. Conf. Robotics and Mechatronics (ICRoM), Tehran, Iran, pp. 226–232, 2024.
[3] J. Chen, N. He, Z. Xu, M. Dou, and L. He, “Design and implementation of a novel two-wheeled composite self-balancing robot for stationary operations in unknown terrain,” IEEE Access, vol. 13, pp. 86032–86045, 2025.
[4] S. Sarathy, M. H. M. M., S. Kalaivani, and A. S., “Implementation of efficient self balancing robot,” in Proc. Int. Conf. Recent Trends in Electrical, Control and Communication (RTECC), Chennai, India, 2018.
[5] N. T. and P. K. T., “PID controller based two wheeled self balancing robot,” in Proc. Fifth Int. Conf. Trends in Electronics and Informatics (ICOEI), Bangalore, India, 2021.
[6] C. Iwendi, J. H. Anajemba, M. A. Alqarni, A. S. Alfakeeh, Z. Zhang, and A. K. Bashir, “Robust navigational control of a two-wheeled self-balancing robot in a sensed environment,” IEEE Access, 2019.
[7] A. D. Diallo, S. Gobee, and V. Durairajah, “Autonomous tour guide robot using embedded system control,” in Proc. IEEE Int. Symp. Robotics and Intelligent Sensors (IRIS), vol. 76, Kuala Lumpur, Malaysia, pp. 126–133, 2015.
[8] R. Shukla, A. R., and J. Ramprabhakar, “Automatic self balancing robot for crop monitoring,” Research Article, 2023.
[9] S.-K. Kim and C. K. Ahn, “Self-tuning position-tracking controller for two-wheeled mobile balancing robots,” IEEE Trans. Circuits Syst. II: Express Briefs, vol. 66, pp. 2019–2026, June 2019.
[10] H. P. Santoso, H. Maghfiroh, J. S. Saputro, and M. M. M. Dinata, “Balancing robot navigation with virtual map and virtual sensor,” in Proc. Int. Conf. Radar, Antenna, Microwave, Electronics, and Telecommunications (ICRAMET), Surakarta, Indonesia, pp. 218–223, 2020.
[11] S. R. Garces et al., “Hybrid self-balancing and object tracking robot using artificial intelligence and machine vision,” in Proc. 2nd Novel Intelligent and Leading Emerging Sciences Conf. (NILES), pp. 264–269, 2020.
[12] N. T and P. K T, “PID Controller Based Two Wheeled Self Balancing Robot,” in 2021 5th International Conference on Trends in Electronics and Informatics (ICOEI), Tirunelveli, India, 2021, pp. 1–4.