HTS221
Arduino library for the HTS221 humidity and temperature sensor
Loading...
Searching...
No Matches
HTS221Sensor Class Reference

#include <HTS221Sensor.h>

Public Member Functions

 HTS221Sensor (TwoWire *i2c)
 Construct an HTS221 sensor driver.
 
HTS221StatusTypeDef begin (void)
 Configure the sensor in order to be used.
 
HTS221StatusTypeDef end (void)
 Disable the sensor and relative resources.
 
HTS221StatusTypeDef Enable (void)
 Enable HTS221.
 
HTS221StatusTypeDef Disable (void)
 Disable HTS221.
 
HTS221StatusTypeDef ReadID (uint8_t *ht_id)
 Read ID address of HTS221.
 
HTS221StatusTypeDef Reset (void)
 Reboot memory content of HTS221.
 
HTS221StatusTypeDef GetHumidity (float *pfData)
 Read humidity and convert the result to percent.
 
HTS221StatusTypeDef GetTemperature (float *pfData)
 Read temperature and convert the result to degrees Celsius.
 
HTS221StatusTypeDef GetODR (float *odr)
 Get the configured output data rate.
 
HTS221StatusTypeDef SetODR (float odr)
 Set the output data rate.
 
HTS221StatusTypeDef ReadReg (uint8_t reg, uint8_t *data)
 Read the data from register.
 
HTS221StatusTypeDef WriteReg (uint8_t reg, uint8_t data)
 Write the data to register.
 
uint8_t IO_Read (uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead)
 Read bytes from the sensor over I2C.
 
uint8_t IO_Write (uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite)
 Write bytes to the sensor over I2C.
 

Detailed Description

Controls an HTS221 humidity and temperature sensor over I2C.

Constructor & Destructor Documentation

◆ HTS221Sensor()

HTS221Sensor::HTS221Sensor ( TwoWire *  i2c)

Construct an HTS221 sensor driver.

Construct the sensor interface using the supplied I2C bus.

Parameters
i2cI2C interface used to communicate with the sensor.

Member Function Documentation

◆ begin()

HTS221StatusTypeDef HTS221Sensor::begin ( void  )

Configure the sensor in order to be used.

Initialize the sensor and its communication interface.

Return values
0in case of success, an error code otherwise

◆ Disable()

HTS221StatusTypeDef HTS221Sensor::Disable ( void  )

Disable HTS221.

Disable sensor measurements.

Return values
HTS221_STATUS_OKin case of success, an error code otherwise

◆ Enable()

HTS221StatusTypeDef HTS221Sensor::Enable ( void  )

Enable HTS221.

Enable sensor measurements.

Return values
HTS221_STATUS_OKin case of success, an error code otherwise

◆ end()

HTS221StatusTypeDef HTS221Sensor::end ( void  )

Disable the sensor and relative resources.

Shut down the sensor interface.

Return values
0in case of success, an error code otherwise

◆ GetHumidity()

HTS221StatusTypeDef HTS221Sensor::GetHumidity ( float *  pfData)

Read humidity and convert the result to percent.

Read relative humidity into pfData.

Parameters
pfDatapointer receiving humidity in percent
Return values
HTS221_STATUS_OKin case of success, an error code otherwise

◆ GetODR()

HTS221StatusTypeDef HTS221Sensor::GetODR ( float *  odr)

Get the configured output data rate.

Get the output data rate and store it in odr.

Parameters
odrpointer receiving the rate in hertz (0.0 for one-shot mode)
Return values
HTS221_STATUS_OKin case of success, an error code otherwise

◆ GetTemperature()

HTS221StatusTypeDef HTS221Sensor::GetTemperature ( float *  pfData)

Read temperature and convert the result to degrees Celsius.

Read temperature into pfData.

Parameters
pfDatapointer receiving temperature in degrees Celsius
Return values
HTS221_STATUS_OKin case of success, an error code otherwise

◆ IO_Read()

uint8_t HTS221Sensor::IO_Read ( uint8_t *  pBuffer,
uint8_t  RegisterAddr,
uint16_t  NumByteToRead 
)
inline

Read bytes from the sensor over I2C.

Parameters
pBufferDestination buffer for the bytes read.
RegisterAddrInternal register address to read from.
NumByteToReadNumber of bytes to read.
Returns
Zero.

◆ IO_Write()

uint8_t HTS221Sensor::IO_Write ( uint8_t *  pBuffer,
uint8_t  RegisterAddr,
uint16_t  NumByteToWrite 
)
inline

Write bytes to the sensor over I2C.

Parameters
pBufferSource buffer containing the bytes to write.
RegisterAddrInternal register address to write to.
NumByteToWriteNumber of bytes to write.
Returns
Zero.

◆ ReadID()

HTS221StatusTypeDef HTS221Sensor::ReadID ( uint8_t *  ht_id)

Read ID address of HTS221.

Read the sensor identifier into ht_id.

Parameters
ht_idthe pointer where the ID of the device is stored
Return values
HTS221_STATUS_OKin case of success, an error code otherwise

◆ ReadReg()

HTS221StatusTypeDef HTS221Sensor::ReadReg ( uint8_t  reg,
uint8_t *  data 
)

Read the data from register.

Read register reg into data.

Parameters
regregister address
dataregister data
Return values
HTS221_STATUS_OKin case of success
HTS221_STATUS_ERRORin case of failure

◆ Reset()

HTS221StatusTypeDef HTS221Sensor::Reset ( void  )

Reboot memory content of HTS221.

Reset the sensor.

Return values
HTS221_STATUS_OKin case of success, an error code otherwise

◆ SetODR()

HTS221StatusTypeDef HTS221Sensor::SetODR ( float  odr)

Set the output data rate.

Set the output data rate to odr.

Parameters
odrrequested rate in hertz; the closest supported rate not below the request is selected (1, 7, or 12.5 Hz)
Return values
HTS221_STATUS_OKin case of success, an error code otherwise

◆ WriteReg()

HTS221StatusTypeDef HTS221Sensor::WriteReg ( uint8_t  reg,
uint8_t  data 
)

Write the data to register.

Write data to register reg.

Parameters
regregister address
dataregister data
Return values
HTS221_STATUS_OKin case of success
HTS221_STATUS_ERRORin case of failure

The documentation for this class was generated from the following files: