{"id":10827,"date":"2021-01-16T14:14:27","date_gmt":"2021-01-16T14:14:27","guid":{"rendered":"https:\/\/wolles-elektronikkiste.de\/mpu6050-accelerometer-and-gyroscope"},"modified":"2024-10-29T13:25:50","modified_gmt":"2024-10-29T13:25:50","slug":"mpu6050-accelerometer-and-gyroscope","status":"publish","type":"post","link":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope","title":{"rendered":"MPU6050 Accelerometer and Gyroscope"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">About this post<\/h2>\n\n<p>The MPU6050, or more precisely the module based on it, is a 3-axis accelerometer and 3-axis gyroscope. In addition, the MPU6050 measures the temperature. A lot has already been written about this sensor, but maybe I can give you one or the other new aspect with this post, like the interrupt programming.<\/p>\r\n<p>The post is structured as follows:<\/p>\r\n<ul>\r\n<li><a href=\"#anker1\">Basics<\/a>\r\n<ul>\r\n<li><a href=\"#anker1\">Measuring principle<\/a><\/li>\r\n<li><a href=\"#anker2\">Technical characteristics<\/a><\/li>\r\n<\/ul>\r\n<\/li>\r\n<li><a href=\"#anker3\">Control without library<\/a>\r\n<ul>\r\n<li><a href=\"#anker3\">Minimal sketch<\/a><\/li>\r\n<li><a href=\"#anker4\">Extended sketch<\/a><\/li>\r\n<li><a href=\"#anker5\">Interrupts<\/a><\/li>\r\n<\/ul>\r\n<\/li>\r\n<li><a href=\"#anker6\">Control with library<\/a>\r\n<ul>\r\n<li><a href=\"#anker6\">Adafruit_MPU6050 Library<\/a><\/li>\r\n<li><a href=\"#anker7\">MPU6500_light<\/a><\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n\n<p>If you just want to get started quickly, you can go directly to the libraries.<a id=\"anker1\"><\/a><\/p>\r\n\n<h2 class=\"wp-block-heading\">Basics<\/h2>\n\n<h3 class=\"wp-block-heading\">The measuring principle of the MPU6050<\/h3>\n\n<p>In the context of accelerometers, you often come across the terms &#8220;3-axis&#8221;, &#8220;6-axis&#8221; or even &#8220;9-axis sensors&#8221;. Don&#8217;t worry, we are not leaving the three-dimensional world. Instead, one or more sensors, which are effective in three dimensions, are used in parallel. And in the case of the MPU6050, this is an accelerometer and a gyroscope. 9-axis sensors usually have an additional geomagnetic field sensor.<\/p>\r\n\n<h4 class=\"wp-block-heading\">Gyroscopes<\/h4>\n\n<p>The classical <a href=\"https:\/\/en.wikipedia.org\/wiki\/Gyroscope\" target=\"_blank\" rel=\"noopener noreferrer\">gyroscope<\/a> works like a toy whipping top. Everyone knows it from childhood and also its effect. The rotation stabilizes it (precession) and therefore the attempt to tilt its axis of rotation requires force. And exactly with this, you can determine the inclination or angular acceleration of an object (e.g. an airplane or ship). Compared to the simple whipping tops, the gyroscope is mounted in a frame. An exemplary toy gyroscope:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Kreiselspielzeug-1024x611.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"611\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Kreiselspielzeug-1024x611.png\" alt=\"A toy gyroscope\" class=\"wp-image-9495\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Kreiselspielzeug-1024x611.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Kreiselspielzeug-300x179.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Kreiselspielzeug-768x458.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Kreiselspielzeug-1536x917.png 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Kreiselspielzeug-1320x788.png 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Kreiselspielzeug.png 1900w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">A toy gyroscope<\/figcaption><\/figure>\n\n<p>In the MPU6050 there is of course no part which is spinning (and fortunately, you don\u2019t have to move it manually ;-)). Such sensors are based on&#8221;<a href=\"https:\/\/en.wikipedia.org\/wiki\/MEMS\" target=\"_blank\" rel=\"noopener noreferrer\">Micro-Electric-Mechanical Systems<\/a>&#8221; (MEMS). In the case of gyroscopes, these are moving parts that change their position within a fixed frame when accelerated. The distance change results in a change in capacity. In principle, this is how it looks:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/01\/Accel_sensor_principle.png\"><img decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/01\/Accel_sensor_principle-1024x311.png\" alt=\"The measuring principle of the MPU6050\" class=\"wp-image-9498\"\/><\/a><figcaption class=\"wp-element-caption\">The measuring principle of the MPU6050<\/figcaption><\/figure>\n\n<p>An older technique is based on the piezo effect, so it uses pressure changes as the measuring principle.<\/p>\r\n\n<h4 class=\"wp-block-heading\">Accelerometers<\/h4>\n\n<p>An accelerometer works according to the same principle. The difference is that the accelerometer detects acceleration in the x-, y-, and z-axis <strong>directions<\/strong>, while the gyroscope detects motion <strong>about<\/strong> the axes. When the module is in the idle state, the gyroscope returns zero for x, y and z. The acceleration sensor, on the other hand, detects the acceleration due to gravity even at rest (in the z-direction when the module is flat).<\/p>\r\n<p>The modules have printed the position of the x- and y-axis. The z-axis is the perpendicular on the module.<a id=\"anker2\"><\/a><\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050-1024x564.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"564\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050-1024x564.jpg\" alt=\"MPU6050 Module\" class=\"wp-image-9493\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050-1024x564.jpg 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050-300x165.jpg 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050-768x423.jpg 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050-1536x846.jpg 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050-1320x727.jpg 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050.jpg 1900w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">MPU6050 Module<\/figcaption><\/figure>\n\n<h3 class=\"wp-block-heading\">Technical Data \/ Features<\/h3>\n\n<p>The most important technical data of the MPU6050 are:<\/p>\r\n<ul>\r\n<li><strong>Power supply <\/strong>(VDD\/GND): the module has an LDO voltage converter (see also <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/voltage-regulation-linear-and-switching-regulators\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>), and hence it can be supplied with 3.3 volts as well as with 5 volts.<\/li>\r\n<li><strong>Power consumption<\/strong>(module): approx. 5.1 mA, in sleep mode approx. 1.4 mA (own measurements). If you remove the LED, the consumption is reduced to 3.7 mA or 33 \u00b5A in sleep mode.<\/li>\r\n<li><strong>Accelerometer<\/strong>:&nbsp;16-bit resolution, measuring ranges +\/- 2, 4, 8 or 16 g; with g = earth acceleration, not grams!<\/li>\r\n<li><strong>Gyroscope<\/strong>:&nbsp;16-bit resolution, measuring ranges: +\/- 250, 500, 1000 or 2000\u00b0\/s.<\/li>\r\n<li><strong>Communication <\/strong>(SDA\/SCL): I2C, address 0x68 (AD0 = GND or unconnected) or 0x69 (AD0 = HIGH)<\/li>\r\n<li><strong>Interrupts<\/strong>: data ready, free fall, acceleration limit;<\/li>\r\n<li><strong>Connection of additional sensors<\/strong> (XDA \/ XCL): I will not go into this.<\/li>\r\n<\/ul>\r\n<p>For more information, see the <a href=\"https:\/\/invensense.tdk.com\/wp-content\/uploads\/2015\/02\/MPU-6000-Datasheet1.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">data sheet<\/a> and the <a href=\"https:\/\/invensense.tdk.com\/wp-content\/uploads\/2015\/02\/MPU-6000-Register-Map1.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">register map<\/a>.<a id=\"anker3\"><\/a><\/p>\r\n\n<h2 class=\"wp-block-heading\">Control of the MPU6050 without library<\/h2>\n\n<h3 class=\"wp-block-heading\">The minimal sketch<\/h3>\n\n<p>If you can live with the defaults (+\/-2 g, +\/-250\u00b0\/s), then you might get by with the following sketch (based on: <a href=\"https:\/\/playground.arduino.cc\/Main\/MPU-6050\/\" target=\"_blank\" rel=\"noopener noreferrer\">Arduino Playground<\/a>).\u00a0<\/p>\r\n<p>I\u2019m not going to go through all the details of the sketch, just so much:<\/p>\r\n<ul>\r\n<li>First, the MPU6050 is awakened by the entry of a zero in the \u201cPower Management 1\u201d register.<\/li>\r\n<li>The MPU6050 continuously produces results for acceleration, gyroscope and temperature.<\/li>\r\n<li>Since the result registers are sequential, they can be read out conveniently in one go.<\/li>\r\n<li>Only raw data is output (-32767 to + 32767).<\/li>\r\n<\/ul>\r\n\n<div class=\"scroll-paragraph-long\">\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"MPU6050_minimum.ino\" data-enlighter-title=\"MPU6050_minimum.ino\">#include \"Wire.h\" \r\n\r\n#define MPU6050_ADDR 0x68 \/\/ Alternatively set AD0 to HIGH  --&gt; Address = 0x69\r\n\r\nint16_t accX, accY, accZ, gyroX, gyroY, gyroZ, tRaw; \/\/ Raw register values (accelaration, gyroscope, temperature)\r\nchar result[7]; \/\/ temporary variable used in convert function\r\n\r\nvoid setup() {\r\n  Serial.begin(9600);\r\n  Wire.begin();\r\n  Wire.beginTransmission(MPU6050_ADDR);\r\n  Wire.write(0x6B); \/\/ PWR_MGMT_1 register\r\n  Wire.write(0); \/\/ wake up!\r\n  Wire.endTransmission(true);\r\n}\r\nvoid loop() {\r\n  Wire.beginTransmission(MPU6050_ADDR);\r\n  Wire.write(0x3B); \/\/ starting with register 0x3B (ACCEL_XOUT_H)\r\n  Wire.endTransmission(false); \/\/ the parameter indicates that the Arduino will send a restart. \r\n                               \/\/ As a result, the connection is kept active.\r\n  Wire.requestFrom(MPU6050_ADDR, 14, true); \/\/ request a total of 7*2=14 registers\r\n  \r\n  \/\/ \"Wire.read()&lt;&lt;8 | Wire.read();\" means two registers are read and stored in the same int16_t variable\r\n  accX = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x3B (ACCEL_XOUT_H) and 0x3C (ACCEL_XOUT_L)\r\n  accY = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x3D (ACCEL_YOUT_H) and 0x3E (ACCEL_YOUT_L)\r\n  accZ = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x3F (ACCEL_ZOUT_H) and 0x40 (ACCEL_ZOUT_L)\r\n  tRaw = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x41 (TEMP_OUT_H) and 0x42 (TEMP_OUT_L)\r\n  gyroX = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x43 (GYRO_XOUT_H) and 0x44 (GYRO_XOUT_L)\r\n  gyroY = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x45 (GYRO_YOUT_H) and 0x46 (GYRO_YOUT_L)\r\n  gyroZ = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x47 (GYRO_ZOUT_H) and 0x48 (GYRO_ZOUT_L)\r\n  \r\n  Serial.print(\"AcX = \"); Serial.print(toStr(accX));\r\n  Serial.print(\" | AcY = \"); Serial.print(toStr(accY));\r\n  Serial.print(\" | AcZ = \"); Serial.print(toStr(accZ));\r\n  \/\/ from data sheet:\r\n  Serial.print(\" | tmp = \"); Serial.print((tRaw + 12412.0) \/ 340.0);\r\n  Serial.print(\" | GyX = \"); Serial.print(toStr(gyroX));\r\n  Serial.print(\" | GyY = \"); Serial.print(toStr(gyroY));\r\n  Serial.print(\" | GyZ = \"); Serial.print(toStr(gyroZ));\r\n  Serial.println();\r\n  \r\n  delay(1000);\r\n}\r\n\r\nchar* toStr(int16_t character) { \/\/ converts int16 to string and formatting\r\n  sprintf(result, \"%6d\", character);\r\n  return result;\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n<\/div>\r\n\n<p>Below you can see the output of the sketch on the serial monitor. Since the MPU6050 was placed flat in the x\/y plane, all results except acceleration in the z-direction (acceleration due to gravity) should be zero. This is not the case, but the result is not bad in first approximation.<\/p>\r\n<p>You can adjust the initial values by entering offset values in corresponding registers. Some libraries have implemented this option, others have not.<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_sketch-1024x339.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"339\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_sketch-1024x339.png\" alt=\"Output of the minimal sketch for the MPU6050\" class=\"wp-image-9507\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_sketch-1024x339.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_sketch-300x99.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_sketch-768x255.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_sketch.png 1053w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Output of the minimal sketch for the MPU6050<\/figcaption><\/figure>\n\n<p>For completeness, I have shown the circuit here. We will need the LED and the line to the interrupt later. Pull-ups for the I2C lines (3.3 V) are integrated on the module. <a id=\"anker4\"><\/a><\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050_Wiring-1024x629.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"629\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050_Wiring-1024x629.png\" alt=\"Wiring the MPU6050 with the Arduino\" class=\"wp-image-9511\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050_Wiring-1024x629.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050_Wiring-300x184.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050_Wiring-768x472.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/MPU6050_Wiring.png 1243w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Wiring the MPU6050 with the Arduino<\/figcaption><\/figure>\n\n<h3 class=\"wp-block-heading\">The extended Minimalsketch <\/h3>\n\n<p>I then added a few extras to the minimum sketch:<\/p>\r\n<ul>\r\n<li><code>setAccRange()<\/code> sets the measuring range for acceleration.<\/li>\r\n<li><code>setGyrRange()<\/code> sets the measuring range for the gyroscope.<\/li>\r\n<li><code>MCP6050_wakeUp()<\/code> awakens the MPU6050.\r\n<ul>\r\n<li>It needs some time to wake up, only after 30 ms I could determine meaningful gyroscope values.<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li><code>MCP6050_sleep<\/code> sends the MPU6050 to sleep.<\/li>\r\n<\/ul>\r\n<p>By applying intermittent sleep, I could reduce the power consumption from 5.2 to 1.4 mA with the following sketch. If you then remove the LED, the consumption drops to less than 0.1 mA.<\/p>\r\n<p>If you want to understand the sketch in terms of register settings, take a look at the <a href=\"https:\/\/invensense.tdk.com\/wp-content\/uploads\/2015\/02\/MPU-6000-Register-Map1.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">register map<\/a>.<\/p>\r\n\n<div class=\"scroll-paragraph-long\">\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"minimum_sketch_extended.ino\" data-enlighter-title=\"minimum_sketch_extended.ino\">#include \"Wire.h\" \r\n\r\n#define MPU6050_ADDR              0x68 \/\/ Alternatively set AD0 to HIGH  --&gt; Address = 0x69\r\n#define MPU6050_GYRO_CONFIG       0x1B \/\/\/&lt; Gyro specfic configuration register\r\n#define MPU6050_ACCEL_CONFIG      0x1C\r\n#define MPU6050_ACCEL_XOUT_H      0x3B\r\n#define MPU6050_PWR_MGT_1         0x6B\r\n#define MPU6050_SLEEP             0x06\r\n\r\ntypedef enum {\r\n  MPU6050_ACC_RANGE_2G,  \/\/ +\/- 2g (default)\r\n  MPU6050_ACC_RANGE_4G,  \/\/ +\/- 4g\r\n  MPU6050_ACC_RANGE_8G,  \/\/ +\/- 8g\r\n  MPU6050_ACC_RANGE_16G \/\/ +\/- 16g\r\n} mpu6050_acc_range;\r\n\r\ntypedef enum {\r\n  MPU6050_GYR_RANGE_250,  \/\/ +\/- 250 deg\/s (default)\r\n  MPU6050_GYR_RANGE_500,  \/\/ +\/- 500 deg\/s\r\n  MPU6050_GYR_RANGE_1000, \/\/ +\/- 1000 deg\/s\r\n  MPU6050_GYR_RANGE_2000  \/\/ +\/- 2000 deg\/s\r\n} mpu6050_gyr_range;\r\n\r\nint16_t accX, accY, accZ, gyroX, gyroY, gyroZ, tRaw; \/\/ Raw register values (accelaration, gyroscope, temperature)\r\nchar result[7];\r\n\r\nvoid setup() {\r\n  Serial.begin(9600);\r\n  Wire.begin();\r\n  MPU6050_wakeUp();\r\n  setAccRange(MPU6050_ACC_RANGE_16G);\r\n  setGyrRange(MPU6050_GYR_RANGE_250);\r\n}\r\n\r\nvoid loop() {\r\n  MPU6050_wakeUp();\r\n  Wire.beginTransmission(MPU6050_ADDR);\r\n  Wire.write(MPU6050_ACCEL_XOUT_H); \/\/ starting with register ACCEL_XOUT_H\r\n  Wire.endTransmission(false); \/\/ the parameter indicates that the Arduino will send a restart. \r\n                               \/\/ As a result, the connection is kept active.\r\n  Wire.requestFrom(MPU6050_ADDR, 7*2, true); \/\/ request a total of 7*2=14 registers\r\n  \r\n  \/\/ \"Wire.read()&lt;&lt;8 | Wire.read();\" means two registers are read and stored in the same variable\r\n  accX = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x3B (ACCEL_XOUT_H) and 0x3C (ACCEL_XOUT_L)\r\n  accY = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x3D (ACCEL_YOUT_H) and 0x3E (ACCEL_YOUT_L)\r\n  accZ = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x3F (ACCEL_ZOUT_H) and 0x40 (ACCEL_ZOUT_L)\r\n  tRaw = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x41 (TEMP_OUT_H) and 0x42 (TEMP_OUT_L)\r\n  gyroX = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x43 (GYRO_XOUT_H) and 0x44 (GYRO_XOUT_L)\r\n  gyroY = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x45 (GYRO_YOUT_H) and 0x46 (GYRO_YOUT_L)\r\n  gyroZ = Wire.read()&lt;&lt;8 | Wire.read(); \/\/ reading registers: 0x47 (GYRO_ZOUT_H) and 0x48 (GYRO_ZOUT_L)\r\n  MPU6050_sleep();\r\n  \r\n  \/\/ print out data\r\n  Serial.print(\"AcX = \"); Serial.print(toStr(accX));\r\n  Serial.print(\" | AcY = \"); Serial.print(toStr(accY));\r\n  Serial.print(\" | AcZ = \"); Serial.print(toStr(accZ));\r\n  \/\/ the following equation was taken from the documentation [MPU-6000\/MPU-6050 Register Map and Description, p.30]\r\n  Serial.print(\" | tmp = \"); Serial.print((tRaw + 12412.0) \/ 340.0);\r\n  Serial.print(\" | GyX = \"); Serial.print(toStr(gyroX));\r\n  Serial.print(\" | GyY = \"); Serial.print(toStr(gyroY));\r\n  Serial.print(\" | GyZ = \"); Serial.print(toStr(gyroZ));\r\n  Serial.println();\r\n  \r\n  delay(1000);\r\n}\r\n\r\nchar* toStr(int16_t i) { \/\/ int16 to string plus output format\r\n  sprintf(result, \"%6d\", i);\r\n  return result;\r\n}\r\n\r\nvoid setAccRange(mpu6050_acc_range range){\r\n  writeRegister(MPU6050_ACCEL_CONFIG, range&lt;&lt;3);\r\n}\r\n\r\nvoid setGyrRange(mpu6050_gyr_range range){\r\n  writeRegister(MPU6050_GYRO_CONFIG, range&lt;&lt;3);\r\n}\r\n\r\nvoid MPU6050_wakeUp(){\r\n  writeRegister(MPU6050_PWR_MGT_1, 0); \r\n  delay(30); \/\/ give him time to wake up, gyro needs quite a while to stabilize;\r\n}\r\n\r\nvoid MPU6050_sleep(){\r\n  writeRegister(MPU6050_PWR_MGT_1, 1&lt;&lt;MPU6050_SLEEP); \r\n}\r\n\r\nvoid writeRegister(uint16_t reg, byte value){\r\n  Wire.beginTransmission(MPU6050_ADDR);\r\n  Wire.write(reg); \r\n  Wire.write(value); \r\n  Wire.endTransmission(true);\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n<\/div>\r\n\n<p>Since I have chosen the range +\/- 16 g in the example, the measured values for the acceleration in z-direction decrease to one eighth:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_plus_sketch-1024x339.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"339\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_plus_sketch-1024x339.png\" alt=\"Output of the extended minimal sketch\" class=\"wp-image-9516\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_plus_sketch-1024x339.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_plus_sketch-300x99.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_plus_sketch-768x255.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_minimum_plus_sketch.png 1053w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Output of the extended minimal sketch<\/figcaption><\/figure>\n\n<p>I could have added more features, but at some point it gets confusing and then libraries are the better choice.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Conversion of raw data<\/h3>\n\n<p>For the conversion of the raw values to values in g, the following applies:<\/p>\r\n\n<p><\/p>\r\n<p><p class=\"ql-center-displayed-equation\" style=\"line-height: 40px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-604abe755f7b921d1d4a6bcab33a5532_l3.png\" height=\"40\" width=\"263\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91; &#92;&#116;&#101;&#120;&#116;&#123;&#103;&#45;&#118;&#97;&#108;&#117;&#101;&#125;&#92;&#59;&#91;&#92;&#116;&#101;&#120;&#116;&#123;&#103;&#125;&#93;&#61;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#118;&#101;&#114;&#116;&#32;&#114;&#97;&#110;&#103;&#101;&#32;&#92;&#118;&#101;&#114;&#116;&#92;&#99;&#100;&#111;&#116;&#32;&#114;&#97;&#119;&#86;&#92;&#33;&#97;&#108;&#117;&#101;&#125;&#123;&#51;&#50;&#55;&#54;&#56;&#125; &#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/p>\r\n\n<p>The conversion of the gyroscope data into angular velocities is done according to the following formula (derived from the data sheet):<a id=\"anker5\"><\/a><\/p>\r\n\n<p><p class=\"ql-center-displayed-equation\" style=\"line-height: 40px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-ada29571dea7903a365066d28181591b_l3.png\" height=\"40\" width=\"235\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91; &#92;&#111;&#109;&#101;&#103;&#97;&#92;&#59;&#91;&#92;&#116;&#101;&#120;&#116;&#123;&deg;&#92;&#33;&#47;&#115;&#125;&#93;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#92;&#118;&#101;&#114;&#116;&#32;&#114;&#97;&#110;&#103;&#101;&#32;&#92;&#118;&#101;&#114;&#116;&#92;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#114;&#97;&#119;&#86;&#92;&#33;&#97;&#108;&#117;&#101;&#125;&#123;&#49;&#51;&#49;&#92;&#99;&#100;&#111;&#116;&#32;&#50;&#53;&#48;&#125; &#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/p>\r\n\n<h3 class=\"wp-block-heading\">Interrupts<\/h3>\n\n<p>Perhaps the following very short video of the &#8220;Magic Push Button&#8221; will whet your appetite for the interrupt function, which by the way was not implemented in any library I looked at.<\/p>\r\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\r\n<iframe loading=\"lazy\" title=\"magic push button\" width=\"731\" height=\"411\" src=\"https:\/\/www.youtube.com\/embed\/sJ_21T3ZkN0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\r\n<\/div><\/figure>\r\n\n<p>As you can see, a press on the button makes the LED glow \u2013 even though the button is not connected at all. The solution to the puzzle is that the vibration when the pushbutton is pressed is sufficient to trigger a correspondingly sensitive \u201cwake on motion\u201d interrupt. So, I could just as easily have knocked on the table. The Arduino sketch ensures that when the interrupt is registered, the LED lights up for one second.<\/p>\r\n<p>You can also do other great things with this interrupt. For example, you can build a device that turns itself on when you pick it up. If it\u2019s lying around, it should be sleeping. No problem, you only have to use the interrupt signal as a wake-up signal for the microcontroller. See also my article about <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/sleep-modes-and-power-management\" target=\"_blank\" rel=\"noopener noreferrer\">Sleep Modes<\/a>.<\/p>\r\n\n<h4 class=\"wp-block-heading\">The problem with undocumented registers<\/h4>\n\n<p>The datasheet of the MPU6050 describes a procedure for setting up interrupts. The problem is that it doesn\u2019t work. While searching the net, I came across <a href=\"https:\/\/www.eluke.nl\/2016\/08\/11\/how-to-enable-motion-detection-interrupt-on-mpu6050\/\" target=\"_blank\" rel=\"noopener\">this page<\/a>, that explains how to do it right. Both undocumented registers in the data sheet and undocumented bits of documented registers are used.<\/p>\r\n<p>Interestingly, there are hardworking people who have done the documentation work for the registers in a reverse engineering process. The result, i.e. the complete register map, can be found <a href=\"http:\/\/www.i2cdevlib.com\/devices\/mpu6050#registers\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\r\n\n<h4 class=\"wp-block-heading\">The Interrupt Sketch<\/h4>\n\n<p>I took the instructions and wrote the following sketch based on it. Some steps suggested in the manual are not necessary in my opinion. I inserted but commented them.<\/p>\r\n<p>Explaining the sketch in detail would be beyond the scope. Just a few comments:<\/p>\r\n<ul>\r\n<li><code>setInterrupt(x)<\/code> activates the interrupt; x sets sensitivity to a value between 1 (4 mg = &#8220;4 milli-g&#8221;, not milligrams) and 255 (1024 mg)\r\n<ul>\r\n<li>at 255 you have to shake the MPU6050 vigorously to trigger the interrupt<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>if you want to set the interrupt pin active-low, then uncomment line 41<\/li>\r\n<li>using the latch function you can set the interrupt pin to remain active until the next read. To do this, change line 41 to: <code>writeRegister(MPU6050_INT_PIN_CFG, 1&lt;&lt;MPU6050_LATCH_INT_EN)<\/code><\/li>\r\n<li>Combination of active-low and latch: <code>writeRegister(MPU6050_INT_PIN_CFG, ((1&lt;&lt;MPU6050_ACTL) | (1&lt;&lt;MPU6050_LATCH_IN_EN))<\/code><\/li>\r\n<\/ul>\r\n<p>Here&#8217;s the sketch:<\/p>\r\n\n<div class=\"scroll-paragraph-long\">\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"MPU6050_interrupt.ino\" data-enlighter-title=\"MPU6050_interrupt.ino\">#include \"Wire.h\" \r\n\r\n#define MPU6050_ADDR              0x68 \/\/ Alternatively set AD0 to HIGH  --&gt; Address = 0x69\r\n#define MPU6050_ACCEL_CONFIG      0x1C \/\/ Accelerometer Configuration Register\r\n#define MPU6050_PWR_MGT_1         0x6B \/\/ Power Management 1 Register\r\n#define MPU6050_INT_PIN_CFG       0x37 \/\/ Interrupt Pin \/ Bypass Enable Configuration Register\r\n#define MPU6050_INT_ENABLE        0x38 \/\/ Interrupt Enable Register\r\n#define MPU6050_LATCH_INT_EN      0x05 \/\/ Latch Enable Bit for Interrupt \r\n#define MPU6050_ACTL              0x07 \/\/ Active-Low Enable Bit\r\n#define MPU6050_WOM_EN            0x06 \/\/ Wake on Motion Enable bit\r\n#define MPU6050_WOM_THR           0x1F \/\/ Wake on Motion Threshold Register\r\n#define MPU6050_MOT_DUR           0x20 \/\/ Motion Detection Duration Register\r\n#define MPU6050_ACCEL_INTEL_CTRL  0x69 \/\/ Accelaration Interrupt Control Register\r\n#define MPU6050_SIGNAL_PATH_RESET 0x68 \/\/ Signal Path Reset Register\r\n\r\nbyte interruptPin=2;\r\nbyte ledPin=10;\r\nvolatile bool accEvent = false;\r\n\r\nvoid setup() {\r\n  Wire.begin();\r\n  writeRegister(MPU6050_PWR_MGT_1, 0);\r\n  setInterrupt(1); \/\/ set Wake on Motion Interrupt \/ Sensitivity; 1(highest sensitivity) - 255\r\n  pinMode(ledPin, OUTPUT);\r\n  pinMode(interruptPin, INPUT);\r\n  attachInterrupt(digitalPinToInterrupt(interruptPin), motion, RISING);\r\n}\r\n\r\nvoid loop() {\r\n   if(accEvent){\r\n    digitalWrite(ledPin, HIGH);\r\n    delay(1000);\r\n    digitalWrite(ledPin, LOW);\r\n    accEvent = false;\r\n    attachInterrupt(digitalPinToInterrupt(interruptPin), motion, RISING);   \r\n  }\r\n}\r\n\r\nvoid setInterrupt(byte threshold){\r\n\/\/writeRegister(MPU6050_SIGNAL_PATH_RESET, 0b00000111);  \/\/ not(?) needed\r\n\/\/writeRegister(MPU6050_INT_PIN_CFG, 1&lt;&lt;MPU6050_ACTL); \/\/ 1&lt;&lt;MPU6050_LATCH_INT_EN\r\n  writeRegister(MPU6050_ACCEL_CONFIG, 0b00000001);\r\n  writeRegister(MPU6050_WOM_THR, threshold); \r\n  writeRegister(MPU6050_MOT_DUR, 0b00000001);  \/\/ set duration (LSB = 1 ms)\r\n\/\/writeRegister(MPU6050_ACCEL_INTEL_CTRL, 0x15);  \/\/ not needed (?)\r\n  writeRegister(MPU6050_INT_ENABLE, 1&lt;&lt;MPU6050_WOM_EN);\r\n}\r\n\r\nvoid writeRegister(uint16_t reg, byte value){\r\n  Wire.beginTransmission(MPU6050_ADDR);\r\n  Wire.write(reg);\r\n  Wire.write(value);\r\n  Wire.endTransmission();\r\n}\r\n\r\nvoid motion(){\r\n  accEvent = true;\r\n  detachInterrupt(digitalPinToInterrupt(interruptPin));\r\n}<\/pre>\r\n<p>\u00a0<\/p>\r\n<\/div>\r\n\n<h2 class=\"wp-block-heading\" id=\"anker6\">Libraries for the MPU6050<\/h2>\n\n<p>No library I have found really takes full advantage of the features of the MPU6050. The interrupts are just an example. I would like to create a more complete library. However, the effort is considerable and most of you are likely to get along with the basic features. Maybe I will come back to that.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Adafruit MPU6050<\/h3>\n\n<p>The most complete library I have found is that of Adafruit. You can download it directly from GitHub <a href=\"https:\/\/github.com\/adafruit\/Adafruit_MPU6050\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a> or install it via the library manager in the Arduino IDE.<\/p>\r\n\n<h4 class=\"wp-block-heading\">Basic reading sketch<\/h4>\n\n<p>The best way to start is with the included sample basic_readings.ino. It reads the acceleration, temperature and gyroscope values. You can set the measuring ranges and a low-pass filter (<code>setFilterBandwith()<\/code>) for the sensors. I will come to the filter below. Here&#8217;s the unchanged sketch:<\/p>\r\n\n<div class=\"scroll-paragraph-long\">\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"basic_readings.ino\" data-enlighter-title=\"basic_readings.ino\">\/\/ Basic demo for accelerometer readings from Adafruit MPU6050\r\n\r\n#include &lt;Adafruit_MPU6050.h&gt;\r\n#include &lt;Adafruit_Sensor.h&gt;\r\n#include &lt;Wire.h&gt;\r\n\r\nAdafruit_MPU6050 mpu;\r\n\r\nvoid setup(void) {\r\n  Serial.begin(115200);\r\n  while (!Serial)\r\n    delay(10); \/\/ will pause Zero, Leonardo, etc until serial console opens\r\n\r\n  Serial.println(\"Adafruit MPU6050 test!\");\r\n\r\n  \/\/ Try to initialize!\r\n  if (!mpu.begin()) {\r\n    Serial.println(\"Failed to find MPU6050 chip\");\r\n    while (1) {\r\n      delay(10);\r\n    }\r\n  }\r\n  Serial.println(\"MPU6050 Found!\");\r\n\r\n  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);\r\n  Serial.print(\"Accelerometer range set to: \");\r\n  switch (mpu.getAccelerometerRange()) {\r\n  case MPU6050_RANGE_2_G:\r\n    Serial.println(\"+-2G\");\r\n    break;\r\n  case MPU6050_RANGE_4_G:\r\n    Serial.println(\"+-4G\");\r\n    break;\r\n  case MPU6050_RANGE_8_G:\r\n    Serial.println(\"+-8G\");\r\n    break;\r\n  case MPU6050_RANGE_16_G:\r\n    Serial.println(\"+-16G\");\r\n    break;\r\n  }\r\n  mpu.setGyroRange(MPU6050_RANGE_500_DEG);\r\n  Serial.print(\"Gyro range set to: \");\r\n  switch (mpu.getGyroRange()) {\r\n  case MPU6050_RANGE_250_DEG:\r\n    Serial.println(\"+- 250 deg\/s\");\r\n    break;\r\n  case MPU6050_RANGE_500_DEG:\r\n    Serial.println(\"+- 500 deg\/s\");\r\n    break;\r\n  case MPU6050_RANGE_1000_DEG:\r\n    Serial.println(\"+- 1000 deg\/s\");\r\n    break;\r\n  case MPU6050_RANGE_2000_DEG:\r\n    Serial.println(\"+- 2000 deg\/s\");\r\n    break;\r\n  }\r\n\r\n  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);\r\n  Serial.print(\"Filter bandwidth set to: \");\r\n  switch (mpu.getFilterBandwidth()) {\r\n  case MPU6050_BAND_260_HZ:\r\n    Serial.println(\"260 Hz\");\r\n    break;\r\n  case MPU6050_BAND_184_HZ:\r\n    Serial.println(\"184 Hz\");\r\n    break;\r\n  case MPU6050_BAND_94_HZ:\r\n    Serial.println(\"94 Hz\");\r\n    break;\r\n  case MPU6050_BAND_44_HZ:\r\n    Serial.println(\"44 Hz\");\r\n    break;\r\n  case MPU6050_BAND_21_HZ:\r\n    Serial.println(\"21 Hz\");\r\n    break;\r\n  case MPU6050_BAND_10_HZ:\r\n    Serial.println(\"10 Hz\");\r\n    break;\r\n  case MPU6050_BAND_5_HZ:\r\n    Serial.println(\"5 Hz\");\r\n    break;\r\n  }\r\n\r\n  Serial.println(\"\");\r\n  delay(100);\r\n}\r\n\r\nvoid loop() {\r\n\r\n  \/* Get new sensor events with the readings *\/\r\n  sensors_event_t a, g, temp;\r\n  mpu.getEvent(&amp;a, &amp;g, &amp;temp);\r\n\r\n  \/* Print out the values *\/\r\n  Serial.print(\"Acceleration X: \");\r\n  Serial.print(a.acceleration.x);\r\n  Serial.print(\", Y: \");\r\n  Serial.print(a.acceleration.y);\r\n  Serial.print(\", Z: \");\r\n  Serial.print(a.acceleration.z);\r\n  Serial.println(\" m\/s^2\");\r\n\r\n  Serial.print(\"Rotation X: \");\r\n  Serial.print(g.gyro.x);\r\n  Serial.print(\", Y: \");\r\n  Serial.print(g.gyro.y);\r\n  Serial.print(\", Z: \");\r\n  Serial.print(g.gyro.z);\r\n  Serial.println(\" rad\/s\");\r\n\r\n  Serial.print(\"Temperature: \");\r\n  Serial.print(temp.temperature);\r\n  Serial.println(\" degC\");\r\n\r\n  Serial.println(\"\");\r\n  delay(500);\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n<\/div>\r\n\n<p>Note that the results are output in m\/s<sup>2<\/sup> or rad\/s. Here I positioned the module in three different ways: 1) z-axis in the direction of the vertical, 2) x-axis in the direction of the vertical and finally 3) y-axis in the direction of the vertical.<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_MPU6050_adafruit_basics.png\"><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"535\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_MPU6050_adafruit_basics.png\" alt=\"Output of basic_readings.ino \" class=\"wp-image-9533\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_MPU6050_adafruit_basics.png 808w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_MPU6050_adafruit_basics-300x199.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_MPU6050_adafruit_basics-768x509.png 768w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/a><figcaption class=\"wp-element-caption\">Output of basic_readings.ino <\/figcaption><\/figure>\n\n<p>If you want to convert angular velocities to degrees\/s:<\/p>\r\n\n<p><p class=\"ql-center-displayed-equation\" style=\"line-height: 39px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-8942e52bf22b09ae79ed86698255f2c7_l3.png\" height=\"39\" width=\"267\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#91; &#50;&#92;&#112;&#105;&#92;&#99;&#100;&#111;&#116;&#32;&#114;&#97;&#100;&#32;&#61;&#32;&#51;&#54;&#48;&deg;&#32;&#92;&#59;&#92;&#59;&#32;&#92;&#82;&#105;&#103;&#104;&#116;&#97;&#114;&#114;&#111;&#119;&#92;&#59;&#92;&#59;&#49;&deg;&#61;&#92;&#102;&#114;&#97;&#99;&#123;&#50;&#92;&#112;&#105;&#92;&#99;&#100;&#111;&#116;&#32;&#114;&#97;&#100;&#125;&#123;&#51;&#54;&#48;&#125; &#92;&#93;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p><\/p>\r\n\n<p>For the conversion of the acceleration values to g, divide the values by 9.81.<\/p>\r\n\n<h4 class=\"wp-block-heading\">Plotter Sketch<\/h4>\n\n<p>Especially with angular velocities, you may not only want to determine individual values, but also track the progression. The sketch plotter.ino is suitable for this purpose, which I also print here unchanged:<\/p>\r\n\n<div class=\"scroll-paragraph-long\">\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"plotter.ino\" data-enlighter-title=\"plotter.ino\">\/\/ Basic demo for accelerometer readings from Adafruit MPU6050\r\n\r\n#include &lt;Adafruit_MPU6050.h&gt;\r\n#include &lt;Adafruit_Sensor.h&gt;\r\n#include &lt;Wire.h&gt;\r\n\r\nAdafruit_MPU6050 mpu;\r\n\r\nvoid setup(void) {\r\n  Serial.begin(115200);\r\n  while (!Serial) {\r\n    delay(10); \/\/ will pause Zero, Leonardo, etc until serial console opens\r\n  }\r\n\r\n  \/\/ Try to initialize!\r\n  if (!mpu.begin()) {\r\n    Serial.println(\"Failed to find MPU6050 chip\");\r\n    while (1) {\r\n      delay(10);\r\n    }\r\n  }\r\n\r\n  mpu.setAccelerometerRange(MPU6050_RANGE_16_G);\r\n  mpu.setGyroRange(MPU6050_RANGE_250_DEG);\r\n  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);\r\n  Serial.println(\"\");\r\n  delay(100);\r\n}\r\n\r\nvoid loop() {\r\n\r\n  \/* Get new sensor events with the readings *\/\r\n  sensors_event_t a, g, temp;\r\n  mpu.getEvent(&amp;a, &amp;g, &amp;temp);\r\n\r\n  \/* Print out the values *\/\r\n  Serial.print(a.acceleration.x);\r\n  Serial.print(\",\");\r\n  Serial.print(a.acceleration.y);\r\n  Serial.print(\",\");\r\n  Serial.print(a.acceleration.z);\r\n  Serial.print(\", \");\r\n  Serial.print(g.gyro.x);\r\n  Serial.print(\",\");\r\n  Serial.print(g.gyro.y);\r\n  Serial.print(\",\");\r\n  Serial.print(g.gyro.z);\r\n  Serial.println(\"\");\r\n\r\n  delay(10);\r\n}<\/pre>\r\n<p>&nbsp;<\/p>\r\n<\/div>\r\n\n<p>Upload the sketch and then select the serial plotter instead of the serial monitor. Here I turned the MPU6050 several times by 90\u00b0. The gyroscope peaks are the small pink and orange peaks between the bigger accelerometer peaks:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_MPU6050_adafruit_plotter.png\"><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"535\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_MPU6050_adafruit_plotter.png\" alt=\"Plotter output\" class=\"wp-image-9535\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_MPU6050_adafruit_plotter.png 808w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_MPU6050_adafruit_plotter-300x199.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Output_MPU6050_adafruit_plotter-768x509.png 768w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/a><figcaption class=\"wp-element-caption\">Plotter output<\/figcaption><\/figure>\n\n<h2 class=\"wp-block-heading\">Cycle and Filter Bandwith<\/h2>\n\n<p>I would like to mention two parameters whose effect is illustrated by the following sketch. This sketch is from me, so it&#8217;s not part of the library&#8217;s sample sketch.<\/p>\r\n<p>The function <code>setCycleRate(frequency)<\/code> causes the MPU6050 to go to sleep and wake up at the specified frequency to record a set of readings. This saves considerable power. Strictly speaking, the function only sets the frequency. It is activated with <code>enableCycle(true)<\/code>. &nbsp; If you pass &#8220;false&#8221;, it becomes inactive.<\/p>\r\n<p>The function <code>setFilterBandwith(bandwith)<\/code> dampens the fluctuation of the measured value. If you upload the sketch with the parameters I have selected (see line 58\/84) and tilt your MPU6050, you will see that the readings are very sluggish. If you use the cycle function, you should set the bandwidth high. For example, change the value to 260 Hz and see what happens.<\/p>\r\n\n<div class=\"scroll-paragraph-long\">\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"cycle_and_filter_bandwith.ino\" data-enlighter-title=\"cycle_and_filter_bandwith.ino\">\/\/ Basic demo for cycle and filter bandwith from Adafruit MPU6050\r\n\r\n#include &lt;Adafruit_MPU6050.h&gt;\r\n#include &lt;Adafruit_Sensor.h&gt;\r\n#include &lt;Wire.h&gt;\r\n\r\nAdafruit_MPU6050 mpu;\r\n\r\nvoid setup(void) {\r\n  Serial.begin(115200);\r\n  while (!Serial)\r\n    delay(10); \/\/ will pause Zero, Leonardo, etc until serial console opens\r\n\r\n  Serial.println(\"Adafruit MPU6050 test!\");\r\n\r\n  \/\/ Try to initialize!\r\n  if (!mpu.begin()) {\r\n    Serial.println(\"Failed to find MPU6050 chip\");\r\n    while (1) {\r\n      delay(10);\r\n    }\r\n  }\r\n  Serial.println(\"MPU6050 Found!\");\r\n\r\n  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);\r\n  Serial.print(\"Accelerometer range set to: \");\r\n  switch (mpu.getAccelerometerRange()) {\r\n  case MPU6050_RANGE_2_G:\r\n    Serial.println(\"+-2G\");\r\n    break;\r\n  case MPU6050_RANGE_4_G:\r\n    Serial.println(\"+-4G\");\r\n    break;\r\n  case MPU6050_RANGE_8_G:\r\n    Serial.println(\"+-8G\");\r\n    break;\r\n  case MPU6050_RANGE_16_G:\r\n    Serial.println(\"+-16G\");\r\n    break;\r\n  }\r\n  mpu.setGyroRange(MPU6050_RANGE_500_DEG);\r\n  Serial.print(\"Gyro range set to: \");\r\n  switch (mpu.getGyroRange()) {\r\n  case MPU6050_RANGE_250_DEG:\r\n    Serial.println(\"+- 250 deg\/s\");\r\n    break;\r\n  case MPU6050_RANGE_500_DEG:\r\n    Serial.println(\"+- 500 deg\/s\");\r\n    break;\r\n  case MPU6050_RANGE_1000_DEG:\r\n    Serial.println(\"+- 1000 deg\/s\");\r\n    break;\r\n  case MPU6050_RANGE_2000_DEG:\r\n    Serial.println(\"+- 2000 deg\/s\");\r\n    break;\r\n  }\r\n\r\n  mpu.setFilterBandwidth(MPU6050_BAND_10_HZ);\r\n  Serial.print(\"Filter bandwidth set to: \");\r\n  switch (mpu.getFilterBandwidth()) {\r\n  case MPU6050_BAND_260_HZ:\r\n    Serial.println(\"260 Hz\");\r\n    break;\r\n  case MPU6050_BAND_184_HZ:\r\n    Serial.println(\"184 Hz\");\r\n    break;\r\n  case MPU6050_BAND_94_HZ:\r\n    Serial.println(\"94 Hz\");\r\n    break;\r\n  case MPU6050_BAND_44_HZ:\r\n    Serial.println(\"44 Hz\");\r\n    break;\r\n  case MPU6050_BAND_21_HZ:\r\n    Serial.println(\"21 Hz\");\r\n    break;\r\n  case MPU6050_BAND_10_HZ:\r\n    Serial.println(\"10 Hz\");\r\n    break;\r\n  case MPU6050_BAND_5_HZ:\r\n    Serial.println(\"5 Hz\");\r\n    break;\r\n  }\r\n\r\n  mpu.setCycleRate(MPU6050_CYCLE_5_HZ);\r\n  Serial.print(\"Cycle rate set to: \");\r\n  switch (mpu.getCycleRate()) {\r\n  case MPU6050_CYCLE_1_25_HZ:\r\n    Serial.println(\"1.25 Hz\");\r\n    break;\r\n  case MPU6050_CYCLE_5_HZ:\r\n    Serial.println(\"5 Hz\");\r\n    break;\r\n  case MPU6050_CYCLE_20_HZ:\r\n    Serial.println(\"20 Hz\");\r\n    break;\r\n  case MPU6050_CYCLE_40_HZ:\r\n    Serial.println(\"40 Hz\");\r\n    break;\r\n  }\r\n  \r\n  mpu.enableCycle(true);\r\n \r\n  Serial.println(\"\");\r\n  delay(100);\r\n}\r\n\r\nvoid loop() {\r\n\r\n  \/* Get new sensor events with the readings *\/\r\n  sensors_event_t a, g, temp;\r\n  mpu.getEvent(&amp;a, &amp;g, &amp;temp);\r\n\r\n  \/* Print out the values *\/\r\n  Serial.print(\"Acceleration X: \");\r\n  Serial.print(a.acceleration.x);\r\n  Serial.print(\", Y: \");\r\n  Serial.print(a.acceleration.y);\r\n  Serial.print(\", Z: \");\r\n  Serial.print(a.acceleration.z);\r\n  Serial.println(\" m\/s^2\");\r\n\r\n  Serial.print(\"Rotation X: \");\r\n  Serial.print(g.gyro.x);\r\n  Serial.print(\", Y: \");\r\n  Serial.print(g.gyro.y);\r\n  Serial.print(\", Z: \");\r\n  Serial.print(g.gyro.z);\r\n  Serial.println(\" rad\/s\");\r\n\r\n  Serial.print(\"Temperature: \");\r\n  Serial.print(temp.temperature);\r\n  Serial.println(\" degC\");\r\n\r\n  Serial.println(\"\");\r\n  delay(500);\r\n}<\/pre>\r\n<\/div>\r\n\n<p>More information can be found in <a href=\"https:\/\/learn.adafruit.com\/mpu6050-6-dof-accelerometer-and-gyro?view=all\" target=\"_blank\" rel=\"noopener noreferrer\">this  Adafruit tutorial<\/a> about the MPU6050. There are also a number of other example sketches.\u00a0<a id=\"anker7\"><\/a><\/p>\r\n\n<h3 class=\"wp-block-heading\">MPU6050 light<\/h3>\n\n<p>Very interesting is also the library MPU6050_light, which you can find <a href=\"https:\/\/github.com\/rfetick\/MPU6050_light\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a> on GitHub or install via the Arduino IDE. It is kept simple (just \u201clight\u201d, as the name suggests). But it offers the possibility to output tilts, which it calculates from the (earth) acceleration data. A prerequisite for reliable data is that the movements are slow, so that the acceleration due to gravity is the decisive variable. Here is an exemplary output of the sample sketch getAngle.ino. I flipped the xy plane back and forth. This works quite well, but I wouldn\u2019t dispose of my spirit level.<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/mpu6050_light_get_angle.png\"><img loading=\"lazy\" decoding=\"async\" width=\"879\" height=\"465\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/mpu6050_light_get_angle.png\" alt=\"Output of GetAngle.ino of the MPU6050 light library\" class=\"wp-image-9557\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/mpu6050_light_get_angle.png 879w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/mpu6050_light_get_angle-300x159.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/mpu6050_light_get_angle-768x406.png 768w\" sizes=\"auto, (max-width: 879px) 100vw, 879px\" \/><\/a><figcaption class=\"wp-element-caption\">Output of GetAngle.ino of the MPU6050 light library<\/figcaption><\/figure>\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The MPU6050 is a 6-axis gyroscope and accelerometer. I show you how to control it with and without a library and use its interrupt function.<\/p>\n","protected":false},"author":1,"featured_media":9492,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[919,572],"tags":[1337,1333,1338,691,1323,1326,1328],"class_list":["post-10827","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-acceleration","category-sensors","tag-accelerometer-en-2","tag-adafruit-mpu6050-en-2","tag-gyroscope","tag-interrupt-en-2","tag-mpu6050-en","tag-mpu6050-without-library","tag-mpu6050_light-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MPU6050 Accelerometer and Gyroscope &#8226; Wolles Elektronikkiste<\/title>\n<meta name=\"description\" content=\"The MPU6050 is a 6-axis gyroscope and accelerometer: how you control it with and without library and use interrupts.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MPU6050 Accelerometer and Gyroscope &#8226; Wolles Elektronikkiste\" \/>\n<meta property=\"og:description\" content=\"The MPU6050 is a 6-axis gyroscope and accelerometer: how you control it with and without library and use interrupts.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope\" \/>\n<meta property=\"og:site_name\" content=\"Wolles Elektronikkiste\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-16T14:14:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-29T13:25:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Beitragsbild.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"1100\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Wolfgang Ewald\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Wolfgang Ewald\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"20 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope\"},\"author\":{\"name\":\"Wolfgang Ewald\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"headline\":\"MPU6050 Accelerometer and Gyroscope\",\"datePublished\":\"2021-01-16T14:14:27+00:00\",\"dateModified\":\"2024-10-29T13:25:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope\"},\"wordCount\":1943,\"commentCount\":22,\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/Beitragsbild.jpg\",\"keywords\":[\"accelerometer\",\"Adafruit MPU6050\",\"gyroscope\",\"Interrupt\",\"MPU6050\",\"MPU6050 without library\",\"MPU6050_light\"],\"articleSection\":[\"Acceleration\",\"Sensors\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope\",\"name\":\"MPU6050 Accelerometer and Gyroscope &#8226; Wolles Elektronikkiste\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/Beitragsbild.jpg\",\"datePublished\":\"2021-01-16T14:14:27+00:00\",\"dateModified\":\"2024-10-29T13:25:50+00:00\",\"description\":\"The MPU6050 is a 6-axis gyroscope and accelerometer: how you control it with and without library and use interrupts.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope#primaryimage\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/Beitragsbild.jpg\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/Beitragsbild.jpg\",\"width\":1100,\"height\":1100},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/mpu6050-accelerometer-and-gyroscope#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MPU6050 Accelerometer and Gyroscope\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\",\"name\":\"Wolles Elektronikkiste\",\"description\":\"Die wunderbare Welt der Elektronik\",\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\",\"name\":\"Wolfgang Ewald\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"width\":512,\"height\":512,\"caption\":\"Wolfgang Ewald\"},\"logo\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MPU6050 Accelerometer and Gyroscope &#8226; Wolles Elektronikkiste","description":"The MPU6050 is a 6-axis gyroscope and accelerometer: how you control it with and without library and use interrupts.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope","og_locale":"en_US","og_type":"article","og_title":"MPU6050 Accelerometer and Gyroscope &#8226; Wolles Elektronikkiste","og_description":"The MPU6050 is a 6-axis gyroscope and accelerometer: how you control it with and without library and use interrupts.","og_url":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope","og_site_name":"Wolles Elektronikkiste","article_published_time":"2021-01-16T14:14:27+00:00","article_modified_time":"2024-10-29T13:25:50+00:00","og_image":[{"width":1100,"height":1100,"url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Beitragsbild.jpg","type":"image\/jpeg"}],"author":"Wolfgang Ewald","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Wolfgang Ewald","Est. reading time":"20 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope#article","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope"},"author":{"name":"Wolfgang Ewald","@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"headline":"MPU6050 Accelerometer and Gyroscope","datePublished":"2021-01-16T14:14:27+00:00","dateModified":"2024-10-29T13:25:50+00:00","mainEntityOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope"},"wordCount":1943,"commentCount":22,"publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Beitragsbild.jpg","keywords":["accelerometer","Adafruit MPU6050","gyroscope","Interrupt","MPU6050","MPU6050 without library","MPU6050_light"],"articleSection":["Acceleration","Sensors"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope","url":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope","name":"MPU6050 Accelerometer and Gyroscope &#8226; Wolles Elektronikkiste","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#website"},"primaryImageOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope#primaryimage"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Beitragsbild.jpg","datePublished":"2021-01-16T14:14:27+00:00","dateModified":"2024-10-29T13:25:50+00:00","description":"The MPU6050 is a 6-axis gyroscope and accelerometer: how you control it with and without library and use interrupts.","breadcrumb":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope#primaryimage","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Beitragsbild.jpg","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/11\/Beitragsbild.jpg","width":1100,"height":1100},{"@type":"BreadcrumbList","@id":"https:\/\/wolles-elektronikkiste.de\/en\/mpu6050-accelerometer-and-gyroscope#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/wolles-elektronikkiste.de\/en"},{"@type":"ListItem","position":2,"name":"MPU6050 Accelerometer and Gyroscope"}]},{"@type":"WebSite","@id":"https:\/\/wolles-elektronikkiste.de\/en#website","url":"https:\/\/wolles-elektronikkiste.de\/en","name":"Wolles Elektronikkiste","description":"Die wunderbare Welt der Elektronik","publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wolles-elektronikkiste.de\/en?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46","name":"Wolfgang Ewald","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","width":512,"height":512,"caption":"Wolfgang Ewald"},"logo":{"@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png"}}]}},"_links":{"self":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/10827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/comments?post=10827"}],"version-history":[{"count":0,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/10827\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media\/9492"}],"wp:attachment":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media?parent=10827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/categories?post=10827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/tags?post=10827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}