Adafruit MPU6050 Arduino Library
Public Member Functions | List of all members
Adafruit_MPU6050 Class Reference

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.
 
boolean begin (uint8_t i2c_addr=MPU6050_I2CADDR_DEFAULT, TwoWire *wire=&Wire, int32_t sensorID=0)
 Sets up the hardware and initializes I2C. More...
 
void reset (void)
 Resets registers to their initial value and resets the sensors' analog and digital signal paths.
 
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 read ()
 Updates the measurement data for all sensors simultaneously.
 
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...
 
void getSensor (sensor_t *accel, sensor_t *gyro, sensor_t *temp)
 Provides the sensor_t data the acceleromenter, gyroscope, and temperature sensor. More...
 
void setInterruptPinPolarity (bool active_low)
 Sets the polarity 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_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...
 
void enableSleep (bool enable)
 Controls the sleep state of the sensor. More...
 
void 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...
 

Detailed Description

Class that stores state and functions for interacting with the MPU6050 I2C Digital Potentiometer.

Member Function Documentation

◆ begin()

boolean Adafruit_MPU6050::begin ( uint8_t  i2c_address = MPU6050_I2CADDR_DEFAULT,
TwoWire *  wire = &Wire,
int32_t  sensorID = 0 
)

Sets up the hardware and initializes I2C.

Parameters
i2c_addressThe I2C address to be used.
wireThe Wire object to be used for I2C connections.
sensorIDThe user-defined ID to differentiate different sensors
Returns
True if initialization was successful, otherwise false.

◆ getAccelerometerRange()

mpu6050_accel_range_t Adafruit_MPU6050::getAccelerometerRange ( void  )

Gets the acceleration measurement range.

Returns
The acceleration measurement range

◆ setAccelerometerRange()

void Adafruit_MPU6050::setAccelerometerRange ( mpu6050_accel_range_t  new_range)

Sets the accelerometer measurement range.

Parameters
new_rangeThe new range to set. Must be a mpu6050_accel_range_t

◆ getGyroRange()

mpu6050_gyro_range_t Adafruit_MPU6050::getGyroRange ( void  )

Gets the gyroscope measurement range.

Returns
The mpu6050_gyro_range_t gyroscope measurement range

◆ setGyroRange()

void Adafruit_MPU6050::setGyroRange ( mpu6050_gyro_range_t  new_range)

Sets the gyroscope measurement range.

Parameters
new_rangeThe new range to set. Must be a mpu6050_gyro_range_t

◆ getEvent()

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.

Parameters
accelPointer to an Adafruit Unified sensor_event_t object to be filled with acceleration event data.
gyroPointer to an Adafruit Unified sensor_event_t object to be filled with gyroscope event data.
tempPointer to an Adafruit Unified sensor_event_t object to be filled with temperature event data.
Returns
True on successful read

◆ getSensor()

void Adafruit_MPU6050::getSensor ( sensor_t *  accel,
sensor_t *  gyro,
sensor_t *  temp 
)

Provides the sensor_t data the acceleromenter, gyroscope, and temperature sensor.

Parameters
accelPointer to the sensor_t object to be filled with accelerometer data.
gyroPointer to the sensor_t object to be filled with gyroscope data.
tempPointer to the sensor_t object to be filled with temperature data.

◆ setInterruptPinPolarity()

void Adafruit_MPU6050::setInterruptPinPolarity ( bool  active_low)

Sets the polarity of the INT pin when active.

Parameters
active_lowIf true the pin will be low when an interrupt is active If false the pin will be high when an interrupt is active

◆ setFsyncSampleOutput()

void Adafruit_MPU6050::setFsyncSampleOutput ( mpu6050_fsync_out_t  fsync_output)

Sets the location that the FSYNC pin sample is stored.

Parameters
fsync_outputa mpu6050_fsync_out_t to specify the LSB of which data register should be used to store the state of the FSYNC pin

◆ getFsyncSampleOutput()

mpu6050_fsync_out_t Adafruit_MPU6050::getFsyncSampleOutput ( void  )

Sets the location that the FSYNC pin sample is stored.

Returns
fsync_output

◆ setI2CBypass()

void Adafruit_MPU6050::setI2CBypass ( bool  bypass)

Connects or disconects the I2C master pins to the main I2C pins.

Parameters
bypassIf 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

◆ setClock()

void Adafruit_MPU6050::setClock ( mpu6050_clock_select_t  new_clock)

Sets clock source.

Parameters
new_clockThe clock source to set. Must be a mpu6050_clock_select_t

◆ getClock()

mpu6050_clock_select_t Adafruit_MPU6050::getClock ( void  )

Gets clock source.

Returns
The current mpu6050_clock_select_t clock source

◆ setFilterBandwidth()

void Adafruit_MPU6050::setFilterBandwidth ( mpu6050_bandwidth_t  bandwidth)

Sets the bandwidth of the Digital Low-Pass Filter.

Parameters
bandwidththe new mpu6050_bandwidth_t bandwidth

◆ getFilterBandwidth()

mpu6050_bandwidth_t Adafruit_MPU6050::getFilterBandwidth ( void  )

Gets bandwidth of the Digital Low Pass Filter.

Returns
The current mpu6050_bandwidth_t filter bandwidth

◆ setSampleRateDivisor()

void Adafruit_MPU6050::setSampleRateDivisor ( uint8_t  divisor)

Sets the divisor used to divide the base clock rate into a measurement rate.

Parameters
divisorThe new clock divisor

◆ getSampleRateDivisor()

uint8_t Adafruit_MPU6050::getSampleRateDivisor ( void  )

Gets the sample rate divisor.

Returns
The sample rate divisor

◆ enableSleep()

void Adafruit_MPU6050::enableSleep ( bool  enable)

Controls the sleep state of the sensor.

Parameters
enableIf 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.

◆ enableCycle()

void Adafruit_MPU6050::enableCycle ( bool  enable)

Controls sensor's 'Cycle' measurement mode.

Parameters
enableIf 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.

◆ setCycleRate()

void Adafruit_MPU6050::setCycleRate ( mpu6050_cycle_rate_t  rate)

Sets the frequency of measurement in 'Cycle' mode.

Parameters
rateThe mpu6050_cycle_rate_t specifying the desired measurement rate

◆ getCycleRate()

mpu6050_cycle_rate_t Adafruit_MPU6050::getCycleRate ( void  )

Gets the frequencey of measurements in 'Cycle' mode.

Returns
The current 'Cycle' measurement frequency

The documentation for this class was generated from the following files: