Documentation ¶
Overview ¶
Package mcp9808 controls a Microchip MCP9808 digital I²C temperature sensor.
Features ¶
-40°C and +125°C Operating Range.
User-Selectable Measurement Resolution: +0.5°C, +0.25°C, +0.125°C, +0.0625°C.
User-Programmable Temperature Alerts.
Datasheet ¶
Index ¶
- Constants
- Variables
- type Alert
- type Dev
- func (d *Dev) Halt() error
- func (d *Dev) Precision(e *physic.Env)
- func (d *Dev) Sense(e *physic.Env) error
- func (d *Dev) SenseContinuous(interval time.Duration) (<-chan physic.Env, error)
- func (d *Dev) SenseTemp() (physic.Temperature, error)
- func (d *Dev) SenseWithAlerts(lower, upper, critical physic.Temperature) (physic.Temperature, []Alert, error)
- func (d *Dev) String() string
- type Opts
Examples ¶
Constants ¶
const ( Maximum resolution = 0 Low resolution = 1 Medium resolution = 2 High resolution = 3 )
Valid resolution values.
Variables ¶
var DefaultOpts = Opts{ Addr: 0x18, Res: Maximum, }
DefaultOpts is the recommended default options.
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct { AlertMode string AlertLevel physic.Temperature }
Alert represents an alert generated by the device.
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev is a handle to the mcp9808 sensor.
func (*Dev) Halt ¶
Halt put the mcp9808 into shutdown mode. It will not read temperatures while in shutdown mode.
func (*Dev) SenseContinuous ¶
SenseContinuous returns measurements as °C, on a continuous basis. The application must call Halt() to stop the sensing when done to stop the sensor and close the channel. It's the responsibility of the caller to retrieve the values from the channel as fast as possible, otherwise the interval may not be respected.
func (*Dev) SenseTemp ¶
func (d *Dev) SenseTemp() (physic.Temperature, error)
SenseTemp reads the current temperature.
func (*Dev) SenseWithAlerts ¶
func (d *Dev) SenseWithAlerts(lower, upper, critical physic.Temperature) (physic.Temperature, []Alert, error)
SenseWithAlerts reads the ambient temperature and returns an slice of any alerts that have been tripped. Lower must be less than upper which must be less than critical.
Directories ¶
Path | Synopsis |
---|---|
Package mcp9808smoketest implements a smoke test for the mcp9808.
|
Package mcp9808smoketest implements a smoke test for the mcp9808. |