Balancerobot Raspberry Pi 3

About the project

Talking BalanceRobot Raspberry Pi 3 written in c++ for Linux Raspberry

Project info

Difficulty: Moderate

Platforms: Raspberry Pi

Estimated time: 4 weeks

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

18650 battery 18650 battery x 1
114990584  ARM Raspberry Pi 3 Model B 114990584 ARM Raspberry Pi 3 Model B x 1
2 x 12V 37mm 350 Rpm 30:1 DC GearMotor with Half Encoder 2 x 12V 37mm 350 Rpm 30:1 DC GearMotor with Half Encoder x 1
RPi Motor Driver Board RPi Motor Driver Board x 1
MPU6050 MPU6050 x 1

Software apps and online services


BalanceRobot Raspberry Pi 3

Project on github:


RPi Motor Driver Board for Raspberry (each channel supply 5a)

MPU6050 (6-axis motion-tracking device that combines a 3-axis gyroscope and a 3-axis accelerometer) With MPU6050 , you can get stable angle when the Kalman filter is used. Place the sensor in the lower section, middle part of robot. I put it in the middle of two dc motors. This prevents oscillations.

2 x 12V 37mm 350 Rpm 30:1 DC GearMotor with Half Encoder

Raspberry Pi 3

18650 battery holder,

The Balance Robot parts are:

For autostart the app on raspberry boot please read below instructions. 

Remote module written in android studio java ,
for controlling robot via Rfcomm serial bluetooth connection.
Please first pair your android device with rapberry pi, and run remote android app on phone than keep it in listening mode. 
After run raspberry pi code with sudo. The default start mode is off (m_IsRunning = false). 
You can press start button from android app to power dc motors
or set m_IsRunning variable to thing you want true or false for start option.

in BalanceRobotPi/main.cpp, plaese change the mac address to your android phone mac address std::string RfCommAndroidMac = "XX:XX:XX:XX:XX:XX";// change it with your phone mac

Building code: 

  1. cd BalanceRobotPi
  2. qmake, make
  4. sudo apt-get install build-essential
  5. sudo apt-get install alsa
  6. sudo apt-get install qt4-default
  7. sudo apt-get install espeak
  8. sudo apt-get install libasound2-dev

Please install build-essential, alsa , qmake and espeak before compile. 

Schematics, diagrams and documents

robot chasis


the main.cpp full project is available on github:



Leave your feedback...