Documentation ¶
Overview ¶
Package hts221 implements a driver for HTS221, a capacitive digital sensor for relative humidity and temperature.
Datasheet: https://www.st.com/resource/en/datasheet/hts221.pdf
Index ¶
Constants ¶
const ( // I2C address HTS221_ADDRESS = 0x5F // control/status registers HTS221_WHO_AM_I_REG = 0x0F HTS221_AV_CONF_REG = 0x10 HTS221_CTRL1_REG = 0x20 HTS221_CTRL2_REG = 0x21 HTS221_STATUS_REG = 0x27 HTS221_HUMID_OUT_REG = 0x28 HTS221_TEMP_OUT_REG = 0x2A // calibration registers HTS221_H0_rH_x2_REG = 0x30 HTS221_H1_rH_x2_REG = 0x31 HTS221_T0_degC_x8_REG = 0x32 HTS221_T1_degC_x8_REG = 0x33 HTS221_T1_T0_MSB_REG = 0x35 HTS221_H0_T0_OUT_REG = 0x36 HTS221_H1_T0_OUT_REG = 0x3A HTS221_T0_OUT_REG = 0x3C HTS221_T1_OUT_REG = 0x3E )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct { Address uint8 // contains filtered or unexported fields }
Device wraps an I2C connection to a HTS221 device.
func New ¶
New creates a new HTS221 connection. The I2C bus must already be configured.
This function only creates the Device object, it does not touch the device.
func (*Device) Configure ¶
func (d *Device) Configure()
Configure sets up the HTS221 device for communication.
func (*Device) Connected ¶
Connected returns whether HTS221 has been found. It does a "who am I" request and checks the response.
func (*Device) ReadHumidity ¶
ReadHumidity returns the relative humidity in percent * 100. Returns an error if the device is not turned on.
func (*Device) ReadTemperature ¶
ReadTemperature returns the temperature in celsius milli degrees (°C/1000). Returns an error if the device is not turned on.
func (*Device) Resolution ¶
Resolution sets the HTS221's resolution mode. The higher resolutions are more accurate but comsume more power (see datasheet). The number of averaged samples will be (h + 2) ^ 2, (t + 1) ^ 2