lsm9ds1
Connect to LSM9DS1 sensor on Arduino hardware I2C bus
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Description
The lsm9ds1
object reads acceleration, angular velocity, and magnetic
field using the STMicroelectronics® LSM9DS1 sensor. The LSM9DS1 is a 9 degree of freedom (DOF) inertial measurement
unit (IMU) used to read acceleration, angular velocity, and magnetic field in all three
dimensions.
The lsm9ds1
object represents a connection to the device on the
Arduino® hardware I2C bus. Attach an LSM9DS1 sensor to the I2C pins on the Arduino
hardware. You can read the data from your sensor in MATLAB®using the object functions.
Before you use the lsm9ds1
object, create an Arduino object using arduino and set its properties. When you create the
Arduino object, make sure that you include the I2C library. For more information, see Connect to Arduino Hardware.
Creation
Description
creates a sensor object with default property values. The object represents the connection
to the sensor on the Arduino hardware, imu
= lsm9ds1(a
)a
.
creates a sensor object with properties using one or more imu
= lsm9ds1(a
,Name,Value
)Name,Value
pair arguments.
Example:
imu =
lsm9ds1(a,'SampleRate',150,'SamplesPerRead',5,'ReadMode','latest');
Input Arguments
Properties
Usage
Create LSM9DS1 Sensor Connection
Create an Arduino object and include the I2C library.
a = arduino();
Or, you can explicitly specify it in the Libraries
Name-Value pair
while creating the Arduino object.
clear a; a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create the sensor object.
imu = lsm9ds1(a)
imu = lsm9ds1 with properties: I2CAddress: 107 ("0x6B") : 30 ("0x1E") SCLPin: "A5" SDAPin: "A4" SampleRate: 100 (Samples/s) SamplesPerRead: 10 ReadMode: 'latest' SamplesRead: 0 SamplesAvailable: 0 Show all properties, functions
Create LSM9DS1 Sensor Connection with Additional Name-Value Pair Arguments
Create a sensor object with additional properties specified as name-value pair arguments.
clear imu; imu = lsm9ds1(a,'SampleRate',50,'SamplesPerRead',5,'ReadMode','oldest')
imu = lsm9ds1 with properties: I2CAddress: 107 ("0x6B") : 30 ("0x1E") SCLPin: "A5" SDAPin: "A4" SampleRate: 50 (Samples/s) SamplesPerRead: 5 ReadMode: 'oldest' SamplesRead: 0 SamplesAvailable: 0 Show all properties, functions
Object Functions
readAcceleration | Read one sample of acceleration from sensor |
readAngularVelocity | Read one sample of angular velocity from sensor |
readMagneticField | Read one sample of magnetic field 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 |
More About
Version History
Introduced in R2019a