Notifications
Clear all

Trouble with MPU 6050 Code

48 Posts
9 Users
14 Likes
4,575 Views
(@quince)
Member
Joined: 2 years ago
Posts: 40
Topic starter  

Greetings, I am very new and am having trouble getting a working copy of the code for the MPU 6050 required for the drone bot workshop electronic level project.

I have downloaded from the workshop and from github and when I try to install I end up with no library or an invalid one. I have installed several library's without an issue and am at a loss , any ideas?


   
Quote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

@quince

I'm sure you'll understand that we need more information before we can offer much practical advice.

For instance, are you using the Arduino IDE or something else ? What version of the IDE are you using. Which files are you downloading and what, exactly, do you do with them once they're downloaded.

And after that, what specific error messages do you get when you try to use them ?

 

PS - did you get your previous problem worked out or is this a continuation of it ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@quince)
Member
Joined: 2 years ago
Posts: 40
Topic starter  

@will Hi Will, The BIG problem is I don't know what is needed . I don't know if you read my into, but I am green as grass. I used instruments based on these innovations during my piloting career, but you don't have to make it to use it.  I wanted to see if I could understand it. I am OK when it comes to building,  but code, that for spy's right?  I never had any thought of learning that but I followed the videos closely, copy and pasted finished two projects and much to my surprise it worked! Now I'm hooked. But understanding, it is still voodoo.

The project is the dronebotworkshop Arduino digital level

Here were my rote learned steps.

 I first tried the links at the bottom of the article in the workplace,

Electronic Level Sketch It appeared to download (11kb is that enough ?) it was extracted and placed into the Arduino library folder, but I am not sure that it is viable because it is my understanding that the MPU 6050 file should come with it. Could not get it to load so copy and pasted from the article and loaded up the library's I had and spent two days of working through it trying to find my issues.

I could not get either of the following to download.

Jeff Rowberg’s I2C Dev Library – The I2C development library for Arduino, by Jeff Rowberg.

Jeff Rowberg’s MPU-6050 Library – The MPU-6050 library for Arduino, by Jeff Rowberg.

I did a search and ended up at https://www.i2cdevlib.com/usage

I downloaded the master, extracted it, broke out the Arduino file and placed it in the Arduino library folder.

From that I was able to load the i2c required file but for some unknown reason  I cannot get the file for MPU 6050 to the library manger. Zip. file, break it out and download separately,nothing.

As I mentioned I am not sure the Level sketch is OK.

I would be grateful for any nugget of knowledge you could drop to point the way. I have read about every thing on the net about how to do this and I don't think I am missing steps. If you are now laughing I'll wait, for you reply. Thanks, Quince

 


   
ReplyQuote
(@quince)
Member
Joined: 2 years ago
Posts: 40
Topic starter  

@will Sorry forgot to tell you I did get all library's to load but the MPU6050 and maybe the sketch?

I did as you said and broke it out and loaded it separately but for some reason the MPU 6050 will not.

The board is an UNO R3 The software loaded automatically when connected


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

@quince 

Don't worry, we all started from nothing, so nobody's gonna laugh at you 🙂 Failing is not falling down, failing is not getting up afterwards.

One thing you should know right away is that sketches will always have a file type of .ino (or .pde for very old sketches), so don't try to put them in the library folder (and remove any that you may have put there in the past).

Let's start with some fundamentals, that may help you understand the structure a bit better. The starting sketch is sort of a subclass of a C++ application. It executes the setup() subroutine (which is where you initialize any variables and set up any device objects that require initialization). It then calls loop() and when that returns, it calls it again and again and ... until something stops it to the plug is pulled.

A library is used to "collect" a set of information into a folder about a particular piece of equipment. There must be an associated .cpp (i.e. a C++ source code file containing the class definition and methods) and a .h file which declares all of the methods available from the object.

There may be more files in the folder describing keywords associated with the class (so the IDE can colour-code these keywords to help understand their origin) and often a set of sample sketches to illustrate the setup and use of the class.

What you will be writing is called a sketch (for historical reasons) and will always be a text file with a file type of .ino (or possibly .pde for very old sketches).  Anything with a file type of .ino is a sketch and should NOT be put in the library folder (please remove any such files that you may have placed in there).

The Arduino IDE insists that a sketch be enclosed in a folder with the same name (but no .ino fileType). hence a sketch called dec11_test.ino must be placed inside a folder dec11_test. If it's not already in a suitable folder, the Arduino IDE will create a suitable folder when you try to compile the sketch.

To add the object represented by the library to your sketch, you'll use the '#include " in your sketch. For example, the mpu-6050-level.ino sketch includes the line "#include " because it wants to use a liquid crystal display and so it includes the library code that encapsulates that object's behaviour.

If the library is not already available in tour library folder, you can use the instructions at 

https://www.arduino.cc/en/guide/libraries

While you read and digest this, I'm going to go take a look at the rest of your post.

Please let me know if this isn't clear or if you have any more questions about the basic elements of the IDE or differences between sketches and libraries.

Anything seems possible when you don't know what you're talking about.


   
ron bentley reacted
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 
Posted by: @quince

I could not get either of the following to download.

Jeff Rowberg’s I2C Dev Library – The I2C development library for Arduino, by Jeff Rowberg.

I tried downloading it and all I got was another copy of "mpu-6050-level.ino" ? Didn't seem to be anything to do with I2C (except for the LCD).

Jeff Rowberg’s MPU-6050 Library – The MPU-6050 library for Arduino, by Jeff Rowberg.

That downloaded fine for me, but was just a folder (named MPU6050) with an examples folder, the expected MPU6050.cpp and MPU6050.h files and a few calc helper files (apparently).

it would appear that neither is required to run the sketch.

If you just copy the MPU6050 to the libraries folder (if it's not already there), you should be able to go to the Arduino "File" menu, submenu "Examples", submenu "MPU6050" and pick a sketch to test the MPU6050 class.

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@quince)
Member
Joined: 2 years ago
Posts: 40
Topic starter  

@will Will, Thanks, It is like getting a drink from a fire hose, I remember when I started my instrument rating in aviation 40 years ago, felt the same way, but with a finger in the glossary to learn the terms and repetition of skills I now enjoy the challenge of flight on instruments.

I will work through instructions and get back with you. Thanks, Again

 


   
ReplyQuote
(@quince)
Member
Joined: 2 years ago
Posts: 40
Topic starter  

Will, after working through a few things I started to get an invalid directory in the error code for the MPU6050 every time I tried to use it. I had somehow got something backwards perhaps the library as you suggested. I had tried to download the MPU 6050 code from several locations, so rather then track it down I deleted all MPU 6050 code and did a reload from the The MPU-6050 library for Arduino, by Jeff Rowberg master I downloaded from https://www.i2cdevlib.com/usage, broke out the Arduino file copied and pasted to the Arduino library and presto, it now shows up in my contributed libraries for use.

I tried to comply and received the following attached message.

I don't understand it more than there is trouble with the MPU 6050.

Thanks again for all the information, it has proved most useful.

 


   
ReplyQuote
(@quince)
Member
Joined: 2 years ago
Posts: 40
Topic starter  

(@will)

Will, after working through a few things I started to get an invalid directory in the error code for the MPU6050 every time I tried to use it. I had somehow got something backwards perhaps the library as you suggested. I had tried to download the MPU 6050 code from several locations, so rather then track it down I deleted all MPU 6050 code and did a reload from the The MPU-6050 library for Arduino, by Jeff Rowberg master I downloaded from https://www.i2cdevlib.com/usage, /a> broke out the Arduino file copied and pasted to the Arduino library and presto, it now shows up in my contributed libraries for use.

I tried to comply and received the following attached message.

I don't understand it more than there is trouble with the MPU 6050.

Thanks again for all the information, it has proved most useful.

 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

@quince 

I can't follow what you're doing here. The error messages don't make a lot of sense, so I'm wondering if you are trying to compile the library components as if they were sketches.

If you're trying to compile things in the /libraries folder, stop trying. They are non-viable on their own and need to be included in a sketch and compiled within the scope of the sketch. Library files should never be modified or customized in place.

You should never have .../Arduino/libraries as your current directory.

Try this:

- move to whatever corresponds to your path {home}/Arduino/

- download the Electronic Level Sketch and copy it to your {home}/Arduino/ folder. It should contain a file with name "mpu-6050-level.ino" which should now be at {home}/Arduino/mpu-6050-level.ino

- drag this file onto the Arduino IDE (or whatever it takes to open the file on your OS)

- click the compile button in the IDE (check symbol at upper left corner)

- if the aIDE says it has to be in a folder ... say OK

- this should compile the mpu-6050-level.ino file. You do NOT need the MPU6050 library to compile this sketch. You will need the liquid crystal IC library though. That may be problematic because there are two of them with similar names and they conflict.

- let me know how this goes.

 

PS - I'll be away for a few hours this afternoon, so I may be slow getting back to you.

Anything seems possible when you don't know what you're talking about.


   
ron bentley reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@quince
@will

Not able to get it working either. Nothing but frustration trying to install the libraries to work with Bill's examples.

Bill's workshop: If you would like more information regarding this excellent set of libraries visit Jeff’s webpage dedicated to I2C development.

These libraries are provided in ZIP format. You can install the ZIP files directly into your Arduino IDE.

As it is a bit overwhelming you might find it useful just to get the two libraries we are going to use today – the I2C Development library and the MPU-6050 library.

It was overwhelming and I wasn't able to find the two zip libraries to download.

Although I used to use c++ with the TurboC++ editor on DOS I gave up with the newer machines as I could never get libraries installed properly.  The Arduino IDE seemed easier with installing of libraries but this example has got me stuck.

I found i2cdevlib-master.zip but the Arduino IDE didn't install it as directed.

 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 
Posted by: @robotbuilder

@quince
@will

Not able to get it working either. Nothing but frustration trying to install the libraries to work with Bill's examples.

Bill's workshop: If you would like more information regarding this excellent set of libraries visit Jeff’s webpage dedicated to I2C development.

These libraries are provided in ZIP format. You can install the ZIP files directly into your Arduino IDE.

As it is a bit overwhelming you might find it useful just to get the two libraries we are going to use today – the I2C Development library and the MPU-6050 library.

It was overwhelming and I wasn't able to find the two zip libraries to download.

[snipt] I found i2cdevlib-master.zip but the Arduino IDE didn't install it as directed.

WOW !

If robotBuilder (who is very skilled, very knowledgeable and very experienced) found nothing but frustration then I would definitely urge you, quince, to postpone this project until you have more experience.

There's no point in beating your head against the wall with the MPU650 if you can find another instrument that's better behaved.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@quince

@will

If robotBuilder (who is very skilled, very knowledgeable and very experienced) found nothing but frustration then I would definitely urge you, quince, to postpone this project until you have more experience.

No I am not very skilled or knowledgeable and my experience is as a self taught occasional hobbyist in the  BASIC,  Assembler and C++ languages and basic electronics. Today's programming environments are much more complicated and I gave up when DOS vanished and was replaced with Windows. After that I relied on experts to provide simple languages that hide all that complexity while at the same time providing sufficient performance to make it all worth while. For example I spent time trying to learn Java. Gave up, too complicated. Now I find there are easier ways like using the Processing language which is a free graphical library and integrated development environment (IDE) built for the electronic arts, new media art, and visual design communities with the purpose of teaching non-programmers the fundamentals of computer programming in a visual context. The Arduino IDE seemed easy to use because I thought it only required you locate and let it install libraries no skill required.

So I would very much encourage you/quince to persevere with using the MPU6050 as I would if I had the module.  Once you figure out how to install the correct libraries it should be easy.  Hopefully if @will can't work through it with you someone else might. I might buy a MPU6050 myself after the xmas break and after getting it working post the steps that worked for me.

 

 


   
ron bentley reacted
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

@robotbuilder @will @quince

Just had a quick look at the latter posts on this topic as i was intrigued.   Looking at the dronebot article on this I saw 2 download links that download:

1) 'mpu-6050-level-+DroneBot-Workshop.zip' file that contained a sketch to use the mpu 6050.  Note that this sketch is displaying info on an attached LCD screen.  Without the LCD the program could be modified to display only on the serial monitor.

2) 'MPU6050.zip' file.  This is the library file.  This can be loaded into Arduino via the Sketch > Include Library > Add .ZIP library  menu path.  The library loaded OK for me.

Don't know if this helps, but I hope its a starter to get the mpu6050 on the level.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2527
 

@byron FYI @robotBuilder @quince

It's all up in the air right now:)

I downloaded the file for the "level" sketch from the OP's link and it doesn't require the MPU6050 library at all. But it DOES require one of the liquid crystal I2C libraries (the one that defines POSITIVE) which I don't have, so I can't compile it.

I have also downloaded the MPU6050 library (again as per the OP's link in a post above) but haven't installed it since it didn't seem to be required.

I did try to download the I2C library from the OP's post but all I got was a second copy of "mpu-6050-level.ino"

I haven't looked at anything in DronebBot-Workshop because all I was starting to do was try to get quince able to compile the (original mpu-6050-level.ino) sketch.

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Page 1 / 4