lps22hb
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Description
The lps22hb
object reads barometric air pressure and ambient
temperature using the LPS22HB sensor connected to the I2C bus of the Arduino® hardware. LPS22HB is used to read barometric air pressure. The LPS22HB also has
an embedded temperature sensor. Attach the LPS22HB 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.pressureSensor
= lps22hb(a
)
Example:
pressureSensor = lps22hb(a);
.
creates a sensor object with properties using one or more pressureSensor
= lps22hb(a
,Name,Value
)Name,Value
pair arguments.
Example:
pressureSensor = lps22hb(a,'I2CAddress',0x5D);
.
Input Arguments
Properties
Object Functions
readPressure | Read one sample of barometric air pressure data from the 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 LPS22HB Sensor
Create an arduino
object with the I2C library.
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create the sensor object.
pressureSensor = lps22hb(a)
pressureSensor = lps22hb with properties: I2CAddress: 92 ("0x5C") Bus: 0 SCLPin: "A5" SDAPin: "A4" SampleRate: 100 (Samples/s) SamplesPerRead: 10 ReadMode: 'latest' SamplesRead: 0 SamplesAvailable: 0 Show all properties, functions
Create LPS22HB Sensor Connection with Additional Name-Value Pair Arguments
Create a sensor object with additional properties specified as name-value pair arguments.
clear pressureSensor; pressureSensor = lps22hb(a,'SampleRate',50,'SamplesPerRead',5,'ReadMode','oldest')
pressureSensor = lps22hb with properties: I2CAddress: 92 ("0x5C") 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 R2021a