Main Content

readTemperature

Read one ambient temperature data sample from LPS22HB sensor

Since R2021a

Description

example

[tempReading,timestamp] = readTemperature(sensor) returns one sample of the ambient temperature data from the LPS22HB sensor. The ambient temperature sample is returned as a scalar in degree Celsius. The function also returns the timestamp at which MATLAB® receives the temperature data from the LPS22HB sensor. The timestamp output is optional.

Examples

collapse all

Read the ambient temperature data from the LPS22HB sensor.

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

mypi = raspi;
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 an lps22hb sensor object on the I2C bus 'i2c-1' on address '0x5D'.

sensor = lps22hb(mypi,'Bus','i2c-1','I2CAddress','0x5D');
sensor = 

  lps22hb with properties:

                         I2CAddress: 93 ("0x5D")
                                Bus: i2c-1

Return one sample of ambient temperature data read from the LPS22HB sensor.

[tempReading,timestamp] = readTemperature(sensor);
tempReading =

  data

    23.9500

timestamp = 

  datetime

   22-Dec-2020 17:29:14.531

Since the timestamp output is optional, you can obtain only the ambient temperature data from the LPS22HB sensor.

[tempReading] = readTemperature(sensor);
tempReading =

  data

    23.9500

Input Arguments

collapse all

LPS22HB sensor object connection to the Raspberry Pi hardware board, specified as a lps22hb object.

Example: sensor = lps22hb(mypi) creates a connection to the LPS22HB sensor on the Raspberry Pi object mypi.

Output Arguments

collapse all

Read the ambient temperature data from the LPS22HB sensor.

Read the date and time at which MATLAB receives the ambient temperature sample value from the LPS22HB sensor, specified as a datetime.

Extended Capabilities

Version History

Introduced in R2021a