Adafruit MPU6050 Sensor Library
|
Class that stores state and functions for interacting with the MPU6050 I2C Digital Potentiometer. More...
#include <Adafruit_MPU6050.h>
Public Member Functions | |
Adafruit_MPU6050 () | |
Instantiates a new MPU6050 class. | |
~Adafruit_MPU6050 () | |
Cleans up the MPU6050 class. | |
bool | begin (uint8_t i2c_addr=MPU6050_I2CADDR_DEFAULT, TwoWire *wire=&Wire, int32_t sensorID=0) |
Sets up the hardware and initializes I2C. More... | |
bool | getEvent (sensors_event_t *accel, sensors_event_t *gyro, sensors_event_t *temp) |
Gets the most recent sensor event, Adafruit Unified Sensor format. More... | |
mpu6050_accel_range_t | getAccelerometerRange (void) |
Gets the acceleration measurement range. More... | |
void | setAccelerometerRange (mpu6050_accel_range_t) |
Sets the accelerometer measurement range. More... | |
mpu6050_gyro_range_t | getGyroRange (void) |
Gets the gyroscope measurement range. More... | |
void | setGyroRange (mpu6050_gyro_range_t) |
Sets the gyroscope measurement range. More... | |
void | setInterruptPinPolarity (bool active_low) |
Sets the polarity of the INT pin when active. More... | |
void | setInterruptPinLatch (bool held) |
Sets the latch behavior of the INT pin when active. More... | |
void | setFsyncSampleOutput (mpu6050_fsync_out_t fsync_output) |
Sets the location that the FSYNC pin sample is stored. More... | |
mpu6050_highpass_t | getHighPassFilter (void) |
Gets bandwidth of the Digital High Pass Filter. More... | |
void | setHighPassFilter (mpu6050_highpass_t bandwidth) |
Sets the bandwidth of the Digital High-Pass Filter. More... | |
void | setMotionInterrupt (bool active) |
Sets the motion interrupt. More... | |
void | setMotionDetectionThreshold (uint8_t thr) |
Sets the motion detection threshold. More... | |
void | setMotionDetectionDuration (uint8_t dur) |
Sets the motion detection duration. More... | |
bool | getMotionInterruptStatus (void) |
Gets motion interrupt status. More... | |
mpu6050_fsync_out_t | getFsyncSampleOutput (void) |
Sets the location that the FSYNC pin sample is stored. More... | |
void | setI2CBypass (bool bypass) |
Connects or disconects the I2C master pins to the main I2C pins. More... | |
void | setClock (mpu6050_clock_select_t) |
Sets clock source. More... | |
mpu6050_clock_select_t | getClock (void) |
Gets clock source. More... | |
void | setFilterBandwidth (mpu6050_bandwidth_t bandwidth) |
Sets the bandwidth of the Digital Low-Pass Filter. More... | |
mpu6050_bandwidth_t | getFilterBandwidth (void) |
Gets bandwidth of the Digital Low Pass Filter. More... | |
void | setSampleRateDivisor (uint8_t) |
Sets the divisor used to divide the base clock rate into a measurement rate. More... | |
uint8_t | getSampleRateDivisor (void) |
Gets the sample rate divisor. More... | |
bool | enableSleep (bool enable) |
Controls the sleep state of the sensor. More... | |
bool | enableCycle (bool enable) |
Controls sensor's 'Cycle' measurement mode. More... | |
void | setCycleRate (mpu6050_cycle_rate_t rate) |
Sets the frequency of measurement in 'Cycle' mode. More... | |
mpu6050_cycle_rate_t | getCycleRate (void) |
Gets the frequencey of measurements in 'Cycle' mode. More... | |
bool | setGyroStandby (bool xAxisStandby, bool yAxisStandby, bool zAxisStandby) |
Sets standbye mode for each of the gyroscope axes. More... | |
bool | setAccelerometerStandby (bool xAxisStandby, bool yAxisStandby, bool zAxisStandby) |
Sets standbye mode for each of the accelerometer axes. More... | |
bool | setTemperatureStandby (bool enable) |
Sets disable mode for thermometer sensor. More... | |
void | reset (void) |
Resets registers to their initial value and resets the sensors' analog and digital signal paths. | |
Adafruit_Sensor * | getTemperatureSensor (void) |
Gets an Adafruit Unified Sensor object for the temp sensor component. More... | |
Adafruit_Sensor * | getAccelerometerSensor (void) |
Gets an Adafruit Unified Sensor object for the accelerometer sensor component. More... | |
Adafruit_Sensor * | getGyroSensor (void) |
Gets an Adafruit Unified Sensor object for the gyro sensor component. More... | |
Protected Member Functions | |
void | _read (void) |
Updates the measurement data for all sensors simultaneously. | |
virtual bool | _init (int32_t sensor_id) |
Initilizes the sensor. More... | |
Protected Attributes | |
float | temperature |
Last reading's temperature (C) | |
float | accX |
Last reading's accelerometer X axis m/s^2. | |
float | accY |
Last reading's accelerometer Y axis m/s^2. | |
float | accZ |
Last reading's accelerometer Z axis m/s^2. | |
float | gyroX |
Last reading's gyro X axis in rad/s. | |
float | gyroY |
Last reading's gyro Y axis in rad/s. | |
float | gyroZ |
Last reading's gyro Z axis in rad/s. | |
Adafruit_I2CDevice * | i2c_dev = NULL |
Pointer to I2C bus interface. | |
Adafruit_MPU6050_Temp * | temp_sensor = NULL |
Temp sensor data object. | |
Adafruit_MPU6050_Accelerometer * | accel_sensor |
Accelerometer data object. More... | |
Adafruit_MPU6050_Gyro * | gyro_sensor = NULL |
Gyro data object. | |
uint16_t | _sensorid_accel |
ID number for accelerometer. | |
uint16_t | _sensorid_gyro |
ID number for gyro. | |
uint16_t | _sensorid_temp |
ID number for temperature. | |
Friends | |
class | Adafruit_MPU6050_Temp |
class | Adafruit_MPU6050_Accelerometer |
class | Adafruit_MPU6050_Gyro |
Class that stores state and functions for interacting with the MPU6050 I2C Digital Potentiometer.
bool Adafruit_MPU6050::begin | ( | uint8_t | i2c_address = MPU6050_I2CADDR_DEFAULT , |
TwoWire * | wire = &Wire , |
||
int32_t | sensor_id = 0 |
||
) |
Sets up the hardware and initializes I2C.
i2c_address | The I2C address to be used. |
wire | The Wire object to be used for I2C connections. |
sensor_id | The user-defined ID to differentiate different sensors |
bool Adafruit_MPU6050::getEvent | ( | sensors_event_t * | accel, |
sensors_event_t * | gyro, | ||
sensors_event_t * | temp | ||
) |
Gets the most recent sensor event, Adafruit Unified Sensor format.
accel | Pointer to an Adafruit Unified sensor_event_t object to be filled with acceleration event data. |
gyro | Pointer to an Adafruit Unified sensor_event_t object to be filled with gyroscope event data. |
temp | Pointer to an Adafruit Unified sensor_event_t object to be filled with temperature event data. |
mpu6050_accel_range_t Adafruit_MPU6050::getAccelerometerRange | ( | void | ) |
Gets the acceleration measurement range.
void Adafruit_MPU6050::setAccelerometerRange | ( | mpu6050_accel_range_t | new_range | ) |
Sets the accelerometer measurement range.
new_range | The new range to set. Must be a mpu6050_accel_range_t |
mpu6050_gyro_range_t Adafruit_MPU6050::getGyroRange | ( | void | ) |
Gets the gyroscope measurement range.
mpu6050_gyro_range_t
gyroscope measurement range void Adafruit_MPU6050::setGyroRange | ( | mpu6050_gyro_range_t | new_range | ) |
Sets the gyroscope measurement range.
new_range | The new range to set. Must be a mpu6050_gyro_range_t |
void Adafruit_MPU6050::setInterruptPinPolarity | ( | bool | active_low | ) |
Sets the polarity of the INT pin when active.
active_low | If true the pin will be low when an interrupt is active If false the pin will be high when an interrupt is active |
void Adafruit_MPU6050::setInterruptPinLatch | ( | bool | held | ) |
Sets the latch behavior of the INT pin when active.
held | If true the pin will remain held until cleared If false the pin will reset after a 50us pulse |
void Adafruit_MPU6050::setFsyncSampleOutput | ( | mpu6050_fsync_out_t | fsync_output | ) |
Sets the location that the FSYNC pin sample is stored.
fsync_output | a mpu6050_fsync_out_t to specify the LSB of which data register should be used to store the state of the FSYNC pin |
mpu6050_highpass_t Adafruit_MPU6050::getHighPassFilter | ( | void | ) |
Gets bandwidth of the Digital High Pass Filter.
mpu6050_highpass_t
filter bandwidth void Adafruit_MPU6050::setHighPassFilter | ( | mpu6050_highpass_t | bandwidth | ) |
Sets the bandwidth of the Digital High-Pass Filter.
bandwidth | the new mpu6050_highpass_t bandwidth |
void Adafruit_MPU6050::setMotionInterrupt | ( | bool | active | ) |
Sets the motion interrupt.
active | If true motion interrupt will activate based on thr and dur If false motion interrupt will be disabled |
void Adafruit_MPU6050::setMotionDetectionThreshold | ( | uint8_t | thr | ) |
Sets the motion detection threshold.
thr |
void Adafruit_MPU6050::setMotionDetectionDuration | ( | uint8_t | dur | ) |
Sets the motion detection duration.
dur |
bool Adafruit_MPU6050::getMotionInterruptStatus | ( | void | ) |
Gets motion interrupt status.
mpu6050_fsync_out_t Adafruit_MPU6050::getFsyncSampleOutput | ( | void | ) |
Sets the location that the FSYNC pin sample is stored.
void Adafruit_MPU6050::setI2CBypass | ( | bool | bypass | ) |
Connects or disconects the I2C master pins to the main I2C pins.
bypass | If true the I2C Master pins are connected to the main I2C pins, bypassing the I2C Master functions of the sensor If false the I2C Master pins are controlled by the I2C master functions of the sensor |
void Adafruit_MPU6050::setClock | ( | mpu6050_clock_select_t | new_clock | ) |
Sets clock source.
new_clock | The clock source to set. Must be a mpu6050_clock_select_t |
mpu6050_clock_select_t Adafruit_MPU6050::getClock | ( | void | ) |
Gets clock source.
mpu6050_clock_select_t
clock source void Adafruit_MPU6050::setFilterBandwidth | ( | mpu6050_bandwidth_t | bandwidth | ) |
Sets the bandwidth of the Digital Low-Pass Filter.
bandwidth | the new mpu6050_bandwidth_t bandwidth |
mpu6050_bandwidth_t Adafruit_MPU6050::getFilterBandwidth | ( | void | ) |
Gets bandwidth of the Digital Low Pass Filter.
mpu6050_bandwidth_t
filter bandwidth void Adafruit_MPU6050::setSampleRateDivisor | ( | uint8_t | divisor | ) |
Sets the divisor used to divide the base clock rate into a measurement rate.
divisor | The new clock divisor |
uint8_t Adafruit_MPU6050::getSampleRateDivisor | ( | void | ) |
Gets the sample rate divisor.
bool Adafruit_MPU6050::enableSleep | ( | bool | enable | ) |
Controls the sleep state of the sensor.
enable | If true the sensor is put into a low power state and measurements are halted until sleep mode is deactivated Setting false wakes up the sensor from sleep mode, resuming measurements. |
bool Adafruit_MPU6050::enableCycle | ( | bool | enable | ) |
Controls sensor's 'Cycle' measurement mode.
enable | If true the sensor will take measurements at the rate set by calling setCycleRate , sleeping between measurements. Setting the sensor into 'Cycle' mode will have no effect if the sensor has been put into a sleep state with enableSleep Setting false returns the sensor to the normal measurement mode. |
void Adafruit_MPU6050::setCycleRate | ( | mpu6050_cycle_rate_t | rate | ) |
Sets the frequency of measurement in 'Cycle' mode.
rate | The mpu6050_cycle_rate_t specifying the desired measurement rate |
mpu6050_cycle_rate_t Adafruit_MPU6050::getCycleRate | ( | void | ) |
Gets the frequencey of measurements in 'Cycle' mode.
bool Adafruit_MPU6050::setGyroStandby | ( | bool | xAxisStandby, |
bool | yAxisStandby, | ||
bool | zAxisStandby | ||
) |
Sets standbye mode for each of the gyroscope axes.
xAxisStandby | If true the gyroscope stops sensing in the X-axis. Setting false resumes X-axis sensing. |
yAxisStandby | If true the gyroscope stops sensing in the Y-axis. Setting false resumes Y-axis sensing. |
zAxisStandby | If true the gyroscope stops sensing in the Z-axis. Setting false resumes Z-axis sensing. |
bool Adafruit_MPU6050::setAccelerometerStandby | ( | bool | xAxisStandby, |
bool | yAxisStandby, | ||
bool | zAxisStandby | ||
) |
Sets standbye mode for each of the accelerometer axes.
xAxisStandby | If true the accelerometer stops sensing in the X-axis. Setting false resumes X-axis sensing. |
yAxisStandby | If true the accelerometer stops sensing in the Y-axis. Setting false resumes Y-axis sensing. |
zAxisStandby | If true the accelerometer stops sensing in the Z-axis. Setting false resumes Z-axis sensing. |
bool Adafruit_MPU6050::setTemperatureStandby | ( | bool | enable | ) |
Sets disable mode for thermometer sensor.
enable | If true the temperature sensor will stop taking measurements. Setting false returns the temperature sensor to the normal measurement mode. |
Adafruit_Sensor * Adafruit_MPU6050::getTemperatureSensor | ( | void | ) |
Gets an Adafruit Unified Sensor object for the temp sensor component.
Adafruit_Sensor * Adafruit_MPU6050::getAccelerometerSensor | ( | void | ) |
Gets an Adafruit Unified Sensor object for the accelerometer sensor component.
Adafruit_Sensor * Adafruit_MPU6050::getGyroSensor | ( | void | ) |
Gets an Adafruit Unified Sensor object for the gyro sensor component.
|
protectedvirtual |
Initilizes the sensor.
sensor_id | Optional unique ID for the sensor set |
|
friend |
Gives access to private members to Temp data object
|
friend |
Gives access to private members to Accelerometer data object
|
friend |
Gives access to private members to Gyro data object
|
protected |
Accelerometer data object.