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


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


13 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.

  3. Hello! I have most of the parts to build this as my independent project. However, looking at the pictures, there are obviously so many other little parts that I do not know. For example, there were the 10 pin and 26 pin ribbon cables as well as the Pi T-Cobbler. Is there a chance that I may be able to have a full list of parts?

    So far I have…
    1. Raspberry PI 3 Model B A1.2GHz 64-bit quad-core ARMv8 CPU, 1GB RAM (Single Board Computer)
    2. 9.7:1 Metal Gearmotor 25Dx48L mm HP 6V with 48 CPR Encoder (Motors 2x)
    3. Pololu Wheel 90x10mm (Wheels 2x)
    4. RF M4 Receiver – 315MHz (RF Receiver)
    5. EasyAcc 6000mAh Ultra-Slim External Battery Smart Output Power Bank Portable Charger with Built-in Micro USB Cable (Battery for Raspberry Pi)
    6. Tenergy 3800mAh (Battery for Motor)
    7. Tenergy Universal Smart 6V – 12V Charger (Battery Charger for Tenergy)
    8. Mini 2-wire Volt Meter (Volt Meter for Motor Battery)
    9. 1 x 4 Keypad (Controls on Robot)
    10. Breadboard Jumper Wire Pack (Jumper Wires)
    11. BerryIMU (IMU)
    12. MD22 – Dual 24Volt 5Amp H Bridge Motor Drive (Motor Driver)
    13. RGB backlight positive LCD 20×4 + extras – black on RGB (Display)
    14. Keyfob 4-Button RF Remote Control – 315MHz
    15. Half-size breadboard
    16. Full sized breadboard
    17. 3 Wood Boards (Base Boards)
    18. Nuts
    19. Screws (small)
    20. Washers
    21. 4x Thread Rods

    If there is anything wrong in the items I have, please notify me. I will post another comment if I have additional questions.
    Thank you! 🙂

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.