Design and Implementation of a Two-Wheel Self-Balancing Robot Using PID Control on an ESP32: Custom PCB, Simulink-generated controller, and a Wi-Fi control panel with OTA updates

This report describes the design and construction of a two-wheeled self-balancing robot, from the hardware to the control software. The robot runs on an ESP32 and reads its tilt angle from an MPU-92/65 IMU. It is powered by Li-ion cells, with an ATtiny13A as a secondary microcontroller that keeps the board in a safe state and resets the ESP32 during firmware updates. I designed a two-layer PCB in Altium Designer that also leaves room for a camera and a servo for later additions. The balancing controller is a positional PID built from basic Simulink blocks, with a low-pass filter on the roll signal. C code generated with Embedded Coder was integrated into a C++ program that uses FreeRTOS and ESPAsyncWebServer. A web control panel served by the robot lets the user change controller parameters, monitor the IMU data at about 200 Hz, read non-volatile system logs, and upload new firmware over the air. During testing, the geared DC motors stalled when the PWM command changed by more than 470 counts at once, so a rate-limiting stage was added before the motor output. Two physical models of the robot were tried, but neither gave usable PID gains. A transfer function identified from 120 s of roll data sampled at 200 Hz reached only a 24.49% fit. The gains were therefore tuned experimentally through the control panel, which gave a steady-state error of about 0.3 degrees. Remote driving and live camera streaming are planned as future work.

Authors

Publication Details

Journal
Engineering Archive (engrXiv)
Published
2026-11-20
DOI
https://doi.org/10.31224/8857
Primary Topic
Control and Dynamics of Mobile Robots
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

Design and Implementation of a Two-Wheel Self-Balancing Robot Using PID Control on an ESP32: Custom PCB, Simulink-generated controller, and a Wi-Fi control panel with OTA updates

Mohammad Sina Majidi
2 links
Engineering Archive (engrXiv)
Control and Dynamics of Mobile Robots
preprint

Design and Implementation of a Two-Wheel Self-Balancing Robot Using PID Control on an ESP32: Custom PCB, Simulink-generated controller, and a Wi-Fi control panel with OTA updates

Mohammad Sina Majidi
preprint en

Abstract

This report describes the design and construction of a two-wheeled self-balancing robot, from the hardware to the control software. The robot runs on an ESP32 and reads its tilt angle from an MPU-92/65 IMU. It is powered by Li-ion cells, with an ATtiny13A as a secondary microcontroller that keeps the board in a safe state and resets the ESP32 during firmware updates. I designed a two-layer PCB in Altium Designer that also leaves room for a camera and a servo for later additions. The balancing controller is a positional PID built from basic Simulink blocks, with a low-pass filter on the roll signal. C code generated with Embedded Coder was integrated into a C++ program that uses FreeRTOS and ESPAsyncWebServer. A web control panel served by the robot lets the user change controller parameters, monitor the IMU data at about 200 Hz, read non-volatile system logs, and upload new firmware over the air. During testing, the geared DC motors stalled when the PWM command changed by more than 470 counts at once, so a rate-limiting stage was added before the motor output. Two physical models of the robot were tried, but neither gave usable PID gains. A transfer function identified from 120 s of roll data sampled at 200 Hz reached only a 24.49% fit. The gains were therefore tuned experimentally through the control panel, which gave a steady-state error of about 0.3 degrees. Remote driving and live camera streaming are planned as future work.

Engineering Archive (engrXiv)
Industry, innovation and infrastructure
Control and Dynamics of Mobile Robots
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon