Read one sample of barometric air pressure data from the sensor
returns one sample of the barometric air pressure measured in Pascals
timestamp] = readPressure(
Pa) along with the
timestamp is optional.
readPressure function is available for only the
Read Pressure Data from Sensor
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 for the sensor in use.
pressureSensor = lps22hb(a);
Return one sample of pressure data.
pressureReading = readPressure(pressureSensor)
pressureReading = 9.5014e+04
pressureReading — Value read from the LPS22HB sensor
The barometric air pressure reading from the LPS22HB sensor, specified in Pascals (Pa).
timestamp — Timestamp
The time at which MATLAB® receives pressure data from the sensor, specified as a datetime.
Code Generation Using MATLAB Function Block
readPressurein a MATLAB Function block with the Simulink® Support Package for Arduino® Hardware to generate code that can be deployed on Arduino Hardware.
Timestamp returned is always in seconds.
Introduced in R2021a