hts221

package
v0.0.0-...-7691dab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2022 License: BSD-3-Clause Imports: 2 Imported by: 0

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

View Source
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

func New(bus drivers.I2C) Device

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

func (d *Device) Connected() bool

Connected returns whether HTS221 has been found. It does a "who am I" request and checks the response.

func (*Device) Power

func (d *Device) Power(status bool)

Power is for turn on/off the HTS221 device

func (*Device) ReadHumidity

func (d *Device) ReadHumidity() (humidity int32, err error)

ReadHumidity returns the relative humidity in percent * 100. Returns an error if the device is not turned on.

func (*Device) ReadTemperature

func (d *Device) ReadTemperature() (temperature int32, err error)

ReadTemperature returns the temperature in celsius milli degrees (°C/1000). Returns an error if the device is not turned on.

func (*Device) Resolution

func (d *Device) Resolution(h uint8, t uint8)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL