This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

readTemperature

Read the temperature value from the Humidity sensor or the Air Pressure sensor

Syntax

temperature = readTemperature(mysh)
temperature = readTemperature(mysh,'usehumiditysensor')
temperature = readTemperature(mysh,'usepressuresensor')

Description

example

temperature = readTemperature(mysh) returns the temperature read from the Humidity sensor. This is the default syntax of the function.

example

temperature = readTemperature(mysh,'usehumiditysensor') returns the temperature read from the Humidity sensor that you specify as an extra argument.

example

temperature = readTemperature(mysh,'usepressuresensor') returns the temperature read from the Air Pressure sensor that you specify as an extra argument.

Examples

collapse all

You can read the temperature from Sense HAT by using the following command.

readTemperature(mysh) 
ans = 

  305.0798 

Read the temperate from Sense HAT.

You can read the temperature from Humidity sensor of Sense HAT.

readTemperature(mysh,'usehumiditysensor') 
ans = 

  305.0798 

Read the temperature from the Humidity sensor by specifying ‘usehumiditysensor’ as an argument to the function.

You can read the temperature from the Air Pressure sensor of Sense HAT.

readTemperature(mysh,'usepressuresensor') 
ans = 

  304.3313 

Read the temperature from the Humidity sensor by specifying ‘usepressuresensor’ as an argument to the function

Input Arguments

collapse all

Connection to a SenseHAT board, specified as a sensehat object.

Argument to specify that the temperature has to be read from Humidity sensor.

Argument to specify that the temperature has to be read from Air Pressure sensor.

Output Arguments

collapse all

The temperature value read from the Humidity sensor or the Air Pressure sensor. The output of this method is a double and the unit of measurement for temperature is Kelvin (K).

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2016b