Adafruit HTS221 Library
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Adafruit_HTS221 Class Referencefinal

Class that stores state and functions for interacting with the HTS221 I2C Digital Potentiometer. More...

#include <Adafruit_HTS221.h>

Public Member Functions

 Adafruit_HTS221 ()
 Instantiates a new HTS221 class.
 
bool begin_I2C (uint8_t i2c_addr=HTS221_I2CADDR_DEFAULT, TwoWire *wire=&Wire, int32_t sensor_id=0)
 Sets up the hardware and initializes I2C. More...
 
bool begin_SPI (uint8_t cs_pin, SPIClass *theSPI=&SPI, int32_t sensor_id=0)
 Sets up the hardware and initializes hardware SPI. More...
 
bool begin_SPI (int8_t cs_pin, int8_t sck_pin, int8_t miso_pin, int8_t mosi_pin, int32_t sensor_id=0)
 Sets up the hardware and initializes software SPI. More...
 
void boot (void)
 Restores the trimming function values into registers from flash.
 
void setActive (bool active)
 Sets the sensor to active or inactive. More...
 
hts221_rate_t getDataRate (void)
 Returns the current measurement rate. More...
 
void setDataRate (hts221_rate_t data_rate)
 Sets the rate at which measurements are taken. More...
 
void drdyActiveLow (bool active_low)
 Sets the polarity of the DRDY pin when active. More...
 
void drdyIntEnabled (bool drdy_int_enabled)
 Enables or disables the Data Ready (DRDY) interrupt on the DRDY pin. More...
 
bool getEvent (sensors_event_t *humidity, sensors_event_t *temp)
 Gets the humidity sensor and temperature values as sensor events. More...
 
Adafruit_Sensor * getTemperatureSensor (void)
 Gets the Adafruit_Sensor object for the HTS221's humidity sensor. More...
 
Adafruit_Sensor * getHumiditySensor (void)
 Gets the Adafruit_Sensor object for the HTS221's humidity sensor. More...
 

Protected Member Functions

bool _read (void)
 Updates the measurement data for all sensors simultaneously. More...
 
virtual bool _init (int32_t sensor_id)
 Initializer for post i2c/spi init. More...
 

Protected Attributes

float corrected_temp
 Last reading's temperature (C) before scaling.
 
float corrected_humidity
 Last reading's humidity (percent) before scaling.
 
uint16_t _sensorid_humidity
 ID number for humidity.
 
uint16_t _sensorid_temp
 ID number for temperature.
 
Adafruit_I2CDevice * i2c_dev = NULL
 Pointer to I2C bus interface.
 
Adafruit_SPIDevice * spi_dev = NULL
 Pointer to I2C bus interface.
 
Adafruit_HTS221_Temptemp_sensor = NULL
 Temp sensor data object.
 
Adafruit_HTS221_Humidityhumidity_sensor
 Humidity sensor data object. More...
 

Friends

class Adafruit_HTS221_Temp
 
class Adafruit_HTS221_Humidity
 

Detailed Description

Class that stores state and functions for interacting with the HTS221 I2C Digital Potentiometer.

Member Function Documentation

◆ begin_I2C()

bool Adafruit_HTS221::begin_I2C ( uint8_t  i2c_address = HTS221_I2CADDR_DEFAULT,
TwoWire *  wire = &Wire,
int32_t  sensor_id = 0 
)

Sets up the hardware and initializes I2C.

Parameters
i2c_addressThe I2C address to be used.
wireThe Wire object to be used for I2C connections.
sensor_idThe unique ID to differentiate the sensors from others
Returns
True if initialization was successful, otherwise false.

◆ begin_SPI() [1/2]

bool Adafruit_HTS221::begin_SPI ( uint8_t  cs_pin,
SPIClass *  theSPI = &SPI,
int32_t  sensor_id = 0 
)

Sets up the hardware and initializes hardware SPI.

Parameters
cs_pinThe arduino pin # connected to chip select
theSPIThe SPI object to be used for SPI connections.
sensor_idThe user-defined ID to differentiate different sensors
Returns
True if initialization was successful, otherwise false.

◆ begin_SPI() [2/2]

bool Adafruit_HTS221::begin_SPI ( int8_t  cs_pin,
int8_t  sck_pin,
int8_t  miso_pin,
int8_t  mosi_pin,
int32_t  sensor_id = 0 
)

Sets up the hardware and initializes software SPI.

Parameters
cs_pinThe arduino pin # connected to chip select
sck_pinThe arduino pin # connected to SPI clock
miso_pinThe arduino pin # connected to SPI MISO
mosi_pinThe arduino pin # connected to SPI MOSI
sensor_idThe user-defined ID to differentiate different sensors
Returns
True if initialization was successful, otherwise false.

◆ setActive()

void Adafruit_HTS221::setActive ( bool  active)

Sets the sensor to active or inactive.

Parameters
activeSet to true to enable the sensor, false to disable

◆ getDataRate()

hts221_rate_t Adafruit_HTS221::getDataRate ( void  )

Returns the current measurement rate.

Returns
hts221_rate_t the current measurement rate

◆ setDataRate()

void Adafruit_HTS221::setDataRate ( hts221_rate_t  data_rate)

Sets the rate at which measurements are taken.

Parameters
data_rateThe new measurement rate. Must be a hts221_rate_t

◆ drdyActiveLow()

void Adafruit_HTS221::drdyActiveLow ( bool  active_low)

Sets the polarity of the DRDY pin when active.

Parameters
active_lowSet to true to make the DRDY pin active low, false for active low

◆ drdyIntEnabled()

void Adafruit_HTS221::drdyIntEnabled ( bool  drdy_int_enabled)

Enables or disables the Data Ready (DRDY) interrupt on the DRDY pin.

Parameters
drdy_int_enabledSet to true to enable the DRDY interrupt, false to disable

◆ getEvent()

bool Adafruit_HTS221::getEvent ( sensors_event_t *  humidity,
sensors_event_t *  temp 
)

Gets the humidity sensor and temperature values as sensor events.

Parameters
humiditySensor event object that will be populated with humidity data
tempSensor event object that will be populated with temp data
Returns
true if the event data was read successfully

◆ getTemperatureSensor()

Adafruit_Sensor * Adafruit_HTS221::getTemperatureSensor ( void  )

Gets the Adafruit_Sensor object for the HTS221's humidity sensor.

Returns
Adafruit_Sensor*

◆ getHumiditySensor()

Adafruit_Sensor * Adafruit_HTS221::getHumiditySensor ( void  )

Gets the Adafruit_Sensor object for the HTS221's humidity sensor.

Returns
Adafruit_Sensor*

◆ _read()

bool Adafruit_HTS221::_read ( void  )
protected

Updates the measurement data for all sensors simultaneously.

Returns
true if the event data was read successfully

◆ _init()

bool Adafruit_HTS221::_init ( int32_t  sensor_id)
protectedvirtual

Initializer for post i2c/spi init.

Parameters
sensor_idOptional unique ID for the sensor set
Returns
True if chip identified and initialized

Friends And Related Function Documentation

◆ Adafruit_HTS221_Temp

friend class Adafruit_HTS221_Temp
friend

Gives access to private members to Temp data object

◆ Adafruit_HTS221_Humidity

friend class Adafruit_HTS221_Humidity
friend

Gives access to private members to Humidity data object

Member Data Documentation

◆ humidity_sensor

Adafruit_HTS221_Humidity* Adafruit_HTS221::humidity_sensor
protected
Initial value:
=
NULL

Humidity sensor data object.


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