Hello friends this post is about DIY self balancing robot in this post I’ll show how you can build your own Self balancing robot.
I have tried to build the project but failed not get results as expected.
but this robot turn out quite good and accurate, though this is not perfect but best as compare to my previous bots.
I have use a custom made PCB, Arduno nano, MPU6050, A4988 driver, HC-05 bt module, MDF board and some hardware to build this self balancing robot,
detail material list you can found further in this post.
Balancingwii firmware and EZ-GUI android app is used in this project to control robot via Bluetooth connection.
I have prepare a PCB also you can download the Gerber file to order PCB or you can also edit the PCB in easyeda platform.
I have order this PCB from JLCPCB.COM there is a good reason to choose JLCPCB as PCB partner is that first they are providing high quality PCB in affordable price and second they have very fast manufacturing time so you get PCB in very short time.
I suggest you if you have any PCB need kindly check out JLCPCB.COM
The basic and minimal connection you must needs are as follow.
- A4 – SDA
- A5 – SCL
Motor driver pins:
- D5 – STEP1 (PORTD 5)
- D6 – STEP2 (PORTD 6)
- D7 – DIR1 (PORTD 7)
- D8 – DIR2 (PORTB 0)
- D4 – ENABLE (for both)
To start programming arduino first we need to download a firmware for balancing robot called balancingwii.
this firmware is based on Multiwii firmware used for quad-copter and multi-rotor flying drones. you can learn here more about Multiwii.
special thanks to Mahowik who develop this firmware.
Download the firmware balancingwii by clicking here, now click on green button clone or download.
The firmware will downloaded in your PC in ZIP format.
Now unzip the downloaded file, open the newly created folder and delete that three file highlighted in image, this we not need at all.
also the name of folder containing balancingwii.ino file both must be same other wise you will get compiling error.
now open the balancingwii.ino file in arduino and compile the code and upload it with out changing any thing.
Don’t forget to turn off BT module before uploading the code.
If your MPU6050 orientation is different then my one you need to change this line in config.h file
You can change here PITCH to ROLL
#define CURRENT_AXIS PITCH // possible to choose ROLL or PITCH axis as current.
By default mostly all HC-05 BT module came with default 9600 baud rate.
but for this project note that the baud rate of your HC-05 BT module must be 115200 other wise you cannot able to connect with android app
You can change the baud rate of HC-05 bt module via AT command search it on google you’ll get many tutorial about it.
/* This is the speed of the serial interfaces */
#define SERIAL0_COM_SPEED 115200
#define SERIAL1_COM_SPEED 115200
#define SERIAL2_COM_SPEED 115200
#define SERIAL3_COM_SPEED 115200
If you feel your robot is less responsive then you can try to change this setting in config.h file, but be remember the values must be in constraint.
#define MAX_SPEED 350 // should be <= 500
#define MAX_TARGET_ANGLE 130 // where 10 = 1 degree, should be <= 15 degree (i.e. <= 150)
#define MAX_STEERING 90 // should be <= 100
EZ-GUI app is we going to use here you can learn more about EZ-GUI from here
EZ-GUI app is available to download from play store for free by click the link below or by scanning the below QR code.
Open the downloaded app and click on the three dot at top right corner of screen
Click on the settings.
Select on BT Device to select BT module
now click on NEXT button
Now select the firmware “Multiwii 2.40” from the list and click next next until you reach the home screen.
Click on “CONNECT” button to connect with bluetooth.
Clink on “AUX” button
Tick mark as shown above.
This is my PID settings.
It is not compulsory that this PID settings will work for you bot each and every bot is unique.
PID is depends on bot desing, center of gravity, wheel size, motor type, and more.
try different setting you will surely get sweet setting after some trials.
now back from this screen, and click on three dot at top right corner and go to “advance” and then go to “Untested” and then click on “Model control”
Now this is the screen to play with you bot, you can run you self balancing bot from the joystick,
play with this screen try different settings to learn more.
In this way our DIY Self Balancing Robot is ready to play. enjoy..
if you have any question please ask in comment section.