Let's Make Robots!

Self Balancing Robot using MPU6050 and Arduino


This is my first robot. I have used an MPU6050 IMU, Arduino UNO, and an Arduino Motor Shield. The motors I have used are cheap ones, that is why a small oscillation always appears. Sensor- It is an MPU 6050 IMU. I have used Jeff Rowberg's DMP library. You won't need any other filters if you use that library. It gives you directly the yaw,pitch,roll values if you want. https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Kaanmcetin,

I had a not so good self balancing robot that used 2 IR distance sensors to detect tilt. Also had accel & gyro but never was able to figure out how to intergrate them.  Used the motors for another project but still have frame, CPU, and other electronics. Bought a MPU6030 and some motors and want to give it another try. Would you be willing to share your code and ideas?

One of the problems I have is how "hard" to drive the motors. My motors have encoders which work great for other robots but seem to be a hinderance with these machines. Tumeing the PID seemed to be an endless challenge.

Regards George

It might be possible to use a 12v 7amp-hr sealed lead acid battery. They are large and heavy, but are occasionally used in toys. They are usually cheaper than LiPos and might work better for the battery for this bot. I have a place down the street that sells them.

To try it out, put something that weighs a few pounds on your top shelf (tape a barbell or a couple cans of food there). If that makes it more stable then the theory works in your case and a small SLA would work on the top shelf.

Unfortunately I can't estimate very well so I don't know how large your shelves are.

I'm seriously debating turning my soon to be robot Groucho into a balance bot. This is partly because I've always wanted to do something like this and partly because a balance bot moves fast much like Groucho Marx's trademark walk (head forward, body leaning forwards, legs back). Decisions, decisions. If I do start building one, I'll let you know. I can use all the help I can get.

I do agree with the others and think your build is great. Especially for a first robot.

Thank you all for the comments and reccomendations on my robot. 

@DangerousThing Actually the robot has another shelf on the top. I already have planned the batteries to be hooked op on its top so that the robot could be more stable. But I havent got any Li-po batteries yet and I power the robot with a 12V adapter. I just didn't need that shelf yet. I have tried to put my finger on its top and press it to simulate a weight on its top, it surely was more stable than before. One thing I am curious about is that if the motors can stand up that much weight as they can not generate enough torque. (that might be caused by the insufficient power source too). 

@bdk6 Thanks for your support. It really was a fast start for me, I had too learn too much to build this robot. And I think it could have been a lot easier if i had started with easier ones. I still need to learn how to interface with arduino over other programs like processing. And it is not a problem for me if you give me information about what i have to change with my project, so that i can improve myself. I won't be discouraged by my faults.

@enigmerald If you start building one notice me, i would like to see your robot and maybe we can compare our works and improve them. I would try tohelp you at certain points. 

@ggalant I dont know why the link is broken, couldnt fix it either. You can google that library, its not hard to find it. 

works very well ! nice work 

1. The link to Jeff Rowberg's DMP library seems to be broken.

2. In the LMR scheme of thing what does "collected" mean?

Thanks for posting!!!

Collecting something is an easy way to save it in your profile so you can easily find it later and get updates.

Also it's similar to 'like' on facebook, or a thumbs up on youtube.

looking good kaanmcetin. It's balancing! Definitely on my to-do list now. Need to fetch some accelerometers!

This is GREAT work.  I admire your courage and dedication to build something like this as your first robot.  You did a great job.  It is really quite impressive.  I look forward to seeing a LOT more from you in the future.  And welcome to LMR.

I think that balancing robots are more stable if there is more weight up high. You might want to make a top shelf to put your batteries or something else fairly heavy on. They can also be more stable if they are taller, if your controller can react fast enough and yours seems to be able to react quickly enough.

The last point seems counterintuitive to some people (it took me a while to understand it). An analogy is comparing balancing a broomstick on the palm of your hand vs balancing a pencil there. Most people can balance a broomstick for minutes with just a little practice, whereas the pencil is a lot more difficult for most people.

have you built two otherwise identical bots, one with the weight up high and one with it low, and actually TESTED this theory?  Or have you gone by a build of one robot and your own (or someone else's) "observations" from that?  Or , even worse, just found this often repeated theory on the Internet and decided to quote it here.  The reason I ask is that I see this all the time, with the same broomstick analogy, but NEVER have a I seen any type of actual comparison or analysis.  I would really like to see one or the other or even both the next time someone quotes this "rule".