Tutorial: Gyroscope and Accelerometer (GY-521/MPU6050) with Arduino | UATS A&S #12

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 มิ.ย. 2024
  • The GY-521 module is a breakout board for the MPU-6050 MEMS (Microelectromechanical systems) that features a 3-axis gyroscope, a 3-axis accelerometer, a digital motion processor (DMP), and a temperature sensor. This tutorial gives only a brief introduction to the GY-521/MPU-6050. In particular, it is shown how to retrieve the raw sensor values.
    Written tutorial and source code: www.mschoeffler.com/2017/10/05...
    Link to I2Cdevlib (advanced MPU6050 library): github.com/jrowberg/i2cdevlib...
    :: List of materials ::
    -- Arduino Uno
    - Aliexpress: 1smart.click/search/st/ali/ms...
    - Amazon: 1smart.click/search/st/azn/ms...
    - ebay.com: 1smart.click/search/st/eby/ms...
    -- Jumper wires
    - Aliexpress: 1smart.click/search/st/ali/ms...
    - Amazon: 1smart.click/search/st/azn/ms...
    - ebay.com: 1smart.click/search/st/eby/ms...
    -- Breadboard
    - Aliexpress: 1smart.click/search/st/ali/ms...
    - Amazon: 1smart.click/search/st/azn/ms...
    - ebay.com: 1smart.click/search/st/eby/ms...
    -- GY-521
    - Aliexpress: 1smart.click/search/st/ali/ms...
    - Amazon: 1smart.click/search/st/azn/ms...
    - ebay.com: 1smart.click/search/st/eby/ms...
    Video Chapters:
    0:00 Tutorial Introduction
    0:46 MPU6050 Specification
    1:11 GY-521
    3:06 Wiring
    4:11 Programming
    6:30 Example demonstration
    Credits:
    Songs: Killing Time
    Artist: Kevin MacLeod (incompetech.com)
    Licensed under Creative Commons: By Attribution 3.0 License
    creativecommons.org/licenses/...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 230

  • @leebannister3759
    @leebannister3759 2 ปีที่แล้ว +13

    This was exactly what I was looking for and it was excellent. Very clear, good pace, great postit notes and I really like the LED extension. I know what my students are doing tomorrow.

  • @nickhydeviolin
    @nickhydeviolin 3 ปีที่แล้ว +9

    I ordered some of these in the mail, opened em up all excited to get em to work, only to not understand the datasheet or any other youtube videos at all. This explained it all so well. It's late now, but I'm excited to try this out tomorrow again fresh! :D

  • @MartinBgelund
    @MartinBgelund 5 ปีที่แล้ว +15

    Thank you for this excellent introduction to the MPU6050!

  • @icarossavvides2641
    @icarossavvides2641 2 ปีที่แล้ว

    Good tutorial as a springboard, refreshing to see well documented code!

  • @vivansheth1902
    @vivansheth1902 2 ปีที่แล้ว

    thankyou so much i looked at around 50 tutorials and i understood just you 🤗🤗🤗

  • @aalizwel2061
    @aalizwel2061 6 ปีที่แล้ว +1

    Awesome
    Best MPU6050 tutorial online
    Thanks a lot

  • @gamories8106
    @gamories8106 2 ปีที่แล้ว

    Thank you, sir. That is my semester final project, gonna submit it tomorrow.

  • @rileystewart9165
    @rileystewart9165 5 ปีที่แล้ว +3

    That's awesome that it has motion detection!

  • @marosakr778
    @marosakr778 6 ปีที่แล้ว

    many thanks , it is very helpful , short , and informative. very practical.

  • @user-mx8nn2gg6q
    @user-mx8nn2gg6q 6 ปีที่แล้ว +3

    Great job ! I learn a lot from your video,Thank you !

  • @janiskrumins3263
    @janiskrumins3263 3 ปีที่แล้ว

    Very good, thanks from Latvia!

  • @amankushwaha3395
    @amankushwaha3395 5 ปีที่แล้ว +1

    Good tutorial.
    It was very helpful

  • @MarkSMays
    @MarkSMays 5 ปีที่แล้ว

    Great, clear explanation. Thanks!

  • @manishpingale6558
    @manishpingale6558 4 ปีที่แล้ว

    Thank you so much for your support and help

  • @neilgrice9251
    @neilgrice9251 3 ปีที่แล้ว

    An excellent Tutorial. Thank you so much.

  • @MarioMonte13
    @MarioMonte13 5 ปีที่แล้ว +3

    I'm hoping to build a HUD to display orientation. Would a compass sensor be wired to the auxiliary pins here to help the sensor know which direction it was facing?

  • @oncledan282
    @oncledan282 5 ปีที่แล้ว

    Hi Michael.
    This is, and by far, the best introductory tutorial I have seen on the GY-521 and the MPU-6050. And your sketch worked the first time too !! I think I need to stabilize the readings, because they change too much from one reading to the next. Any idea on how to do that? I heard of an Low Pass Filter, but fail to find an adequate one. Could you please help me on this quest?
    I will seek more tutorials to convert these raw values into real usable values that could be fed to a motor driver board, so I can use it to stabilize a platform's stability.
    Thank you for your help and time, and until that time, have a great day.

  • @wolfie3657
    @wolfie3657 8 หลายเดือนก่อน

    Oh thank you, thank you, thank you! This is perfect for me!

  • @Marco110981
    @Marco110981 4 ปีที่แล้ว +1

    Hi Michael. This is a very interesting video. Thank you for posting it.
    Imagine I want to connect this sensor with an Arduino NANO. Nothing more then the board and the sensor, constantly measuring, and connected to a 12V source. Any clue about the current draw in that case?

  • @sriramrepaka7003
    @sriramrepaka7003 4 ปีที่แล้ว

    Great too informative thanks for the introduction

  • @tseckwr3783
    @tseckwr3783 2 ปีที่แล้ว

    Nice job of explaining. Thanks

  • @chandradasabulathsinhala6038
    @chandradasabulathsinhala6038 4 ปีที่แล้ว

    Thanks for a great explanation. I am a Sri Lankan....

  • @katyd2959
    @katyd2959 6 ปีที่แล้ว

    I want to try MPU 6050 to your tutorial, thank you

  • @rahultri333
    @rahultri333 6 ปีที่แล้ว +2

    how can i change the sensitivity of GY521 so as to read more than 2g. please tell me where to change what values, where can i find AFS_SEL and FS_SEL (in which file). waiting eagerly for response .

  • @vaingloryarmonia6859
    @vaingloryarmonia6859 6 ปีที่แล้ว +2

    Can program gyroscope change to
    Example :
    For coordinat 250 to 1000 led on
    Else coordinat 1000 to 250 led off
    Can u help me for this program?

  • @timmorgan3673
    @timmorgan3673 6 ปีที่แล้ว

    Many thanks for a great tutorial

  • @You7aRe7My7LivE
    @You7aRe7My7LivE 2 ปีที่แล้ว

    sehr sehr hilfreich - besten Dank!

  • @yedidyacohen8295
    @yedidyacohen8295 4 ปีที่แล้ว

    The MPU 6050 product specification for register 6B specifies that in order to reset the MPU to its default value, you need to set the DEVICE_RESET bit (bit7) to "1". Why did youset it to zero (command Wire.write(0); in the setup() function)?

  • @kumareshj7741
    @kumareshj7741 6 ปีที่แล้ว

    tq im getting output can u please explain me how to limit the reading to 10 with 3 sec delay for each??? can tell me the changes

  • @mustafash484
    @mustafash484 6 ปีที่แล้ว +1

    thank you for this video , i wanna ask if i want to monitor this result on mobile application how can i what i need , thank you

  • @panzertracks
    @panzertracks 3 ปีที่แล้ว

    can you make a tutorial on how to use this mpu-6050 to control a servo for a canon stabilizer on a RC tank. thanks for sharing.

  • @dutchdykefinger
    @dutchdykefinger 5 ปีที่แล้ว +1

    i have an arduino uno r3. which does have the SLC and SDA pins next to the gnd and aref pins, they are however not marked
    they work perfectly fine just testing your sketch though,
    thanks for that one, and the visual example :D

  • @vaingloryarmonia6859
    @vaingloryarmonia6859 6 ปีที่แล้ว

    Sir, can u help me for my project " turn off blinking led with gyroscope sensor ,for first im using button for on blinking and then turn off with gyroscope sensor ,help me for combining blinking led (sein lamp) and gyroscope sensor

  • @occocia
    @occocia ปีที่แล้ว

    What can i use to measure the impact of a object to ground. I want to have all the measuring sensors inside the object.

  • @roblox254r
    @roblox254r 2 ปีที่แล้ว

    im planning to create vr controller using this, however based on your explanation you can only "rotate" and get the rotation value, not the actual device position in 3d space, right?

  • @m.s.3346
    @m.s.3346 3 ปีที่แล้ว

    Thanks. I just gave this video the 2500th thumb up.

  • @christopherclark2205
    @christopherclark2205 4 ปีที่แล้ว

    Great tutorial, very well done! Quick question - regarding the data output, what is the output data rate? Perhaps better asked, what is the time difference between each data set output?

    • @Dutch3DMaster
      @Dutch3DMaster 3 ปีที่แล้ว

      If you do not use a delay, it's basically as fast as the Arduino itself can process it over a serial bus, and depending on the one you use you might need to look up the information for the Arduino. It might also be that the pins SCL and SDA have a different clock compared to most of the other pins, but I am not completely use. I built a sensor with it for tracking head rotation (to input into a program that mimicks the TrackIR protocol for certain games) and the delay is small enough for that that it does not pose a problem for that use, but obviously, whatever use you have in mind might change the situation.

  • @DzulfiqarDYanto
    @DzulfiqarDYanto 5 ปีที่แล้ว

    how to change the accelerometer value from the unit of numbers to the angle unit?

  • @samaanbisso5112
    @samaanbisso5112 4 ปีที่แล้ว

    Can you switch the data of the accelerometer to read in frequency (Hz) using only Arduino?

  • @MrVicenteRJ
    @MrVicenteRJ 2 ปีที่แล้ว

    Hello, I need an IMU with low noise since I want to implement a PID and it needs to be precise, is there any way to reduce the noise in this sensor? thanks in advanced

  • @jackfrost4033
    @jackfrost4033 4 หลายเดือนก่อน

    Does measuring the trajectory of a turning plane only require a gyroscope or also an accelerometer? (for trajectory measurement and not that of pitching)
    THANKS

  • @prstyodc
    @prstyodc 4 ปีที่แล้ว

    hello, if i want change the output to angle with mpu 6050, what i must change?

  • @sergej529
    @sergej529 4 ปีที่แล้ว

    Thank you for this good introduction. How can I read two of the MPU6050 devices on the same I2C bus?

  • @banuzuhdianprastinanda
    @banuzuhdianprastinanda 4 ปีที่แล้ว

    When the GY-521 board is rotated or moved, the sensor values not change according to the movement. What should i do?

  • @2012TheAndromeda
    @2012TheAndromeda 3 ปีที่แล้ว

    I'm having trouble figuring out why MPU6050 is 0x68. I didn't find this value in the datasheet, and I ask because I actually have an MPU3050, so it's address is different but I can't find out what it is.

  • @simonemastroianni1985
    @simonemastroianni1985 6 ปีที่แล้ว

    In my Leonardo board there are only 2 pins with writed: SDA and SDL

  • @banditgym4852
    @banditgym4852 4 ปีที่แล้ว +5

    Is anyone else's mind also exploding with thoughts and implications of all this???? Mindblown

  • @MsSergey1313
    @MsSergey1313 4 ปีที่แล้ว +1

    It is excellent tutorial! Thanks!

  • @euanespenilla1779
    @euanespenilla1779 4 ปีที่แล้ว

    Hello for anyone out there that has good knowledge with the MPU6050, I'm planning to make it a sort of Earthquake/Vibration detector but I want it to be configured in such a way that it will only send a signal to a sound device when it the accelerometer reaches a certain value threshold, is this possible?

  • @mikeyz8775
    @mikeyz8775 4 ปีที่แล้ว +3

    Is there a place i can chat about this kind of project. Maybe a forums

  • @fransflorenza9708
    @fransflorenza9708 3 ปีที่แล้ว

    hi, im using gy 521 module that use mpu6050 chip, but when i tried to used example code from adafruit library (basic readings), the serial shows that my chip is not found. any one can help me? thx..

  • @ericgroen253
    @ericgroen253 4 ปีที่แล้ว

    Very informative! Thank you!

  • @bernardcharlesworth9860
    @bernardcharlesworth9860 4 ปีที่แล้ว

    Thanks good introduction

  • @diptangshudutta3637
    @diptangshudutta3637 3 ปีที่แล้ว

    that was a brilliant vid thanks a lot

  • @mainhattencalling
    @mainhattencalling ปีที่แล้ว

    I think i might need some help understanding the stop paramater for endTransmission(bool) and requestFrom(address, quantity, bool). i get that if you type true as a stop parameter, the connection is stopped and if you type false the connection is kept alive. But how do i know what i need to use for my code? I really really want to have a better understanding for the I2C Bus, but i cant manage to find a more detailed description regarding this particular topic. Unfortunately i cant wrap my head around on what it means to 'stop' the Bus or to 'restart' it.
    If you read this, maybe you can leave a comment! I would be very very happy. Thank you in advance!

  • @ahmedansari6827
    @ahmedansari6827 2 ปีที่แล้ว

    what are the raw values of accelerometer and gyroscope? I mean is it linear acceleration, angular acceleration, angular velocity or angular position? And what unit? Please someone answer asap!

  • @omarbensekkou9467
    @omarbensekkou9467 4 ปีที่แล้ว

    hi eric thank you for thes video i have a project of ship stabelity i don t know how to jogin thes and a servo motor if you can please hel me

  • @bablugaonkar666
    @bablugaonkar666 ปีที่แล้ว

    This vedio is good help to learners like me i

  • @sudhishgokhale
    @sudhishgokhale 4 ปีที่แล้ว

    what is the meaning of DMP initialization failed ( Code 1)?

  • @merlin9657
    @merlin9657 4 ปีที่แล้ว +3

    Nice, but for me it only works if you write "Wire.endTransmission(false);" instead of "Wire.endTransmission(true);" in the setup.

  • @aryaprima6735
    @aryaprima6735 3 ปีที่แล้ว

    excuse me I want to ask, when I connect VCC with 5v, why did Arduino off sir @michael ?

  • @First.Last.99
    @First.Last.99 2 ปีที่แล้ว

    what is the smallest and cheapest controller I can use this module with?

  • @bablugaonkar666
    @bablugaonkar666 ปีที่แล้ว

    Sir can we rotate an image in x y z axis using accelerometer I want to do this project

  • @ipungtech5827
    @ipungtech5827 5 ปีที่แล้ว

    Youre amazing, tahnks very much

  • @vimukthifernando9238
    @vimukthifernando9238 4 ปีที่แล้ว

    Is it possible to put these code segments into the raspberry pi module?

  • @WoodGrainBear
    @WoodGrainBear 3 หลายเดือนก่อน

    Great video : - )

  • @jerryocrow1
    @jerryocrow1 4 ปีที่แล้ว

    Great intro. (Pardon me, but my hearing stumbles with "non American English", a rare form of "Huh?" This is minimized by speakers hanging around similar people who are willing to polish their pronunciation.) We all need polish, especially me! Thank you for an excellent introduction.

  • @rodneybernard4959
    @rodneybernard4959 3 ปีที่แล้ว

    What is the minimum time resolution between two measurements

  • @davidbarton1188
    @davidbarton1188 6 ปีที่แล้ว

    Curious if you know of anyway to use the mpu-6050 in a scenario where it's not connected to a computer and you could place it on a device and monitor movements and then go back and review those movements later. I'm assuming something else would be needed but am not aware of what that would be.

    • @LatinDanceVideos
      @LatinDanceVideos 6 ปีที่แล้ว

      David Barton will need to summarize data in real time then store data for later analysis.

  • @sciencestruck9698
    @sciencestruck9698 3 ปีที่แล้ว

    it was so nice

  • @LatinDanceVideos
    @LatinDanceVideos 6 ปีที่แล้ว

    Thanks for this.
    I want to use ESP32 board, assume I need to swap pins. Much of the addressing will be similar otherwise.
    Then I'm wondering how to process after raw values are accessed.

  • @syahrul9282
    @syahrul9282 5 ปีที่แล้ว

    Does accelerometer xalculate altitude?

  • @timkern9563
    @timkern9563 2 ปีที่แล้ว

    Asking everyone here: does anyone have a video on capturing and reading the temperature, or on how the Tangent function works?
    My application needs both temperature and Tangent. Thanks!

  • @Omar-pu7sq
    @Omar-pu7sq 6 ปีที่แล้ว

    thank you very much, you are the best

  • @JadwinManuel
    @JadwinManuel 2 ปีที่แล้ว

    I have been trying to use these sensors in my robotics projects, but i run into the wire.h code crashing intermintently. Like, it will work perfectly for hours, then it will crash the entire arduino the next day. i know its not brown out issues.

  • @nithinsai2250
    @nithinsai2250 3 ปีที่แล้ว

    It worked bro thanks a lot

  • @Jake-si9ih
    @Jake-si9ih 5 ปีที่แล้ว +1

    Help!
    I've hooked everything up properly and simply copy and pasted your code but it just prints the values a random number of times and just stops. All readings but temp are printed as -1

  • @Yash-Gaikwad
    @Yash-Gaikwad 2 ปีที่แล้ว

    How to get list of values of all register in memory of sensor?

  • @PoppyMusica
    @PoppyMusica 6 ปีที่แล้ว

    Is this better than the GY-85?

  • @chinmayakishore6219
    @chinmayakishore6219 5 ปีที่แล้ว

    is uploading the code the same as executing

  • @murlidewangan4277
    @murlidewangan4277 2 ปีที่แล้ว

    Your in video Last project Code is not worked
    Please help
    No any LEDs glow when I tilt sensor

  • @JohnGaliwango
    @JohnGaliwango 5 ปีที่แล้ว

    Nice Video!!!

  • @poojak3175
    @poojak3175 3 ปีที่แล้ว

    Hi sir I have made biped robot in which I have used Arduino and pca9685 as I want to balance my robot I had added mpu6050 I am getting problem in my program please help me sir

  • @grzesiek1x
    @grzesiek1x ปีที่แล้ว

    I had only my ADXL 335 and was wondering why I couldn't make my self balancing robot t owork and after some time I actually realised that it has only an accelelometer and no gyroscope (I always thought there are both) this is why my readings was not so precise while in motion so I need something which has borh actually ...

  • @jonidb2003
    @jonidb2003 5 ปีที่แล้ว

    Excellent Video, thank you very Much!!!, Wonder if you can help me, I need to manage 2 leds, I was trying to use your code, but I had the error message somehow while I am compiling the program: "the accelerometer_X was not declared in this scope" , even-thoug has been defined already here --- int16_t accelerometer_x, accelerometer_, accelerometer_z----; thanks!!!

  • @kapprison8624
    @kapprison8624 3 ปีที่แล้ว +7

    My values are just saying -1 and aren't changing, its wired the same as in the video and I have the same code so if anyone can help by maybe telling me some common mistakes I may be making then that'll be a great help. Edit: It was a connectivity issue, the pins weren't properly connected.

    • @rikerthiessen5027
      @rikerthiessen5027 3 ปีที่แล้ว

      Hey man I just opened 1 of the 3 I ordered today. It was working fine, and then it started reading only -1 for everything except temperature. I am just trying to test the MPU-6050 before soldering the pins on so I know whether I need to return it or not. Mine is wired the exact same and the code is the same... Do you think it would also be a connectivity issue? could I have fried it somehow? (EDIT: my green LED on the MPU-6050 still turns on so I assume it isn't fried?)

    • @austinbouvel9429
      @austinbouvel9429 ปีที่แล้ว

      I have same issue

    • @qsr6840
      @qsr6840 ปีที่แล้ว

      Hi. I have the same problem. Did you solve it?

    • @canodepvc2837
      @canodepvc2837 ปีที่แล้ว

      @@rikerthiessen5027 Did you solve it?

    • @qsr6840
      @qsr6840 ปีที่แล้ว

      @@qudsiyab.95 yeah, I already did the same thing and it worked. But thanks anyway :)

  • @surendramaharjan3129
    @surendramaharjan3129 2 ปีที่แล้ว

    Why didn't you explain about the Digital Motion Processor (DMP)?

  • @AslamYusof
    @AslamYusof 4 ปีที่แล้ว

    Thank you!

  • @tahakm1192
    @tahakm1192 2 ปีที่แล้ว

    Thank you for the great explanation, I have inserted the code and it compiled well and then it was uploaded fine.
    But the other screen did not show up (the screen with the temperature values and coordinates)
    Can you help?
    Thanks,

    • @tahakm1192
      @tahakm1192 2 ปีที่แล้ว +1

      I figured it out,
      Tools> Serial Monitor
      and it shows, I also got good readings,
      Thanks

  • @sulkifli5052
    @sulkifli5052 ปีที่แล้ว

    Thank you sir

  • @audiostratus
    @audiostratus 4 ปีที่แล้ว

    Fantastic video! Unfortunately I think my MPU6050 board might be bad ... the LED for the module is not lighting and my nano is not reading anything from it. For a Nano, do I need to assign the A4/A5 pins in setup or is it assumed by the Nano that they are used for this?

    • @Dutch3DMaster
      @Dutch3DMaster 3 ปีที่แล้ว +1

      Late response, but did you use the Wire.h library? This is what activates the A4 and A5 pins for the I2C bus instead of them being regular Analog pins.

    • @audiostratus
      @audiostratus 3 ปีที่แล้ว

      @@Dutch3DMaster I don’t think I did...I’ll check and try that, thanks!

  • @canuysalel8758
    @canuysalel8758 6 ปีที่แล้ว +5

    Hi, what are the units for outputs of accelerometer and gyroscope, for instance m/s^2 for accelerometer or radians for gyroscope?

    • @eggnogg589
      @eggnogg589 6 ปีที่แล้ว +2

      these vals in the serial monitor are raw values from i2c. The mpu6050 data sheet has conversions to g/degrees based on what sensitivity you define for your chip.

  • @hendrikjansevanrensburg881
    @hendrikjansevanrensburg881 5 ปีที่แล้ว +1

    Great tut man, I have one problem, my serial monitor shows "-1" for every value of aX, aY, aZ and the gyro values. All are "-1", any idea what could be the cause?

    • @mennomjorna
      @mennomjorna 5 ปีที่แล้ว

      Same thing here, already found the solution??

    • @werkhaye
      @werkhaye 5 ปีที่แล้ว

      I had the same problem, it turns out that the reason I was getting this output was because the module wasn't connected properly (it was loose on the breadboard). Hope this helped

  • @jameselliott9397
    @jameselliott9397 5 ปีที่แล้ว

    I would love if people would just post code in the comments.maybe if I suggest it enough I can get a trend started.

  • @YTimo
    @YTimo 4 ปีที่แล้ว

    @Michael Schoeffler Wie kann ich dafür sorgen, dass wenn ich das Bewege, dass es dann so ist als hätte ich meine Maus bewegt?

    • @Dutch3DMaster
      @Dutch3DMaster 3 ปีที่แล้ว

      Use a Mouse library and have the gyroscope values be the readout for mouse movement, there are probably tutorials on this on TH-cam.

  • @kjtemmes
    @kjtemmes 2 ปีที่แล้ว

    Hi.
    all is working but app isnt..
    I have checked the BT with terminal and all is good...
    App just isnt...

  • @vishalkumarvishal2651
    @vishalkumarvishal2651 5 ปีที่แล้ว +1

    Where is the led source code

  • @AeroCraftAviation
    @AeroCraftAviation 3 ปีที่แล้ว

    Aaah how do you install the I2Cdevlib? I extracted the "Arduino" folder from the entire ZIP file. Then put the Arduino folder into the user_libraries folder in documents/Arduino/libraries/user_libraries. I put #include in my sketch, and it says "no such file or directory". How to fix?!

    • @viliasiosirait4361
      @viliasiosirait4361 3 ปีที่แล้ว

      in case you still need it, Go extract only the i2cdev folder inside the arduino. makesure the extracted folder is being converted to .zip before you include it into the library

  • @adityasharma-jh5ct
    @adityasharma-jh5ct ปีที่แล้ว

    wow nice video

  • @bigheat86
    @bigheat86 5 ปีที่แล้ว

    Nice one.