Documentation ¶
Index ¶
- Constants
- type BH1750
- func (v *BH1750) ChangeSensivityFactor(i2c *i2c.I2C, factor byte) error
- func (v *BH1750) FetchMeasuredAmbientLight(i2c *i2c.I2C) (uint16, error)
- func (v *BH1750) GetDefaultSensivityFactor() byte
- func (v *BH1750) MeasureAmbientLight(i2c *i2c.I2C, resolution ResolutionMode) (uint16, error)
- func (v *BH1750) PowerDown(i2c *i2c.I2C) error
- func (v *BH1750) PowerOn(i2c *i2c.I2C) error
- func (v *BH1750) Reset(i2c *i2c.I2C) error
- func (v *BH1750) StartMeasureAmbientLightContinuously(i2c *i2c.I2C, resolution ResolutionMode) (wait time.Duration, err error)
- type ResolutionMode
Constants ¶
const ( // No active state. CMD_POWER_DOWN = 0x00 // Waiting for measurement command. CMD_POWER_ON = 0x01 // Reset Data register value. // Reset command is not acceptable in Power Down mode. CMD_RESET = 0x07 // Start measurement at 1lx resolution. // Measurement Time is typically 120ms. CMD_CONTINUOUSLY_H_RES_MODE = 0x10 // Start measurement at 0.5lx resolution. // Measurement Time is typically 120ms. CMD_CONTINUOUSLY_H_RES_MODE2 = 0x11 // Start measurement at 4lx resolution. // Measurement Time is typically 16ms. CMD_CONTINUOUSLY_L_RES_MODE = 0x13 // Start measurement at 1lx resolution. // Measurement Time is typically 120ms. // It is automatically set to Power Down mode after measurement CMD_ONE_TIME_H_RES_MODE = 0x20 // Start measurement at 0.5lx resolution. // Measurement Time is typically 120ms. // It is automatically set to Power Down mode after measurement. CMD_ONE_TIME_H_RES_MODE2 = 0x21 // Start measurement at 4lx resolution. // Measurement Time is typically 16ms. // It is automatically set to Power Down mode after measurement. CMD_ONE_TIME_L_RES_MODE = 0x23 // Change measurement time. 01000_MT[7,6,5] CMD_CHANGE_MEAS_TIME_HIGH = 0x40 // Change measurement time. 011_MT[4,3,2,1,0] CMD_CHANGE_MEAS_TIME_LOW = 0x60 )
Command bytes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BH1750 ¶
type BH1750 struct {
// contains filtered or unexported fields
}
BH1750 it's a sensor itself.
func (*BH1750) ChangeSensivityFactor ¶
ChangeSensivityFactor used when you close sensor with protection cover, which change (ordinary decrease) expected amount of light falling on the sensor. In this case you should calibrate you sensor and find appropriate factor to get in output correct ambient light value. Be aware, that improving sensitivity will increase measurement time.
func (*BH1750) FetchMeasuredAmbientLight ¶
FetchMeasuredAmbientLight return current average ambient light in lux. Previous command should be any continuous measurement initiation, otherwise error will be reported.
func (*BH1750) GetDefaultSensivityFactor ¶
GetDefaultSensivityFactor return factor value used when your sensor have no any protection cover. This is default setting according to specification.
func (*BH1750) MeasureAmbientLight ¶
MeasureAmbientLight measure and return ambient light once in lux.
func (*BH1750) StartMeasureAmbientLightContinuously ¶
func (v *BH1750) StartMeasureAmbientLightContinuously(i2c *i2c.I2C, resolution ResolutionMode) (wait time.Duration, err error)
StartMeasureAmbientLightContinuously start continuous measurement process. Use FetchMeasuredAmbientLight to get average ambient light amount collected and calculated over a time. Use PowerDown to stop measurements and return sensor to idle state.
type ResolutionMode ¶
type ResolutionMode int
ResolutionMode define sensor sensitivity and measure time. Be aware, that improving sensitivity lead to increasing of measurement time.
const ( // LowResolution precision 4 lx, 16 ms measurement time LowResolution ResolutionMode = iota + 1 // HighResolution precision 1 lx, 120 ms measurement time HighResolution // HighestResolution precision 0.5 lx, 120 ms measurement time HighestResolution )
func (ResolutionMode) String ¶
func (v ResolutionMode) String() string
String define stringer interface.