Documentation
¶
Index ¶
- Variables
- type MeasureRepeatability
- type PeriodicMeasure
- type SHT3X
- func (v *SHT3X) Break(i2c *i2c.I2C) error
- func (v *SHT3X) CheckCommandFailed(i2c *i2c.I2C) (bool, error)
- func (v *SHT3X) CheckResetDetected(i2c *i2c.I2C) (bool, error)
- func (v *SHT3X) CheckWrittenChecksumIsIncorrect(i2c *i2c.I2C) (bool, error)
- func (v *SHT3X) FetchTemperatureAndRelativeHumidity(i2c *i2c.I2C) (temp float32, hum float32, err error)
- func (v *SHT3X) FetchTemperatureAndRelativeHumidityWithContext(parent context.Context, i2c *i2c.I2C) (temp float32, hum float32, err error)
- func (v *SHT3X) FetchUncompTemperatureAndHumidity(i2c *i2c.I2C) (ut uint16, uh uint16, err error)
- func (v *SHT3X) FetchUncompTemperatureAndHumidityWithContext(parent context.Context, i2c *i2c.I2C) (ut uint16, uh uint16, err error)
- func (v *SHT3X) GetAlertPendingStatus(i2c *i2c.I2C) (bool, error)
- func (v *SHT3X) GetHeaterStatus(i2c *i2c.I2C) (bool, error)
- func (v *SHT3X) GetHumidityAlertStatus(i2c *i2c.I2C) (bool, error)
- func (v *SHT3X) GetTemperatureAlertStatus(i2c *i2c.I2C) (bool, error)
- func (v *SHT3X) ReadAlertHighClear(i2c *i2c.I2C) (float32, float32, error)
- func (v *SHT3X) ReadAlertHighSet(i2c *i2c.I2C) (float32, float32, error)
- func (v *SHT3X) ReadAlertLowClear(i2c *i2c.I2C) (float32, float32, error)
- func (v *SHT3X) ReadAlertLowSet(i2c *i2c.I2C) (float32, float32, error)
- func (v *SHT3X) ReadStatusReg(i2c *i2c.I2C) (uint16, error)
- func (v *SHT3X) ReadTemperatureAndRelativeHumidity(i2c *i2c.I2C, precision MeasureRepeatability) (float32, float32, error)
- func (v *SHT3X) ReadUncompTemperatureAndHumidity(i2c *i2c.I2C, precision MeasureRepeatability) (uint16, uint16, error)
- func (v *SHT3X) Reset(i2c *i2c.I2C) error
- func (v *SHT3X) SetHeaterStatus(i2c *i2c.I2C, enableHeater bool) error
- func (v *SHT3X) StartPeriodicTemperatureAndHumidityMeasure(i2c *i2c.I2C, period PeriodicMeasure, precision MeasureRepeatability) error
- func (v *SHT3X) WriteAlertHighClear(i2c *i2c.I2C, temp, hum float32) error
- func (v *SHT3X) WriteAlertHighSet(i2c *i2c.I2C, temp, hum float32) error
- func (v *SHT3X) WriteAlertLowClear(i2c *i2c.I2C, temp, hum float32) error
- func (v *SHT3X) WriteAlertLowSet(i2c *i2c.I2C, temp, hum float32) error
- type StatusRegFlag
Constants ¶
This section is empty.
Variables ¶
var ( // Measure values in "single shot mode". CMD_SINGLE_MEASURE_HIGH_CSE = []byte{0x2C, 0x06} // Single Measure of Temp. and Hum.; High precise; Clock stretching enabled CMD_SINGLE_MEASURE_MEDIUM_CSE = []byte{0x2C, 0x0D} // Single Measure of Temp. and Hum.; Medium precise; Clocl stretching enabled CMD_SINGLE_MEASURE_LOW_CSE = []byte{0x2C, 0x10} // Single Measure of Temp. and Hum.; Low precise; Clock stretching enabled CMD_SINGLE_MEASURE_HIGH = []byte{0x24, 0x00} // Single Measure of Temp. and Hum.; High precise CMD_SINGLE_MEASURE_MEDIUM = []byte{0x24, 0x0B} // Single Measure of Temp. and Hum.; Medium precise CMD_SINGLE_MEASURE_LOW = []byte{0x24, 0x16} // Single Measure of Temp. and Hum.; Low precise // Measure values in "periodic acquisition mode". CMD_PERIOD_MEASURE_05MPS_HIGH = []byte{0x20, 0x32} // Periodic Measure of Temp. and Hum.; 0.5 Measurements Per Second; High precise CMD_PERIOD_MEASURE_05MPS_MEDIUM = []byte{0x20, 0x24} // Periodic Measure of Temp. and Hum.; 0.5 Measurements Per Second; Medium precise CMD_PERIOD_MEASURE_05MPS_LOW = []byte{0x20, 0x2F} // Periodic Measure of Temp. and Hum.; 0.5 Measurements Per Second; Low precise CMD_PERIOD_MEASURE_1MPS_HIGH = []byte{0x21, 0x30} // Periodic Measure of Temp. and Hum.; 1 Measurements Per Second; High precise CMD_PERIOD_MEASURE_1MPS_MEDIUM = []byte{0x21, 0x26} // Periodic Measure of Temp. and Hum.; 1 Measurements Per Second; Medium precise CMD_PERIOD_MEASURE_1MPS_LOW = []byte{0x21, 0x2D} // Periodic Measure of Temp. and Hum.; 1 Measurements Per Second; Low precise CMD_PERIOD_MEASURE_2MPS_HIGH = []byte{0x22, 0x36} // Periodic Measure of Temp. and Hum.; 2 Measurements Per Second; High precise CMD_PERIOD_MEASURE_2MPS_MEDIUM = []byte{0x22, 0x20} // Periodic Measure of Temp. and Hum.; 2 Measurements Per Second; Medium precise CMD_PERIOD_MEASURE_2MPS_LOW = []byte{0x22, 0x2B} // Periodic Measure of Temp. and Hum.; 2 Measurements Per Second; Low precise CMD_PERIOD_MEASURE_4MPS_HIGH = []byte{0x23, 0x34} // Periodic Measure of Temp. and Hum.; 4 Measurements Per Second; High precise CMD_PERIOD_MEASURE_4MPS_MEDIUM = []byte{0x23, 0x22} // Periodic Measure of Temp. and Hum.; 4 Measurements Per Second; Medium precise CMD_PERIOD_MEASURE_4MPS_LOW = []byte{0x23, 0x29} // Periodic Measure of Temp. and Hum.; 4 Measurements Per Second; Low precise CMD_PERIOD_MEASURE_10MPS_HIGH = []byte{0x27, 0x37} // Periodic Measure of Temp. and Hum.; 10 Measurements Per Second; High precise CMD_PERIOD_MEASURE_10MPS_MEDIUM = []byte{0x27, 0x21} // Periodic Measure of Temp. and Hum.; 10 Measurements Per Second; Medium precise CMD_PERIOD_MEASURE_10MPS_LOW = []byte{0x27, 0x2A} // Periodic Measure of Temp. and Hum.; 10 Measurements Per Second; Low precise // Alert management commands. // Works in conjunction with "periodic acquisition mode". // Equation must be respected: HIGH SET > HIGH CLEAR > LOW CLEAR > LOW SET. CMD_ALERT_READ_HIGH_SET = []byte{0xE1, 0x1F} // Read high defined level, exceeding which alert is triggered ON CMD_ALERT_READ_HIGH_CLEAR = []byte{0xE1, 0x14} // Read high defined level, falling behind which alert is triggering OFF CMD_ALERT_READ_LOW_CLEAR = []byte{0xE1, 0x09} // Read low defined level, exceeding which alert is triggered OFF CMD_ALERT_READ_LOW_SET = []byte{0xE1, 0x02} // Read low defined level, falling behind which alert is triggering ON CMD_ALERT_WRITE_HIGH_SET = []byte{0x61, 0x1D} // Write high level, exceeding which alert is triggered ON CMD_ALERT_WRITE_HIGH_CLEAR = []byte{0x61, 0x16} // Write high level, falling behind which alert is triggering OFF CMD_ALERT_WRITE_LOW_CLEAR = []byte{0x61, 0x0B} // Write low level, exceeding which alert is triggered OFF CMD_ALERT_WRITE_LOW_SET = []byte{0x61, 0x00} // Write low level, falling behind which alert is triggering ON // Heater management commands. CMD_ENABLE_HEATER = []byte{0x30, 0x6D} // Switch heater on CMD_DISABLE_HEATER = []byte{0x30, 0x66} // Switch heater off // Status register commands. CMD_READ_STATUS_REG = []byte{0xF3, 0x2D} // Read status register CMD_CLEAR_STATUS_REG = []byte{0x30, 0x41} // Clear status register // Other commands. CMD_PERIOD_FETCH = []byte{0xE0, 0x00} // Read data after being measured by periodic acquisition mode command CMD_ART = []byte{0x2B, 0x32} // Activate "accelerated response time" CMD_BREAK = []byte{0x30, 0x93} // Interrupt "periodic acqusition mode" and return to "single shot mode" CMD_RESET = []byte{0x30, 0xA2} // Soft reset command )
Command byte's sequences
Functions ¶
This section is empty.
Types ¶
type MeasureRepeatability ¶
type MeasureRepeatability int
MeasureRepeatability used to define measure precision.
const ( RepeatabilityLow MeasureRepeatability = iota + 1 // Low precision RepeatabilityMedium // Medium precision RepeatabilityHigh // High precision )
func (MeasureRepeatability) GetMeasureTime ¶
func (v MeasureRepeatability) GetMeasureTime() time.Duration
GetMeasureTime define how long to wait for the measure process to complete according to specification.
func (MeasureRepeatability) String ¶
func (v MeasureRepeatability) String() string
String define stringer interface.
type PeriodicMeasure ¶
type PeriodicMeasure int
PeriodicMeasure identify pause between subsequent measures in "periodic data acquisition" mode.
const ( PeriodicHalfMPS PeriodicMeasure = iota + 1 // 1 measurement per each 2 seconds Periodic1MPS // 1 measurement per second Periodic2MPS // 2 measurements per second Periodic4MPS // 4 measurements per second Periodic10MPS // 10 measurements per second )
func (PeriodicMeasure) GetWaitDuration ¶
func (v PeriodicMeasure) GetWaitDuration() time.Duration
GetWaitDuration identify pause between measures depending on PeriodicMeasure value.
func (PeriodicMeasure) String ¶
func (v PeriodicMeasure) String() string
String define stringer interface.
type SHT3X ¶
type SHT3X struct {
// contains filtered or unexported fields
}
SHT3X is a sensor itself.
func (*SHT3X) Break ¶
Break interrupt "periodic data acquisition mode" and return sensor to "single shot mode".
func (*SHT3X) CheckCommandFailed ¶
CheckCommandFailed return last command status: failed (true) or not (false).
func (*SHT3X) CheckResetDetected ¶
CheckResetDetected return system reset detected : found (true) or not (false).
func (*SHT3X) CheckWrittenChecksumIsIncorrect ¶
CheckWrittedChecksumIsIncorrect return last command status: not correct (true) correct (false).
func (*SHT3X) FetchTemperatureAndRelativeHumidity ¶
func (v *SHT3X) FetchTemperatureAndRelativeHumidity(i2c *i2c.I2C) (temp float32, hum float32, err error)
FetchTemperatureAndRelativeHumidity wait for uncompensated temperature and humidity values and convert them to float values (Celsius and related humidity).
func (*SHT3X) FetchTemperatureAndRelativeHumidityWithContext ¶
func (v *SHT3X) FetchTemperatureAndRelativeHumidityWithContext(parent context.Context, i2c *i2c.I2C) (temp float32, hum float32, err error)
FetchTemperatureAndRelativeHumidityWithContext wait for uncompensated temperature and humidity values and convert them to float values (Celsius and related humidity). Use context parameter, since operation is time consuming (can take up to 2 seconds, waiting for results).
func (*SHT3X) FetchUncompTemperatureAndHumidity ¶
FetchUncompTemperatureAndHumidity return uncompensated temperature and humidity obtained from sensor.
func (*SHT3X) FetchUncompTemperatureAndHumidityWithContext ¶
func (v *SHT3X) FetchUncompTemperatureAndHumidityWithContext(parent context.Context, i2c *i2c.I2C) (ut uint16, uh uint16, err error)
FetchUncompTemperatureAndHumidityWithContext return uncompensated temperature and humidity obtained from sensor. Use context parameter, since operation is time consuming (can take up to 2 seconds, waiting for results).
func (*SHT3X) GetAlertPendingStatus ¶
GetAlertPendingStatus return alert pending status: found (true) or not (false).
func (*SHT3X) GetHeaterStatus ¶
GetHeaterStatus return heater status: enabled (true) or disabled (false).
func (*SHT3X) GetHumidityAlertStatus ¶
GetHumidityAlertStatus return humidity alert pending status: found (true) or not (false).
func (*SHT3X) GetTemperatureAlertStatus ¶
GetTemperatureAlertStatus return humidity alert pending status: found (true) or not (false).
func (*SHT3X) ReadAlertHighClear ¶
ReadAlertHighClear read sensor alert HIGH CLEAR limits for temperature and humidity.
func (*SHT3X) ReadAlertHighSet ¶
ReadAlertHighSet read sensor alert HIGH SET limits for temperature and humidity.
func (*SHT3X) ReadAlertLowClear ¶
ReadAlertLowClear read sensor alert LOW CLEAR limits for temperature and humidity.
func (*SHT3X) ReadAlertLowSet ¶
ReadAlertLowSet read sensor alert LOW SET limits for temperature and humidity.
func (*SHT3X) ReadStatusReg ¶
ReadStatusReg return status register flags. You should use constants of type StatusRegFlag to distinguish individual states received from sensor.
func (*SHT3X) ReadTemperatureAndRelativeHumidity ¶
func (v *SHT3X) ReadTemperatureAndRelativeHumidity(i2c *i2c.I2C, precision MeasureRepeatability) (float32, float32, error)
ReadTemperatureAndRelativeHumidity returns humidity and temperature obtained from sensor in "single shot mode".
func (*SHT3X) ReadUncompTemperatureAndHumidity ¶
func (v *SHT3X) ReadUncompTemperatureAndHumidity(i2c *i2c.I2C, precision MeasureRepeatability) (uint16, uint16, error)
ReadUncompTemperatureAndHumidity returns uncompensated humidity and temperature obtained from sensor in "single shot mode".
func (*SHT3X) SetHeaterStatus ¶
SetHeaterStatus enable or disable heater.
func (*SHT3X) StartPeriodicTemperatureAndHumidityMeasure ¶
func (v *SHT3X) StartPeriodicTemperatureAndHumidityMeasure(i2c *i2c.I2C, period PeriodicMeasure, precision MeasureRepeatability) error
StartPeriodicTemperatureAndHumidityMeasure send command to the sensor to start continuous measurement process of temperature and humidity with the pace defined by period parameter. Measurement process should be interrupted by Break command. Use Fetch... methods to read results.
func (*SHT3X) WriteAlertHighClear ¶
WriteAlertHighClear write alert HIGH CLEAR limits for temperature and humidity to the sensor.
func (*SHT3X) WriteAlertHighSet ¶
WriteAlertHighSet write alert HIGH SET limits for temperature and humidity to the sensor.
func (*SHT3X) WriteAlertLowClear ¶
WriteAlertLowClear write alert LOW CLEAR limits for temperature and humidity to the sensor.
type StatusRegFlag ¶
type StatusRegFlag uint16
StatusRegFlag determine sensor states. It shows various sensor pending events and returns heater status.
const ( ALERT_PENDING StatusRegFlag = 0x8000 HEATER_ENABLED StatusRegFlag = 0x2000 HUMIDITY_ALERT StatusRegFlag = 0x0800 TEMPERATURE_ALERT StatusRegFlag = 0x0400 RESET_DETECTED StatusRegFlag = 0x0010 COMMAND_FAILED StatusRegFlag = 0x0002 WRITE_DATA_CRC_FAILED StatusRegFlag = 0x0001 )
func (StatusRegFlag) String ¶
func (v StatusRegFlag) String() string
String define stringer interface.