pyupm_si114x module

class pyupm_si114x.SI114X(bus, address=96)[source]

Bases: object

API for the SI1145 UV Light Sensor.

ID: si114x

Name: UV/IR/visible Light Sensor

Other Names: SI1146, SI1147

Category: light

Manufacturer: adafruit

Link:https://www.adafruit.com/products/1777

Connection: i2c This module was tested with the Adafruit* UV Light Sensor

This device is capable of measuring IR and visible ambient light as well. It also supports the ability to use externally attached LEDs to perform proximity detection on 3 separate channels.

Currently, this class only supports the retrieving of the calculated UV index measured by the device, but enough infrastructure is provided to make it easy to enhance this driver in the future to support additional capabilities, including interrupt support.

C++ includes: si114x.hpp

CHLIST_EN_ALS_IR = 32
CHLIST_EN_ALS_VIS = 16
CHLIST_EN_AUX = 64
CHLIST_EN_PS1 = 1
CHLIST_EN_PS2 = 2
CHLIST_EN_PS3 = 4
CHLIST_EN_UV = 128
CMD_ALS_AUTO = 14
CMD_ALS_FORCE = 6
CMD_ALS_PAUSE = 10
CMD_BUSADDR = 2
CMD_GET_CAL = 18
CMD_NOOP = 0
CMD_PARAM_QUERY = 128
CMD_PARAM_SET = 160
CMD_PSALS_AUTO = 15
CMD_PSALS_FORCE = 7
CMD_PSALS_PAUSE = 11
CMD_PS_AUTO = 13
CMD_PS_FORCE = 5
CMD_PS_PAUSE = 9
CMD_RESET = 1
ERR_ALS_IR_ADC_OVER = 141
ERR_ALS_VIS_ADC_OVER = 140
ERR_AUX_ADC_OVER = 142
ERR_INVALID_SET = 128
ERR_NONE = 0
ERR_PS1_ADC_OVER = 136
ERR_PS2_ADC_OVER = 137
ERR_PS3_ADC_OVER = 138
IRQEN_ALS_IE = 1
IRQEN_PS1_IE = 4
IRQEN_PS2_IE = 8
IRQEN_PS3_IE = 16
PARAM_ALS_ENCODING = 6
PARAM_ALS_IR_ADCMUX = 14
PARAM_ALS_IR_ADC_COUNT = 29
PARAM_ALS_IR_ADC_MISC = 31
PARAM_ALS_IR_ADX_GAIN = 30
PARAM_ALS_VIS_ADC_COUNT = 16
PARAM_ALS_VIS_ADC_GAIN = 17
PARAM_ALS_VIS_ADC_MISC = 18
PARAM_AUX_ADCMUX = 15
PARAM_CHLIST = 1
PARAM_I2C_ADDDR = 0
PARAM_LED_REC = 28
PARAM_PS1_ADCMUX = 7
PARAM_PS2_ADCMUX = 8
PARAM_PS3_ADCMUX = 9
PARAM_PSLED12_SEL = 2
PARAM_PSLED3_SEL = 3
PARAM_PS_ADC_COUNT = 10
PARAM_PS_ADC_GAIN = 11
PARAM_PS_ADC_MISC = 12
PARAM_PS_ENCODING = 5
REG_ALS_IR_DATA0 = 36
REG_ALS_IR_DATA1 = 37
REG_ALS_VIS_DATA0 = 34
REG_ALS_VIS_DATA1 = 35
REG_ANA_IN_KEY0 = 59
REG_ANA_IN_KEY1 = 60
REG_ANA_IN_KEY2 = 61
REG_ANA_IN_KEY3 = 62
REG_AUX_UVINDEX0 = 44
REG_AUX_UVINDEX1 = 45
REG_CHIP_STAT = 48
REG_COMMAND = 24
REG_HW_KEY = 7
REG_INT_CFG = 3
REG_IRQ_ENABLE = 4
REG_IRQ_MODE1 = 5
REG_IRQ_MODE2 = 6
REG_IRQ_STATUS = 33
REG_MEAS_RATE0 = 8
REG_MEAS_RATE1 = 9
REG_PARAM_READ = 46
REG_PARAM_WR = 23
REG_PART_ID = 0
REG_PS1_DATA0 = 38
REG_PS1_DATA1 = 39
REG_PS2_DATA0 = 40
REG_PS2_DATA1 = 41
REG_PS3_DATA0 = 42
REG_PS3_DATA1 = 43
REG_PS_LED21 = 15
REG_PS_LED3 = 16
REG_RESPONSE = 32
REG_REV_ID = 1
REG_SEQ_ID = 2
REG_UCOEF0 = 19
REG_UCOEF1 = 20
REG_UCOEF2 = 21
REG_UCOEF3 = 22
getUVIndex()[source]

float getUVIndex()

Reads the currently measured UV index value

UV index value

initialize()[source]

void initialize()

Resets and initializes the device and starts auto-sampling

readByte(reg)[source]

uint8_t readByte(uint8_t reg)

Reads a byte value from a register

reg: Register location to read from

Value in a specified register

readParam(param)[source]

uint8_t readParam(SI114X_PARAM_T param)

Reads a value from the parameter memory

param: SI114X_PARAM_T register to read

Value

readWord(reg)[source]

uint16_t readWord(uint8_t reg)

Reads a word value from a register

reg: Register location to read from

Value in a specified register

reset()[source]

void reset()

Disables interrupts and auto-measuring, issues a device reset, and then sets the hardware key.

setUVCalibration(uvcoeff0, uvcoeff1, uvcoeff2, uvcoeff3)[source]

void setUVCalibration(uint8_t uvcoeff0, uint8_t uvcoeff1, uint8_t uvcoeff2, uint8_t uvcoeff3)

Sets UV calibration values. The constructor sets default values for you, so you only need this function if you need different values for your device and situation. If you set new values here, be sure to do so before calling initialize().

uvcoeff0: Coefficient for REG_UCOEF0

uvcoeff1: Coefficient for REG_UCOEF1

uvcoeff2: Coefficient for REG_UCOEF2

uvcoeff3: Coefficient for REG_UCOEF3

update()[source]

void update()

Updates stored values. You should call this before calling getUVIndex()

writeByte(reg, byte)[source]

bool writeByte(uint8_t reg, uint8_t byte)

Writes a byte value into a register

reg: Register location to write into

byte: Byte to write

True if successful

writeParam(param, value)[source]

void writeParam(SI114X_PARAM_T param, uint8_t value)

Writes a value to the parameter memory.

param: SI114X_PARAM_T register to write

value: Value to write