PiBBOT V2 – Balancing Robot using a Raspberry Pi

I have spend the last month creating a new version of PiBBOT (Pi Balancing roBOT) , PiBBOT V2.

This version has a sturdier frame and a LCD display. I replaced the 1.8″ TFT with a LCD as the TFT was causing delays in the main loop timing. I also added a very slim battery for the Raspberry Pi.

Main components;

    • RGB backlight LCD 20×4 which shows gyro, accelerometer and complimentary filter angle.
    • Volt Meter to view condition of battery used for motors.
    • RF Receiver RF M4 Receiver – 315MHz. Used to tune PID and then control direction.
    • 1×4 Keypad to turn motors on/off and to reset the gyro.
    • Motors; 9.7:1 Metal Gearmotor 25Dx48L mm with 48 CPR Encoder
    • Wheels; Pololu Wheel 90x10mm
    • IMU; BerryIMU – An accelerometer, gyroscope, magnetometer and barometric/altitude sensor
    • Battery for Motors – 7.2V Tenergy 3800mAh Flat NiMH High Power (38A Drain Rate)
    • Battery for Rasperry Pi – Anker Astro Slim2 4500mAh Ultra-Slim Portable External Battery Charger Power Bank

PiBBOTv2breadboard PiBBOTv2bat1 PiBBOTv2bat2 PiBBOTv2

The code for this project can be found here;


BerryIMU Raspberry Pi Gyroscope Accelerometer
Take a look at two of my previous blog entries for more detail;

Success with a Balancing Robot using a Raspberry Pi
Guide to interfacing a Gyro and Accelerometer with a Raspberry Pi

12 thoughts on “PiBBOT V2 – Balancing Robot using a Raspberry Pi”

  1. This is really a big help, I am trying to build something similar, thank you for your work, I appreaciate that!

  2. Hi Mark,
    I am working with a Minimu-9 v5 and am having a hard time figuring out how to translate your code into a usable format for me. Since I only need the gyro and accel data, I assume I would omit the pieces of code that deal with the magnetometer. Also, would you be able to explain the use of buf in GPIOpinsMotorController.h?

    1. Yes, no need for compass when you are just trying to balance.

      Buf is just a temporary array which is used to write to the i2c device

      buf[0] = 1; // Register to set speed of motor 1 , Right motor.

      if((int)speed+(int)RightFixValue > 254) buf[1] = 254;
      else if((int)speed+(int)RightFixValue< 0) buf[1] = 0; else buf[1] = speed+RightFixValue; if ((write(fd, buf, 2)) != 2) { printf("Error writing to i2c slave\n"); exit(1); }

      An example, in the above code, the value in buf[0] is the register for the motor number and the value in buf[1] is the power to apply. This is then written to the i2c slave.

      BTW: dont let RightFixValue confuse you... I needed it as one motor would spin faster than the other.. I used this to apply more or less power to one motor. If your motors spin at the same speed.. then you dont need it.

Leave a Reply

Your email address will not be published. Required fields are marked *