Documentation ¶
Index ¶
- Variables
- type FirmwareVersion
- type HeaterLevel
- type SensorType
- type SerialNumberRaw
- type Si7021
- func (v *Si7021) GetHeaterLevel(i2c *i2c.I2C) (HeaterLevel, error)
- func (v *Si7021) GetHeaterStatus(i2c *i2c.I2C) (bool, error)
- func (v *Si7021) GetMeasureResolution(i2c *i2c.I2C) (UserRegFlag, error)
- func (v *Si7021) GetVoltageLow(i2c *i2c.I2C) (bool, error)
- func (v *Si7021) ReadFirmwareVersion(i2c *i2c.I2C) (FirmwareVersion, error)
- func (v *Si7021) ReadRelativeHumidity(i2c *i2c.I2C) (float32, error)
- func (v *Si7021) ReadRelativeHumidityAndTemperature(i2c *i2c.I2C) (float32, float32, error)
- func (v *Si7021) ReadSensoreType(i2c *i2c.I2C) (SensorType, error)
- func (v *Si7021) ReadSerialNumber(i2c *i2c.I2C) (int64, error)
- func (v *Si7021) ReadSerialNumberRaw(i2c *i2c.I2C) (*SerialNumberRaw, error)
- func (v *Si7021) ReadTemperature(i2c *i2c.I2C) (float32, error)
- func (v *Si7021) ReadUncompHumidity(i2c *i2c.I2C) (uint16, byte, error)
- func (v *Si7021) ReadUncompHumidityAndTemprature(i2c *i2c.I2C) (uint16, uint16, error)
- func (v *Si7021) ReadUncompTemprature(i2c *i2c.I2C) (uint16, byte, error)
- func (v *Si7021) Reset(i2c *i2c.I2C) error
- func (v *Si7021) SetHeaterLevel(i2c *i2c.I2C, level HeaterLevel) error
- func (v *Si7021) SetHeaterStatus(i2c *i2c.I2C, enableHeater bool) error
- func (v *Si7021) SetMeasureResolution(i2c *i2c.I2C, res UserRegFlag) error
- type UserRegFlag
Constants ¶
This section is empty.
Variables ¶
var ( CMD_REL_HUM_CSE = []byte{0xE5} // Measure Relative Humidity, Hold Master Mode (clock stretching enabled) CMD_REL_HUM = []byte{0xF5} // Measure Relative Humidity, No Hold Master Mode CMD_TEMPRATURE_CSE = []byte{0xE3} // Measure Temperature, Hold Master Mode (clock stretching enabled) CMD_TEMPRATURE = []byte{0xF3} // Measure Temperature, No Hold Master Mode CMD_TEMP_FROM_PREVIOUS = []byte{0xE0} // Read Temperature Value from Previous RH Measurement CMD_RESET = []byte{0xFE} // Reset CMD_WRITE_USER_REG_1 = []byte{0xE6} // Write RH/T User Register 1 CMD_READ_USER_REG_1 = []byte{0xE7} // Read RH/T User Register 1 CMD_WRITE_HEATER_REG = []byte{0x51} // Write Heater Control Register CMD_READ_HEATER_REG = []byte{0x11} // Read Heater Control Register CMD_READ_ID_1ST_PART = []byte{0xFA, 0x0F} // Read Electronic ID 1st Byte CMD_READ_ID_2ND_PART = []byte{0xFC, 0xC9} // Read Electronic ID 2nd Byte CMD_READ_FIRMWARE_REV = []byte{0x84, 0xB8} // Read Firmware Revision )
Command byte's sequences
Functions ¶
This section is empty.
Types ¶
type FirmwareVersion ¶
type FirmwareVersion byte
const ( FIRMWARE_VER_1_0 FirmwareVersion = 0xFF FIRMWARE_VER_2_0 FirmwareVersion = 0x20 )
func (FirmwareVersion) String ¶
func (v FirmwareVersion) String() string
String define stringer interface.
type HeaterLevel ¶
type HeaterLevel byte
HeaterLevel define gradation of sensor heating. Keep in mind that when heater is on, the temprature value provided by sensor is not correspond to real ambient environment temprature.
const ( HEATER_LEVEL_1 HeaterLevel = 0x0 // Typical power consumption: 3.09 mA HEATER_LEVEL_2 HeaterLevel = 0x1 // Typical power consumption: 9.18 mA HEATER_LEVEL_3 HeaterLevel = 0x2 // Typical power consumption: 15.24 mA HEATER_LEVEL_4 HeaterLevel = 0x3 HEATER_LEVEL_5 HeaterLevel = 0x4 // Typical power consumption: 27.39 mA HEATER_LEVEL_6 HeaterLevel = 0x5 HEATER_LEVEL_7 HeaterLevel = 0x6 HEATER_LEVEL_8 HeaterLevel = 0x7 HEATER_LEVEL_9 HeaterLevel = 0x8 // Typical power consumption: 51.69 mA HEATER_LEVEL_10 HeaterLevel = 0x9 HEATER_LEVEL_11 HeaterLevel = 0xA HEATER_LEVEL_12 HeaterLevel = 0xB HEATER_LEVEL_13 HeaterLevel = 0xC HEATER_LEVEL_14 HeaterLevel = 0xD HEATER_LEVEL_15 HeaterLevel = 0xE HEATER_LEVEL_16 HeaterLevel = 0xF // Typical power consumption: 94.2 mA HEATER_LEVEL_MASK HeaterLevel = 0xF )
type SensorType ¶
type SensorType byte
SensorType denote sensor type.
const ( SI_ENGINEERING_TYPE1 SensorType = 0x00 SI_ENGINEERING_TYPE2 SensorType = 0xFF SI_7013_TYPE SensorType = 0x0D SI_7020_TYPE SensorType = 0x14 SI_7021_TYPE SensorType = 0x15 )
type SerialNumberRaw ¶
type SerialNumberRaw struct { SNA3 byte CRC_SNA3 byte SNA2 byte CRC_SNA2 byte SNA1 byte CRC_SNA1 byte SNA0 byte CRC_SNA0 byte SNB3 byte SNB2 byte CRC_SNB2 byte SNB1 byte SNB0 byte CRC_SNB0 byte }
Keeps sensor serial number raw bytes including CRC info.
type Si7021 ¶
type Si7021 struct {
// contains filtered or unexported fields
}
func (*Si7021) GetHeaterLevel ¶
func (v *Si7021) GetHeaterLevel(i2c *i2c.I2C) (HeaterLevel, error)
GetHeaterLevel return sensor heating gradation.
func (*Si7021) GetHeaterStatus ¶
GetHeaterStatus return heater status: on (true) or off (false).
func (*Si7021) GetMeasureResolution ¶
func (v *Si7021) GetMeasureResolution(i2c *i2c.I2C) (UserRegFlag, error)
GetMeasureResolution read current sensor measure accuracy.
func (*Si7021) GetVoltageLow ¶
GetVoltageStatus provide power supply voltage low: low (true) or OK (false).
func (*Si7021) ReadFirmwareVersion ¶
func (v *Si7021) ReadFirmwareVersion(i2c *i2c.I2C) (FirmwareVersion, error)
ReadFirmwareVersion return sensor firmware revision.
func (*Si7021) ReadRelativeHumidity ¶
ReadRelativeHumidity return relative humidity.
func (*Si7021) ReadRelativeHumidityAndTemperature ¶
ReadRelativeHumidityAndTemperature return relative humidity and temperature.
func (*Si7021) ReadSensoreType ¶
func (v *Si7021) ReadSensoreType(i2c *i2c.I2C) (SensorType, error)
ReadSensorType return sensor model.
func (*Si7021) ReadSerialNumber ¶
ReadSerialNumberRaw read sensor serial number to the struct.
func (*Si7021) ReadSerialNumberRaw ¶
func (v *Si7021) ReadSerialNumberRaw(i2c *i2c.I2C) (*SerialNumberRaw, error)
ReadSerialNumberRaw read sensor serial number to the struct.
func (*Si7021) ReadTemperature ¶
ReadTemperature return temprature.
func (*Si7021) ReadUncompHumidity ¶
ReadUncompHumidity returns uncompensated humidity and CRC.
func (*Si7021) ReadUncompHumidityAndTemprature ¶
ReadUncompHumidityAndTemperature returns uncompensated humidity, temperature and CRC.
func (*Si7021) ReadUncompTemprature ¶
ReadUncompTemperature returns uncompensated temperature and CRC.
func (*Si7021) SetHeaterLevel ¶
func (v *Si7021) SetHeaterLevel(i2c *i2c.I2C, level HeaterLevel) error
SetHeaterLevel define internal heater heating gradation. Remeber, when heater is on temprature provided by sensor is not correspond to real ambient temprature.
func (*Si7021) SetHeaterStatus ¶
SetHeaterStatus enable of disable internal heater.
func (*Si7021) SetMeasureResolution ¶
func (v *Si7021) SetMeasureResolution(i2c *i2c.I2C, res UserRegFlag) error
SetMeasureResolution set up sensor temprature and humidity measure accuracy.
type UserRegFlag ¶
type UserRegFlag byte
UserRegFlag keep sensor states.
const ( RES_RH_12BIT_TEMP_14BIT UserRegFlag = 0x00 // RH - 12bit, Temperature - 14bit RES_RH_8BIT_TEMP_12BIT UserRegFlag = 0x01 // RH - 8bit, Temperature - 12bit RES_RH_10BIT_TEMP_13BIT UserRegFlag = 0x80 // RH - 10bit, Temperature - 13bit RES_RH_11BIT_TEMP_11BIT UserRegFlag = 0x81 // RH - 11bit, Temperature - 11bit RES_RH_TEMP_MASK UserRegFlag = 0x81 HEATER_ENABLED UserRegFlag = 0x4 // Heater activated VOLTAGE_LOW UserRegFlag = 0x40 // Voltage is lower than 1.9V )