Main Content

readPressure

Read one absolute pressure data sample from sensor

Since R2021a

Add-On Required: This feature requires the MATLAB Support Package for Raspberry Pi Hardware add-on.

Description

[pressureReading,timestamp] = readPressure(sensorobj) returns one sample of the absolute pressure data from the sensor. The absolute pressure sample is returned as a scalar in Pascal. The function also returns the timestamp at which MATLAB® receives the absolute pressure data from the sensor. The timestamp output is optional.

Note

The readAngularVelocity function is available for the LPS22HB and BMP280 sensors.

Examples

collapse all

Create a connection from MATLAB to the Raspberry Pi® hardware board.

mypi = raspi('raspberrypi-hysdu8X38o','rocky','bullwinkle')
mypi = 

  Raspi with Properties:

           DeviceAddress: 'raspberrypi-hysdu8X38o'
                    Port: 18734
               BoardName: 'Raspberry Pi 3 Model B+'
           AvailableLEDs: {'led0'}
    AvailableDigitalPins: [4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
    AvailableSPIChannels: {‘CE0’,’CE1’}
       AvailableI2CBuses: {'i2c-1'}
             I2CBusSpeed: 100000
        AvailabelWebCams: mmal service 16.1 (platform:bcm2835-v4l2)

Create a sensor object on the I2C bus 'i2c-1' on address '0x76'.

sensorobj = bmp280(mypi,'Bus','i2c-1','I2CAddress','0x76');
sensorobj = 

  bmp280 with properties:

                         I2CAddress: 104 ("0x76")
                                Bus: i2c-1

Return one sample of absolute pressure data read from the sensor.

[pressureReading,timestamp] = readPressure(sensor);
pressureReading =

  data

    9.0993e+04

timestamp = 

  datetime

   22-Dec-2020 17:28:33.315

Since the timestamp output is optional, you can obtain only the absolute pressure data from the sensor.

[pressureReading] = readPressure(sensor);
pressureReading =

  data

    9.0993e+04

Input Arguments

collapse all

The sensor object.

Output Arguments

collapse all

Read the absolute pressure data from the sensor.

Read the date and time at which MATLAB receives the absolute pressure sample value from the sensor, specified as a datetime.

Extended Capabilities

Version History

Introduced in R2021a