Giter VIP home page Giter VIP logo

tinympu6050's Introduction

TinyMPU6050

Build Status

Inspired by tockn's library simplicity and ease of use, this implementation focuses on performance and accuracy while still being lightweight.

You're more than welcome to collaborate!

Warning

While in calibration mode, DO NOT MOVE the sensor.

Disclaimer

  • Temperature isn't covered by this library (my personal choice);
  • It's ALWAYS in development

tinympu6050's People

Contributors

bmcage avatar edgar-bonet avatar gabriel-milan avatar jozo132 avatar pavitter-bluestone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tinympu6050's Issues

TinyMPU return strange values if used with delay

I used the default "Angles Example" but added a delay of 1 sec at the end of the void loop(). function. The start Value seems to be ok (around +-2°) but after I started to change the pitch, it starts to return weird values. e.g. even though I put it back on the flat table, it still shows the max value and reduces it really slow (around 0.5° per delay). If I remove the delay, everything is responding immediately.
I also tried to put the printing into another function called after a delay by the loop, but the error is still the same.
I've experienced this bug both on my ESP32 and Arduino UNO (maybe on other boards to but I have only these).
Else it's a great library.

Initial orientation

Hello Gabriel,

I just discovered your library today and it looks promising.

I am wondering what should be changed in the MPU6050::Execute() function, to take into consideration when the IMU is mounted vertically (with the Y axis pointing up/down instead of the Z-Axis).

I think the calculation of the angleAccZ and angleZ variables should take gravity into consideration instead of Y axis in this condition.

Wrong angle range of values for X and Y axis, drifting Z-axis angle value

Hi again,

While using your library, running the demo sketch ArduinoIDE_Angles_Example on my ESP32, I noticed that the range of values for the X and Y axis is wrong : starting flat, the angle is 0.

  • when I tilt on the X-axis, the angle will go from 0 to + 90° or -90° (depends on the tilting direction), and then fall back to zero instead of reaching +180 or -180 and then changing sign
  • same thing happens on the Y axis

I tried to attach a video of me tilting the device and recording the screen in the same time, sorry for the bad quality, it was made with my phone. Here is the video : Wrong values MPU6050

I have also noticed that the Z-axis angle value drifts as I tilt on X or Y axis, and never falls back to 0 when put in the same position as I used for calibration.

Regarding wrong angle range, I suspect it has something to do with the wrapping, however I have not yet looked in it, however, I do not have any idea concerning Z-axis drifting...

Best regards,

Ewald

ESP32 with MPU6050 ping no work

can you helo me, i have a ESP32 WEMOS OLED , i trying your library but dont work , only print constants values :

9:45:02.820 -> GyroY = -0.02 degrees/second
09:45:02.820 -> GyroZ = -0.02 degrees/second
09:45:02.820 -> --- Accel angles:
09:45:02.820 -> AccelAngX = 180.00
09:45:02.867 -> AccelAngY = 180.00
09:45:02.867 -> AccelAngZ = 45.00
09:45:02.867 -> --- Gyro angles:
09:45:02.867 -> GyroAngX = -5.45
09:45:02.867 -> GyroAngY = -5.45
09:45:02.867 -> GyroAngZ = -5.45
09:45:02.867 -> --- Filtered angles:
09:45:02.867 -> FilteredAngX = 177.94
09:45:02.867 -> FilteredAngY = 177.94
09:45:02.867 -> FilteredAngZ = 42.94
09:45:02.867 -> --- Angle filter coefficients:
09:45:02.867 -> Accelerometer percentage = 0.02%
09:45:02.867 -> Gyroscope percentage = 0.98%
09:45:02.867 -> --- Deadzone:
09:45:02.867 -> Accelerometer deadzone = 0.00 m/s²
09:45:02.867 -> Gyroscope deadzone = 0.01 degrees/second

Issue with calibration

12:58:21.597 206 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:21.775 207 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:21.967 208 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:22.161 209 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:22.365 210 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:22.584 211 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:22.815 212 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:23.012 213 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:23.141 214 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:23.338 215 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:23.550 216 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:23.754 217 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:23.931 218 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:24.139 219 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:24.367 220 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:24.577 221 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:24.704 222 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:24.901 223 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:25.189 224 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:25.294 225 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:25.500 226 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:25.711 227 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:25.881 228 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:26.076 229 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:26.273 230 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:26.471 231 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:26.685 232 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:26.873 233 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:27.085 234 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:27.297 235 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:27.444 236 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:27.709 237 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:27.837 238 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:28.047 239 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:28.244 240 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:28.464 241 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:28.667 242 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:28.864 243 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:29.013 244 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:29.206 245 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:29.409 246 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:29.594 247 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:29.826 248 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:29.992 249 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:30.182 250 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:30.377 251 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:30.572 252 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:30.771 253 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:30.965 254 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:31.168 255 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:31.398 256 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:31.614 257 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:31.811 258 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:31.941 259 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:32.138 260 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:32.363 261 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:32.527 262 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:32.771 263 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:32.918 264 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:33.116 265 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:33.311 266 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:33.507 267 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:33.733 268 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:33.935 269 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:34.135 270 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:34.324 271 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:34.535 272 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:34.693 273 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:34.876 274 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:35.074 275 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:35.266 276 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:35.490 277 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:35.677 278 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:35.913 279 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:36.051 280 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:36.288 281 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:36.442 282 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:36.664 283 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:36.839 284 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:37.049 285 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:37.299 286 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:37.451 287 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:37.617 288 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:37.806 289 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:38.003 290 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:38.204 291 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:38.402 292 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:38.617 293 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:38.815 294 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:38.981 295 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:39.176 296 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:39.374 297 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:39.589 298 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:39.761 299 loops / 4 axis calibrated. Missing:  AccZ GyY
12:58:40.002 300 loops / 4 axis calibrated. Missing:  AccZ GyY

