hts221
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Description
The hts221
object reads relative humidity and ambient temperature
using the HTS221 sensor connected to the I2C bus of the Arduino® hardware. HTS221 is used to read relative humidity. The HTS221 also has an
embedded temperature sensor. Attach the HTS221 sensor to the I2C pins on the hardware. You can
read the data from the sensor in MATLAB® using the Object Functions.
Creation
Description
creates a sensor object with default property values.humiditySensor
= hts221(a
)
Example:
humiditySensor = hts221(a);
.
creates a sensor object with properties using one or more humiditySensor
= hts221(a
,Name,Value
)Name,Value
pair arguments.
Example:
humiditySensor = hts221(a, 'Bus', 1);
.
Input Arguments
Properties
Object Functions
readHumidity | Read one sample of relative humidity data from the sensor |
readTemperature | Read one sample of temperature from sensor |
read | Read real-time sensor data at a specified rate |
release | Release the sensor object |
flush | Flush the host buffer |
info | Read information related to sensor |
Examples
Create Connection to HTS221 Sensor
Create an arduino
object with the I2C library.
a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create the sensor object.
humiditySensor = hts221(a)
humiditySensor = hts221 with properties: I2CAddress: 95 ("0x5F") Bus: 0 SCLPin: "A5" SDAPin: "A4" SampleRate: 100 (Samples/s) SamplesPerRead: 10 ReadMode: 'latest' SamplesRead: 0 SamplesAvailable: 0 Show all properties all functions
Create HTS221 Sensor Connection with Additional Name-Value Pair Arguments
Create a sensor object with additional properties specified as name-value pair arguments.
clear humiditySensor; humiditySensor = hts221(a,'SampleRate',50,'SamplesPerRead',5,'ReadMode','oldest')
humiditySensor = hts221 with properties: I2CAddress: 95 ("0x5F") Bus: 0 SCLPin: "A5" SDAPin: "A4" SampleRate: 50 (Samples/s) SamplesPerRead: 5 ReadMode: 'oldest' SamplesRead: 0 SamplesAvailable: 0 Show all properties, functions
More About
Version History
Introduced in R2021a