veml6070

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package veml6070 provides a driver for the VEML6070 digital UV light sensor by Vishay.

Datasheet: https://www.vishay.com/docs/84277/veml6070.pdf Application Notes: https://www.vishay.com/docs/84310/designingveml6070.pdf

Index

Constants

View Source
const (
	ADDR_L = 0x38 // 7bit address of the VEML6070 (write, read)
	ADDR_H = 0x39 // 7bit address of the VEML6070 (read)
)
View Source
const (
	RSET_240K = 240000
	RSET_270K = 270000
	RSET_300K = 300000
	RSET_600K = 600000
)

Some possible values for resistance value (in ohm) of VEML6070 calibration resistor

View Source
const (
	IT_HALF = 0x00
	IT_1    = 0x04
	IT_2    = 0x08
	IT_4    = 0x0C
)

Possible values for integration time of VEML6070 (internally represents the config register bit mask)

View Source
const (
	UVI_RISK_LOW = iota
	UVI_RISK_MODERATE
	UVI_RISK_HIGH
	UVI_RISK_VERY_HIGH
	UVI_RISK_EXTREME
)

Possible values for UVI (UV index) risk level estimations - the VEML6070 can only estimate UVI risk levels since it can only sense UVA rays but the vendor tried to come up with some coarse thresholds, from application notes

View Source
const (
	CONFIG_SD_DISABLE = 0x00
	CONFIG_SD_ENABLE  = 0x01
)

Possible values for shutdown

View Source
const (
	CONFIG_DEFAULTS = 0x02
	CONFIG_ENABLE   = CONFIG_SD_DISABLE | CONFIG_DEFAULTS
	CONFIG_DISABLE  = CONFIG_SD_ENABLE | CONFIG_DEFAULTS
)

Enable / disable

View Source
const NORMALIZED_REFRESHTIME = 100.0

The refresh time in milliseconds for which NORMALIZED_UVA_SENSITIVITY is applicable to a step count

View Source
const NORMALIZED_UVA_SENSITIVITY = 50.0

The UVA sensitivity in mW/(m*m)/step which is applicable to a step count normalized to the NORMALIZED_REFRESHTIME, from datasheet for RSET=240 kOhm and IT_FACTOR=1

View Source
const RSET_TO_REFRESHTIME_SCALE = 100.0 / RSET_240K

Scale factor in milliseconds / ohm to determine refresh time (aka sampling time) without IT_FACTOR for any given RSET, from datasheet. Note: 100.0 milliseconds are applicable for RSET=240 kOhm and IT_FACTOR=1

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	AddressLow  uint16
	AddressHigh uint16
	RSET        uint32
	IT          uint8
	// contains filtered or unexported fields
}

Device wraps an I2C connection to a VEML6070 device.

func New

func New(bus machine.I2C) Device

New creates a new VEML6070 connection. The I2C bus must already be configured.

This function only creates the Device object, it does not initialize the device. You must call Configure() first in order to use the device itself.

func (*Device) Configure

func (d *Device) Configure() bool

Configure sets up the device for communication

func (*Device) GetEstimatedRiskLevel

func (d *Device) GetEstimatedRiskLevel(intensity uint32) uint8

GetEstimatedRiskLevel returns estimated risk level from comparing UVA light intensity values in mW/(m*m) with thresholds calculated from application notes

func (*Device) ReadUVALightIntensity

func (d *Device) ReadUVALightIntensity() (uint32, error)

ReadUVALightIntensity returns the UVA light intensity (irradiance) in milli Watt per square meter (mW/(m*m))

Jump to

Keyboard shortcuts

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