multiple tinyMPU6050

Hello Gabriel,

How can I edit the library or my own arduino code to access 2 MPU6050's (0x68 and 0x69) while using the tinyMPU6050 libary?

Thankx

constant AccX = 0.99 m/s²

Hi :-)

The sensor is located on my desk, completely immobile, and the value of AccX is equal constantly to 0.99 m/s² - are you able to explain why?

All Gets Example doesn't compile, GetAngAccZ missing

Hey there,
I pulled the current master and noticed that the PlatformIO_All_Gets_Example doesn't compile, because the function GetAngAccZ is missing since the commit: 5264a0d .
The Arduino_All_Gets_Example has the same problem too.
Hope it helps.

Out of bounds FilteredAngY and Z (possibly X too) ?

Are the below values out of bounds? (i.e 0-359.99...) or am I just using the wrong angle convention?

22:47:25.132 -> --- Filtered angles:
22:47:25.167 -> FilteredAngX = 8.48
22:47:25.167 -> FilteredAngY = 512.71
22:47:25.167 -> FilteredAngZ = -302.91

GetAngZ() drifting when the chip does not move

the chip is still, but GetAngZ() value is drifting:

GetAngX, GetAngY, GetAngZ

 -8.00  ,   -4.90  ,   19.98
 -7.99  ,   -4.91  ,   19.98
 -8.00  ,   -4.91  ,   19.98
 -7.99  ,   -4.90  ,   19.99
 -8.00  ,   -4.90  ,   19.99
 -8.00  ,   -4.90  ,   19.99
 -8.00  ,   -4.89  ,   19.99
 -8.00  ,   -4.91  ,   19.99
 -8.00  ,   -4.91  ,   19.99
 -8.00  ,   -4.91  ,   19.99
 -8.00  ,   -4.91  ,   19.99
 -8.00  ,   -4.92  ,   20.00
 -8.00  ,   -4.91  ,   20.00
 -8.00  ,   -4.91  ,   20.00
 -8.00  ,   -4.91  ,   20.01
 -8.00  ,   -4.91  ,   20.01
 -7.99  ,   -4.90  ,   20.01
 -7.99  ,   -4.90  ,   20.01
 -7.99  ,   -4.90  ,   20.01
 -7.98  ,   -4.91  ,   20.01
 -7.98  ,   -4.91  ,   20.02

...

 -7.99  ,   -4.94  ,   24.97
 -7.99  ,   -4.94  ,   24.98
 -7.99  ,   -4.94  ,   24.98
 -7.99  ,   -4.94  ,   24.98
 -8.00  ,   -4.94  ,   24.98
 -8.00  ,   -4.93  ,   24.98
 -8.00  ,   -4.94  ,   24.99
 -8.00  ,   -4.94  ,   24.99
 -8.00  ,   -4.93  ,   24.99
 -8.00  ,   -4.93  ,   24.99
 -8.00  ,   -4.93  ,   24.99
 -8.00  ,   -4.93  ,   25.00
 -7.99  ,   -4.93  ,   25.00
 -8.00  ,   -4.93  ,   25.00
 -8.00  ,   -4.92  ,   25.01
 -8.00  ,   -4.91  ,   25.01
 -8.00  ,   -4.91  ,   25.01
 -8.00  ,   -4.91  ,   25.02
 -7.99  ,   -4.90  ,   25.02
 -8.00  ,   -4.90  ,   25.02
 -8.00  ,   -4.91  ,   25.03
 -8.01  ,   -4.91  ,   25.03
 -8.00  ,   -4.92  ,   25.04
 -8.00  ,   -4.92  ,   25.05
 -8.01  ,   -4.93  ,   25.05

Getting missing AccZ GyY values from calibration

Getting this from Calibration mode
13:58:48.156 -> 88 loops / 4 axis calibrated. Missing: AccZ GyY
13:58:48.361 -> 89 loops / 4 axis calibrated. Missing: AccZ GyY
...

Nope I am not on a roller coaster.

