Read one sample of relative humidity data from the sensor
Read humidity 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.
humiditySensor = hts221(a);
Return one sample of humidity data.
humidityReading = readHumidity(humiditySensor)
humidityReading = 69.6077
humidityReading — Value read from the sensor
The relative humidity reading from the sensor, specified in percentage (%)
timestamp — Timestamp
The time at which MATLAB® receives humidity data from the sensor, specified as a datetime.
Code Generation Using MATLAB Function Block
readHumidityin a MATLAB Function block with the Simulink® Support Package for Arduino® Hardware to generate code that can be deployed on Arduino Hardware.
Timestamp returned is always in seconds.