readTemperature
Description
[
returns one sample of the temperature measured in degree Celsius along with the
tempReadings
,timestamp
] = readtemperature(sensorobj
)timestamp
. Timestamp
is optional.
Note
The readTemperature
function is available for the
LSM6DS3
, LSM6DS3H
,
LSM6DSL
, LSM6DSM
,
LSM6DSR
, LSM6DSO
,
LPS22HB
, LSM303C
,
HTS221
, ICM20948
,
ADXL345
, BMP280
, and
LIS3DH
sensors.
Examples
Read temperature 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.
Note
The sample code and output in this example is for hts221
object. If you are using another sensor that supports
readTemperature
function, use the corresponding
sensor object.
sensorobj = hts221(a);
Return one sample of temperature data.
temperatureReadings = readTemperature(sensorobj)
temperatureReadings = 28.12
Input Arguments
Output Arguments
More About
Version History
Introduced in R2021a