[Edit]
14:09:33.081 -> 298 loops / 4 axis calibrated. Missing: AccZ GyY
14:09:33.286 -> 299 loops / 4 axis calibrated. Missing: AccZ GyY
14:09:33.487 -> 300 loops / 4 axis calibrated. Missing: AccZ GyY
14:09:54.087 -> 1 loops / 1 axis calibrated. Missing: AccX AccY AccZ GyX GyY
14:09:54.289 -> 2 loops / 4 axis calibrated. Missing: AccZ GyY
14:09:54.462 -> 3 loops / 4 axis calibrated. Missing: AccZ GyY

just loops after 300, it seems to want to tell me what is flat and whats not rather than using what it's got as flat and working from there.

Acceleration offsets ?

Hi !
First of all, thank you very much for your work ! Your library works very well, I am currently working on a project for my education, and I am glad that I have found your library.
However, I have played a bit with my MPU6050, and have found that it had an error in measuring gravity. While holding my sensor perfectly still and horizontal the gravity value read is a little less than 16000 on Z-axis (so a little less than 1g with default scale), and a little more than 250 on X-axis and 400 for Y-axis. After looking through your library, I did not find any code that would correct these error.
Have I missed a part where you set acceleration offsets ?

Best regards,

Ewald

Measurement slow when when upside down

Hi @gabriel-milan first off, thank you so much for this, it works the best with ESP8266 from libraries I tried :)

I don't know if this is a bug or it's a "feature" of the sensor but when I orient it upside down (MPU6050 chip facing down), the measurements are slow / delayed. It's around one second delayed. Once I reorient it back, it's fast again. This is very unfortunate as I plan on using it oriented like that.

EDIT: Z-axis seems to stay fast, only X and Y are slow. Tested on Angles example. The difference can be easily observed when making sudden fast moves

Examples?

Thank you for posting this. However I find no Arduino or AVR code examples on the use of this library.

Unreliable endianness of retrieved data

The method MPU6050::UpdateRawAccel() contains the following line:

rawAccX = wire->read() << 8 | wire->read();

and similar lines for rawAccY and rawAccZ. The same idiom is used in MPU6050::UpdateRawGyro().

This kind of expression should be avoided, as it does not guarantee the endianness of the retrieved data. This is because, in C++, the order of evaluation of the arguments of the | operator is unspecified.

Presumably, the current version of gcc, when invoked with the options passed by the current version of the Arduino IDE, generates assembly that orders the bytes in the expected way. But this cannot be relied upon, and can very well depend on the compiler, compiler version, compiler options, or even surrounding code. This is the kind of software error that cannot be unveiled by testing, as the code can “just work” even if it is incorrect.

The simplest solution is to issue the calls to wire->read() within separate statements. Unlike the arguments of the | operator, separate statements have a well define order of evaluation:

rawAccX = wire->read() << 8;
rawAccX |= wire->read();

See also this post on the Arduino forum.

Prints out same values regardless of sensor position

I am using the example sketch, with the pin configuration:

SDA -> A5
SCL -> A4

However, regardless of how I move the gyroscope, the same values are printed out.

The output of the program can be found below

`

Starting calibration...
Calibration complete!
Offsets:
AccX Offset = 0.00
AccY Offset = 0.00
AccZ Offset = 2047.00
GyroX Offset = 0.00
GyroY Offset = 0.00
GyroZ Offset = 0.00
AngX = 179.99 / AngY = 179.99 / AngZ = 45.00
AngX = 179.99 / AngY = 179.99 / AngZ = 45.00
AngX = 179.99 / AngY = 179.99 / AngZ = 45.00
AngX = 179.99 / AngY = 179.99 / AngZ = 45.00
AngX = 179.99 / AngY = 179.99 / AngZ = 45.00
AngX = 179.99 / AngY = 179.99 / AngZ = 44.99
AngX = 179.99 / AngY = 179.99 / AngZ = 44.99
AngX = 179.99 / AngY = 179.99 / AngZ = 44.99
AngX = 179.99 / AngY = 179.99 / AngZ = 44.99
AngX = 179.99 / AngY = 179.99 / AngZ = 44.99
AngX = 179.99 / AngY = 179.99 / AngZ = 44.99
AngX = 179.99 / AngY = 179.99 / AngZ = 44.99
`

Library Install from Arduino IDE

If you install from the Arduino IDE, you still get the example versions with the "mpu." missing from the function calls in the ArduinoIDE_All_Gets_Example, dunno if that's the library people being slow, or if its some date/time stamp thing not detecting it as a new version

Updating to V0.4.3

After using the built in Arduino IDE update library function to V 0.4.3 the following is received in the debug window

Invalid library found in C:\Users\<user name>\OneDrive\Documents\Arduino\libraries\TinyMPU6050: no headers files (.h) found in C:\Users\<user name>\OneDrive\Documents\Arduino\libraries\TinyMPU6050

This may be a OneDrive path issue, but deleting the library manually and then manually putting the downloaded extracted zip version from GitHub fixes the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.