getSampleRate method

int getSampleRate()

Returns the Sample Rate of the MPU6050 in Hz.

The Sample Rate is generated by dividing the gyroscope output rate by SMPLRT_DIV: Sample Rate = Gyroscope Output Rate / (1 + SMPLRT_DIV) where Gyroscope Output Rate = 8kHz when the DLPF is disabled (DLPF_CFG = 0 or 7), and 1kHz when the DLPF is enabled.

Note: The accelerometer output rate is 1kHz (accelerometer and not gyroscope !). This means that for a Sample Rate greater than 1kHz, the same accelerometer sample may be output to the FIFO, DMP, and sensor registers more than once.

Implementation

int getSampleRate() {
  var gyroscopeOutputRate =
      (_dlpfCfg == DLPF.filter0 || _dlpfCfg == DLPF.filter7)
          ? 8000
          : 1000; // 8kHz if DLPG disabled, and 1kHz if enabled.
  return gyroscopeOutputRate ~/ (1 + _smplrtDiv);
}