Library to talk with MPU6050 IMUs
Fork of MPU6050 by
MPU6050 Class Reference
#include <MPU6050.h>
Public Member Functions | |
MPU6050 (PinName sda, PinName scl) | |
Constructor. | |
char | testConnection (void) |
Tests the I2C connection by reading the WHO_AM_I register. | |
void | setBW (char BW) |
Sets the bandwidth of the digital low-pass filter. | |
void | setI2CBypass (bool state) |
Sets the auxiliary I2C bus in bypass mode to read the sensors behind the MPU6050 (useful for eval board, otherwise just connect them to primary I2C bus) | |
void | setAcceleroRange (char range) |
Sets the Accelero full-scale range. | |
int | getAcceleroRawX (void) |
Reads the accelero x-axis. | |
int | getAcceleroRawY (void) |
Reads the accelero y-axis. | |
int | getAcceleroRawZ (void) |
Reads the accelero z-axis. | |
void | getAcceleroRaw (int *data) |
Reads all accelero data. | |
void | getAccelero (float *data) |
Reads all accelero data, gives the acceleration in m/s2. | |
void | setGyroRange (char range) |
Sets the Gyro full-scale range. | |
int | getGyroRawX (void) |
Reads the gyro x-axis. | |
int | getGyroRawY (void) |
Reads the gyro y-axis. | |
int | getGyroRawZ (void) |
Reads the gyro z-axis. | |
void | getGyroRaw (int *data) |
Reads all gyro data. | |
void | getGyro (float *data) |
Reads all gyro data, gives the gyro in rad/s. | |
int | getTempRaw (void) |
Reads temperature data. | |
float | getTemp (void) |
Returns current temperature. | |
void | setSleepMode (bool state) |
Sets the sleep mode of the MPU6050. | |
void | write (char address, char data) |
Writes data to the device, could be private, but public is handy so you can transmit directly to the MPU. | |
char | read (char adress) |
Read data from the device, could be private, but public is handy so you can transmit directly to the MPU. | |
void | read (char adress, char *data, int length) |
Read multtiple regigsters from the device, more efficient than using multiple normal reads. |
Detailed Description
MPU6050 IMU library.
Example:
Later, maybe
Definition at line 188 of file MPU6050.h.
Constructor & Destructor Documentation
MPU6050 | ( | PinName | sda, |
PinName | scl | ||
) |
Constructor.
Includes.
Sleep mode of MPU6050 is immediatly disabled
- Parameters:
-
sda - mbed pin to use for the SDA I2C line. scl - mbed pin to use for the SCL I2C line.
Definition at line 6 of file MPU6050.cpp.
Member Function Documentation
void getAccelero | ( | float * | data ) |
Reads all accelero data, gives the acceleration in m/s2.
Function uses the last setup value of the full scale range, if you manually set in another range, this won't work.
- Parameters:
-
data - pointer to float array with length three: data[0] = X, data[1] = Y, data[2] = Z
Definition at line 121 of file MPU6050.cpp.
void getAcceleroRaw | ( | int * | data ) |
Reads all accelero data.
- Parameters:
-
data - pointer to signed integer array with length three: data[0] = X, data[1] = Y, data[2] = Z
Definition at line 113 of file MPU6050.cpp.
int getAcceleroRawX | ( | void | ) |
Reads the accelero x-axis.
- Returns:
- 16-bit signed integer x-axis accelero data
Definition at line 89 of file MPU6050.cpp.
int getAcceleroRawY | ( | void | ) |
Reads the accelero y-axis.
- Returns:
- 16-bit signed integer y-axis accelero data
Definition at line 97 of file MPU6050.cpp.
int getAcceleroRawZ | ( | void | ) |
Reads the accelero z-axis.
- Returns:
- 16-bit signed integer z-axis accelero data
Definition at line 105 of file MPU6050.cpp.
void getGyro | ( | float * | data ) |
Reads all gyro data, gives the gyro in rad/s.
Function uses the last setup value of the full scale range, if you manually set in another range, this won't work.
- Parameters:
-
data - pointer to float array with length three: data[0] = X, data[1] = Y, data[2] = Z
Definition at line 197 of file MPU6050.cpp.
void getGyroRaw | ( | int * | data ) |
Reads all gyro data.
- Parameters:
-
data - pointer to signed integer array with length three: data[0] = X, data[1] = Y, data[2] = Z
Definition at line 189 of file MPU6050.cpp.
int getGyroRawX | ( | void | ) |
Reads the gyro x-axis.
- Returns:
- 16-bit signed integer x-axis gyro data
Definition at line 165 of file MPU6050.cpp.
int getGyroRawY | ( | void | ) |
Reads the gyro y-axis.
- Returns:
- 16-bit signed integer y-axis gyro data
Definition at line 173 of file MPU6050.cpp.
int getGyroRawZ | ( | void | ) |
Reads the gyro z-axis.
- Returns:
- 16-bit signed integer z-axis gyro data
Definition at line 181 of file MPU6050.cpp.
float getTemp | ( | void | ) |
Returns current temperature.
- Returns:
- float with the current temperature
Definition at line 232 of file MPU6050.cpp.
int getTempRaw | ( | void | ) |
Reads temperature data.
- Returns:
- 16 bit signed integer with the raw temperature register value
Definition at line 224 of file MPU6050.cpp.
char read | ( | char | adress ) |
Read data from the device, could be private, but public is handy so you can transmit directly to the MPU.
- Parameters:
-
adress - register address to write to
- Returns:
- - data from the register specified by RA
Definition at line 26 of file MPU6050.cpp.
void read | ( | char | adress, |
char * | data, | ||
int | length | ||
) |
Read multtiple regigsters from the device, more efficient than using multiple normal reads.
- Parameters:
-
adress - register address to write to length - number of bytes to read data - pointer where the data needs to be written to
Definition at line 33 of file MPU6050.cpp.
void setAcceleroRange | ( | char | range ) |
Sets the Accelero full-scale range.
Macros: MPU6050_ACCELERO_RANGE_2G - MPU6050_ACCELERO_RANGE_4G - MPU6050_ACCELERO_RANGE_8G - MPU6050_ACCELERO_RANGE_16G
- Parameters:
-
range - The two bits that set the full-scale range (use the predefined macros)
Definition at line 78 of file MPU6050.cpp.
void setBW | ( | char | BW ) |
Sets the bandwidth of the digital low-pass filter.
Macros: MPU6050_BW_256 - MPU6050_BW_188 - MPU6050_BW_98 - MPU6050_BW_42 - MPU6050_BW_20 - MPU6050_BW_10 - MPU6050_BW_5 Last number is the gyro's BW in Hz (accelero BW is virtually identical)
- Parameters:
-
BW - The three bits that set the bandwidth (use the predefined macros)
Definition at line 55 of file MPU6050.cpp.
void setGyroRange | ( | char | range ) |
Sets the Gyro full-scale range.
Macros: MPU6050_GYRO_RANGE_250 - MPU6050_GYRO_RANGE_500 - MPU6050_GYRO_RANGE_1000 - MPU6050_GYRO_RANGE_2000
- Parameters:
-
range - The two bits that set the full-scale range (use the predefined macros)
Definition at line 155 of file MPU6050.cpp.
void setI2CBypass | ( | bool | state ) |
Sets the auxiliary I2C bus in bypass mode to read the sensors behind the MPU6050 (useful for eval board, otherwise just connect them to primary I2C bus)
- Parameters:
-
state - Enables/disables the I2C bypass mode
Definition at line 64 of file MPU6050.cpp.
void setSleepMode | ( | bool | state ) |
Sets the sleep mode of the MPU6050.
- Parameters:
-
state - true for sleeping, false for wake up
Definition at line 38 of file MPU6050.cpp.
char testConnection | ( | void | ) |
Tests the I2C connection by reading the WHO_AM_I register.
- Returns:
- True for a working connection, false for an error
Definition at line 48 of file MPU6050.cpp.
void write | ( | char | address, |
char | data | ||
) |
Writes data to the device, could be private, but public is handy so you can transmit directly to the MPU.
- Parameters:
-
adress - register address to write to data - data to write
Definition at line 18 of file MPU6050.cpp.
Generated on Thu Jul 14 2022 19:01:42 by 1.7.2