Skip to content

MPU6050 — X/Y/Z axis acceleration (mpu6050_get_accel)

What it does: Returns the acceleration of the selected axis (X, Y, Z) from the MPU6050 accelerometer.

mpu6050_get_accel

Inputs

  • Field axis: axis selection (X, Y, Z).

Output

  • Number: acceleration of the selected axis (unit according to the used library).

When to use it

  • For detecting movement, vibration or orientation to gravity.
  • After mpu6050 aktualizovat data to match current data.

Tips and pitfalls

  • Accelerometer range depends on library configuration (typically from ±2g to ±16g).
  • When static, expect a gravitational acceleration component on one axis.

Usage example

example_mpu6050

Open example in ESP IDE

Generated Python example

value = mpu.getAccel()[0]