# Train a balance bot with reinforcement learning

DevFeed: [Train a balance bot with reinforcement learning](<https://devfeed.tech/articles/train-a-balance-bot-with-reinforcement-learning-104618.md>)

Original publisher: [Read original article](<https://blog.adafruit.com/2026/10/28/train-a-balance-bot-with-reinforcement-learning/>)

Author: Anne Barela

Published: 2026-10-28T16:13:21Z

Content type: tutorial

Language: en

Sources: [Adafruit Industries](<https://devfeed.tech/sources/adafruit-industries-makers-hackers-artists-designers-and-engineers.md>)

Topics: [Reinforcement learning](<https://devfeed.tech/topics/reinforcement-learning.md>), [Fine-tuning](<https://devfeed.tech/topics/fine-tuning.md>)

Tags: [2017](<https://devfeed.tech/tags/2017.md>), [agent](<https://devfeed.tech/tags/agent.md>), [algorithm](<https://devfeed.tech/tags/algorithm.md>), [arduino](<https://devfeed.tech/tags/arduino.md>), [artificial-intelligence](<https://devfeed.tech/tags/artificial-intelligence.md>), [balance](<https://devfeed.tech/tags/balance.md>), [bot](<https://devfeed.tech/tags/bot.md>), [control](<https://devfeed.tech/tags/control.md>), [esp32](<https://devfeed.tech/tags/esp32.md>), [fine-tuning](<https://devfeed.tech/tags/fine-tuning.md>), [guide](<https://devfeed.tech/tags/guide.md>), [language-models](<https://devfeed.tech/tags/language-models.md>), [large-language-models](<https://devfeed.tech/tags/large-language-models.md>), [learning](<https://devfeed.tech/tags/learning.md>), [make](<https://devfeed.tech/tags/make.md>), [models](<https://devfeed.tech/tags/models.md>), [openai](<https://devfeed.tech/tags/openai.md>), [policy](<https://devfeed.tech/tags/policy.md>), [ppo](<https://devfeed.tech/tags/ppo.md>), [published](<https://devfeed.tech/tags/published.md>), [reinforcement-learning](<https://devfeed.tech/tags/reinforcement-learning.md>), [reverse-engineering](<https://devfeed.tech/tags/reverse-engineering.md>), [robot](<https://devfeed.tech/tags/robot.md>), [robotics](<https://devfeed.tech/tags/robotics.md>), [software](<https://devfeed.tech/tags/software.md>), [train](<https://devfeed.tech/tags/train.md>)

## AI overview

The guide trains a two-wheeled balance bot with PPO in Google Colab using MuJoCo, so no local installation is needed. It runs eight parallel environments for 500,000 timesteps each, with separate actor and critic networks, then builds robustness through three curriculum phases: balancing, randomized sensor noise/action delay/motor torque, and randomized nudges, part masses, and wheel friction. The trained actor is exported as ONNX and a C header; the header is added to an Arduino sketch for the M5Stack Bala2-Fire, where its ESP32 runs inference in a 5 ms control loop and maps two outputs to motor PWM. Only the actor is deployed; the critic is used during training.

## Source excerpt

Shawn Hymel wrote a guide in Make: Volume 99 on training a two-wheeled balance bot with reinforcement learning instead of a classical control loop. The agent is trained with proximal policy optimization, or PPO, the algorithm OpenAI published in 2017 that is still used for robot control and for fine-tuning large language models. Training was [...]