lsm6dsr
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Description
The lsm6dsr
object reads acceleration, angular velocity, and
temperature using the LSM6DSR sensor connected to the I2C bus of the hardware. The LSM6DSR is
an inertial measurement unit (IMU) used to read acceleration and angular velocity in all three
dimensions. The LSM6DSR also has an embedded temperature sensor. Attach an LSM6DSR sensor to
the I2C pins on the hardware. You can read the data from your sensor in MATLAB® using the Object Functions.
Creation
Description
creates a sensor object with default property values.imu
= lsm6dsr(a
)
Example:
imu = lsm6dsr(a);
.
creates a sensor object with properties using one or more imu
= lsm6dsr(a
,Name,Value
)Name,Value
pair arguments.
Example:
imu = lsm6dsr(a,'I2CAddress',0x6A);
.
Input Arguments
Properties
Object Functions
readAcceleration | Read one sample of acceleration from sensor |
readAngularVelocity | Read one sample of angular velocity from sensor |
readTemperature | Read one sample of temperature from sensor |
read | Read real-time sensor data at a specified rate |
release | Release the sensor object |
flush | Flush the host buffer |
info | Read information related to sensor |
Examples
Create Connection to LSM6DSR Sensor
Create an arduino
object with the I2C library.
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create the sensor object.
imu = lsm6dsr(a)
imu = lsm6dsr with properties: I2CAddress: 106 ("0x6B") SCLPin: "A5" SDAPin: "A4" SampleRate: 100 (Samples/s) SamplesPerRead: 10 ReadMode: 'latest' SamplesRead: 0 SamplesAvailable: 0 Show all properties, functions
Create LSM6DSR Sensor Connection with Additional Name-Value Pair Arguments
Create a sensor object with additional properties specified as name-value pair arguments.
clear imu; imu = lsm6dsr(a,'SampleRate',110,'SamplesPerRead',3,'ReadMode','oldest')
imu = lsm6dsr with properties: I2CAddress: 107 ("0x6B") Bus: 0 SCLPin: "A5" SDAPin: "A4" SampleRate: 110 (samples/s) SamplesPerRead: 3 ReadMode: "oldest" SamplesRead: 0 SamplesAvailable: 0 Show all properties all functions
More About
Version History
Introduced in R2021a