bh1750

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package bh1750 provides a driver for the BH1750 digital Ambient Light

Datasheet: https://www.mouser.com/ds/2/348/bh1750fvi-e-186247.pdf

Index

Constants

View Source
const (
	POWER_DOWN                              = 0x00
	POWER_ON                                = 0x01
	RESET                                   = 0x07
	CONTINUOUS_HIGH_RES_MODE   SamplingMode = 0x10
	CONTINUOUS_HIGH_RES_MODE_2 SamplingMode = 0x11
	CONTINUOUS_LOW_RES_MODE    SamplingMode = 0x13
	ONE_TIME_HIGH_RES_MODE     SamplingMode = 0x20
	ONE_TIME_HIGH_RES_MODE_2   SamplingMode = 0x21
	ONE_TIME_LOW_RES_MODE      SamplingMode = 0x23

	// resolution in 10*lx
	HIGH_RES  = 10
	HIGH_RES2 = 5
	LOW_RES   = 40
)

Registers. Names, addresses and comments copied from the datasheet.

View Source
const Address = 0x23

The I2C address which this device listens to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Address uint16
	// contains filtered or unexported fields
}

Device wraps an I2C connection to a bh1750 device.

func New

func New(bus machine.I2C) Device

New creates a new bh1750 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 device for communication

func (*Device) Illuminance

func (d *Device) Illuminance() int32

Illuminance returns the adjusted value in mlx (milliLux)

func (*Device) RawSensorData

func (d *Device) RawSensorData() uint16

RawSensorData returns the raw value from the bh1750

func (*Device) SetMode

func (d *Device) SetMode(mode SamplingMode)

SetMode changes the reading mode for the sensor

type SamplingMode

type SamplingMode byte

SamplingMode is the sampling's resolution of the measurement

Jump to

Keyboard shortcuts

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