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

  Рет қаралды 376,601

Michael Schoeffler

Michael Schoeffler

Күн бұрын

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 жыл бұрын
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 жыл бұрын
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 жыл бұрын
Thank you for this excellent introduction to the MPU6050!
@icarossavvides2641
@icarossavvides2641 2 жыл бұрын
Good tutorial as a springboard, refreshing to see well documented code!
@aalizwel2061
@aalizwel2061 6 жыл бұрын
Awesome Best MPU6050 tutorial online Thanks a lot
@vivansheth1902
@vivansheth1902 2 жыл бұрын
thankyou so much i looked at around 50 tutorials and i understood just you 🤗🤗🤗
@user-mx8nn2gg6q
@user-mx8nn2gg6q 6 жыл бұрын
Great job ! I learn a lot from your video,Thank you !
@marosakr778
@marosakr778 6 жыл бұрын
many thanks , it is very helpful , short , and informative. very practical.
@rileystewart9165
@rileystewart9165 5 жыл бұрын
That's awesome that it has motion detection!
@gamories8106
@gamories8106 3 жыл бұрын
Thank you, sir. That is my semester final project, gonna submit it tomorrow.
@MarkSMays
@MarkSMays 5 жыл бұрын
Great, clear explanation. Thanks!
@manishpingale6558
@manishpingale6558 4 жыл бұрын
Thank you so much for your support and help
@amankushwaha3395
@amankushwaha3395 5 жыл бұрын
Good tutorial. It was very helpful
@janiskrumins3263
@janiskrumins3263 4 жыл бұрын
Very good, thanks from Latvia!
@neilgrice9251
@neilgrice9251 3 жыл бұрын
An excellent Tutorial. Thank you so much.
@sriramrepaka7003
@sriramrepaka7003 4 жыл бұрын
Great too informative thanks for the introduction
@MarioMonte13
@MarioMonte13 5 жыл бұрын
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?
@timmorgan3673
@timmorgan3673 6 жыл бұрын
Many thanks for a great tutorial
@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.
@tseckwr3783
@tseckwr3783 2 жыл бұрын
Nice job of explaining. Thanks
@katyd2959
@katyd2959 6 жыл бұрын
I want to try MPU 6050 to your tutorial, thank you
@vaingloryarmonia6859
@vaingloryarmonia6859 6 жыл бұрын
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?
@Marco110981
@Marco110981 4 жыл бұрын
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?
@rahultri333
@rahultri333 6 жыл бұрын
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 .
@ericgroen253
@ericgroen253 4 жыл бұрын
Very informative! Thank you!
@dutchdykefinger
@dutchdykefinger 5 жыл бұрын
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
@mustafash484
@mustafash484 6 жыл бұрын
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
@You7aRe7My7LivE
@You7aRe7My7LivE 2 жыл бұрын
sehr sehr hilfreich - besten Dank!
@MsSergey1313
@MsSergey1313 4 жыл бұрын
It is excellent tutorial! Thanks!
@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
@wolfie3657
@wolfie3657 10 ай бұрын
Oh thank you, thank you, thank you! This is perfect for me!
@simonemastroianni1985
@simonemastroianni1985 6 жыл бұрын
In my Leonardo board there are only 2 pins with writed: SDA and SDL
@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)?
@DzulfiqarDYanto
@DzulfiqarDYanto 5 жыл бұрын
how to change the accelerometer value from the unit of numbers to the angle unit?
@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
@chandradasabulathsinhala6038
@chandradasabulathsinhala6038 4 жыл бұрын
Thanks for a great explanation. I am a Sri Lankan....
@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.
@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
@merlin9657
@merlin9657 4 жыл бұрын
Nice, but for me it only works if you write "Wire.endTransmission(false);" instead of "Wire.endTransmission(true);" in the setup.
@Omar-pu7sq
@Omar-pu7sq 6 жыл бұрын
thank you very much, you are the best
@bernardcharlesworth9860
@bernardcharlesworth9860 4 жыл бұрын
Thanks good introduction
@samaanbisso5112
@samaanbisso5112 4 жыл бұрын
Can you switch the data of the accelerometer to read in frequency (Hz) using only Arduino?
@diptangshudutta3637
@diptangshudutta3637 3 жыл бұрын
that was a brilliant vid thanks a lot
@sudhishgokhale
@sudhishgokhale 5 жыл бұрын
what is the meaning of DMP initialization failed ( Code 1)?
@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?
@syahrul9282
@syahrul9282 5 жыл бұрын
Does accelerometer xalculate altitude?
@ipungtech5827
@ipungtech5827 5 жыл бұрын
Youre amazing, tahnks very much
@sergej529
@sergej529 4 жыл бұрын
Thank you for this good introduction. How can I read two of the MPU6050 devices on the same I2C bus?
@chinmayakishore6219
@chinmayakishore6219 5 жыл бұрын
is uploading the code the same as executing
@mikeyz8775
@mikeyz8775 4 жыл бұрын
Is there a place i can chat about this kind of project. Maybe a forums
@prstyodc
@prstyodc 4 жыл бұрын
hello, if i want change the output to angle with mpu 6050, what i must change?
@occocia
@occocia 2 жыл бұрын
What can i use to measure the impact of a object to ground. I want to have all the measuring sensors inside the object.
@MrVicenteRJ
@MrVicenteRJ 3 жыл бұрын
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
@christopherclark2205
@christopherclark2205 5 жыл бұрын
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.
@PoppyMusica
@PoppyMusica 6 жыл бұрын
Is this better than the GY-85?
@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?
@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 4 жыл бұрын
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.
@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!
@rodneybernard4959
@rodneybernard4959 3 жыл бұрын
What is the minimum time resolution between two measurements
@jackfrost4033
@jackfrost4033 5 ай бұрын
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
@aryaprima6735
@aryaprima6735 3 жыл бұрын
excuse me I want to ask, when I connect VCC with 5v, why did Arduino off sir @michael ?
@nithinsai2250
@nithinsai2250 3 жыл бұрын
It worked bro thanks a lot
@m.s.3346
@m.s.3346 3 жыл бұрын
Thanks. I just gave this video the 2500th thumb up.
@First.Last.99
@First.Last.99 2 жыл бұрын
what is the smallest and cheapest controller I can use this module with?
@rohitrai6187
@rohitrai6187 4 жыл бұрын
Thanks. Very Helpful.
@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!
@WoodGrainBear
@WoodGrainBear 5 ай бұрын
Great video : - )
@vimukthifernando9238
@vimukthifernando9238 4 жыл бұрын
Is it possible to put these code segments into the raspberry pi module?
@Yash-Gaikwad
@Yash-Gaikwad 2 жыл бұрын
How to get list of values of all register in memory of sensor?
@bablugaonkar666
@bablugaonkar666 Жыл бұрын
Sir can we rotate an image in x y z axis using accelerometer I want to do this project
@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..
@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!
@JohnGaliwango
@JohnGaliwango 5 жыл бұрын
Nice Video!!!
@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.
@vishalkumarvishal2651
@vishalkumarvishal2651 5 жыл бұрын
Where is the led source code
@jonidb2003
@jonidb2003 6 жыл бұрын
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 жыл бұрын
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 :)
@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.
@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.
@sciencestruck9698
@sciencestruck9698 3 жыл бұрын
it was so nice
@mechatronicsevolution1624
@mechatronicsevolution1624 3 жыл бұрын
What does waking up the MPU mean?
@anomiedesign5030
@anomiedesign5030 2 жыл бұрын
how to add a second module?
@AslamYusof
@AslamYusof 4 жыл бұрын
Thank you!
@jsquaredm
@jsquaredm 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.
@surendramaharjan3129
@surendramaharjan3129 3 жыл бұрын
Why didn't you explain about the Digital Motion Processor (DMP)?
@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 KZfaq.
@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 ...
@chinmayakishore6219
@chinmayakishore6219 5 жыл бұрын
it is not changing values it is remaining constant
@AnkitPatelAP
@AnkitPatelAP 5 жыл бұрын
make on load cell
@kuwainguljar9776
@kuwainguljar9776 2 жыл бұрын
Where can i get the code for the LEDs?
@Jake-si9ih
@Jake-si9ih 5 жыл бұрын
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
@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
@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 жыл бұрын
I figured it out, Tools> Serial Monitor and it shows, I also got good readings, Thanks
@random_idRI
@random_idRI 6 ай бұрын
How white servo motor
@hendrikjansevanrensburg881
@hendrikjansevanrensburg881 5 жыл бұрын
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
@bablugaonkar666
@bablugaonkar666 Жыл бұрын
This vedio is good help to learners like me i
@canuysalel8758
@canuysalel8758 6 жыл бұрын
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 жыл бұрын
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.
@bigheat86
@bigheat86 5 жыл бұрын
Nice one.
@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
Build an Electronic Level with MPU-6050 and Arduino
33:37
DroneBot Workshop
Рет қаралды 314 М.
MPU6050 with Arduino - GY-521
8:41
DIY Engineers
Рет қаралды 51 М.
НЫСАНА КОНЦЕРТ 2024
2:26:34
Нысана театры
Рет қаралды 833 М.
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 31 МЛН
How does an Accelerometer work? | 3D Animation
6:11
CircuitBread
Рет қаралды 55 М.
Tutorial: MH Sensor Series/KY-033/TCRT5000 + LCM1602 IIC V1 | UATS A&S #13
6:40
Detailed MPU6050 Tutorial
55:34
Maker's Wharf
Рет қаралды 37 М.
RFID Readers RDM6300 and RDM630 (Arduino-Tutorial) | UATS A&S #15
13:15
Michael Schoeffler
Рет қаралды 51 М.
Arduino in focus - GY-521 MPU6050 accelerator and position sensor
12:27
Mein Elektronik Hobby
Рет қаралды 9 М.
Самые крутые школьные гаджеты
0:49
iPhone, Galaxy или Pixel? 😎
0:16
serg1us
Рет қаралды 1,3 МЛН
Сколько реально стоит ПК Величайшего?
0:37
Telefonu Parçaladım!😱
0:16
Safak Novruz
Рет қаралды 26 МЛН
iPhone 15 Pro Max vs IPhone Xs Max  troll face speed test
0:33