lis3dh
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Description
The lis3dh
object reads linear acceleration and temperature using
the LIS3DH sensor connected to the I2C bus of the Arduino® hardware. Attach the LIS3DH sensor to the I2C pins on the hardware. You can read
the data from the sensor in MATLAB® using the Object Functions.
Creation
Description
creates a sensor object with default property values.accelSensor
= lis3dh(a
)
Example:
accelSensor = lis3dh(a);
.
creates a sensor object with properties using one or more accelSensor
= lis3dh(a
,Name,Value
)Name,Value
pair arguments.
Example:
accelSensor = lis3dh(a,'I2CAddress',0x19);
.
Input Arguments
Properties
Object Functions
readAcceleration | Read one sample of acceleration from sensor |
readTemperature | Read one sample of temperature from sensor |
readVoltage | Read voltage from ADC pins on 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 LIS3DH Sensor
Create an arduino
object with the I2C library.
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create the sensor object.
accelSensor = lis3dh(a)
accelSensor = lis3dh with properties: I2CAddress: 24 ("0x18") Bus: 0 SCLPin: "A5" SDAPin: "A4" SampleRate: 100 (Samples/s) SamplesPerRead: 10 ReadMode: 'latest' SamplesRead: 0 SamplesAvailable: 0 Show all properties, functions
Create LIS3DH Sensor Connection with Additional Name-Value Pair Arguments
Create a sensor object with additional properties specified as name-value pair arguments.
clear accelSensor; accelSensor = lis3dh(a,'SampleRate',50,'SamplesPerRead',5,'ReadMode','oldest')
accelSensor = lis3dh with properties: I2CAddress: 24 ("0x18") Bus: 0 SCLPin: "A5" SDAPin: "A4" SampleRate: 100 (samples/s) SamplesPerRead: 10 ReadMode: "oldest" SamplesRead: 0 SamplesAvailable: 0 Show all properties all functions
More About
Version History
Introduced in R2022b