CircuitPython ISL29125 Library

isl29125

CircuitPython driver for the ISL29125 Sensor

  • Author(s): Jose D. Montoya

Implementation Notes

class isl29125.ISL29125(i2c_bus: busio.I2C, address: int = _I2C_ADDR)[source]

Driver for the ISL29125 Light Sensor connected over I2C.

Parameters:
i2c_bus : I2C

The I2C bus the ISL29125 is connected to.

address : int

The I2C device address. Defaults to 0x44

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

Here is an example of using the ISL29125 class. First you will need to import the libraries to use the sensor

import board
import circuitpython_isl29125.isl29125 as isl29125

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
isl = isl29125.ISL29125(i2c)

Now you have access to the colors attribute

red, green, blue = isl.colors
property adc_resolution : str

ADC’s resolution and the number of clock cycles per conversion is determined by this bit. Changing the resolution of the ADC, changes the number of clock cycles of the ADC which in turn changes the integration time. Integration time is the period the ADC samples the photodiode current signal for a measurement

Mode

Value

isl29125.RES_12BITS

0b0 16 bits

isl29125.RES_16BITS

0b1 12 bits

Example

i2c = board.I2C()
isl = isl29125.ISL29125(i2c)


isl.operation_mode = isl29125.RES_12BITS
property blue

blue property

clear_register_flag()[source]

Clears the flag register performing a read action

property colors

colors property

property green

Green property

property high_threshold : int

The interrupt threshold level is a 16-bit number (Low Threshold-1 and Low Threshold-2). The lower interrupt threshold registers are used to set the lower trigger point for interrupt generation. If the ALS value crosses below or is equal to the lower threshold, an interrupt is asserted on the interrupt pin (LOW) and the interrupt status bit (HIGH).

property interrupt_threshold : str

The interrupt_threshold is the status bits for light intensity detection. The property:interrupt_triggered is set to logic HIGH when the light intensity crosses the interrupt thresholds window (register address 0x04 - 0x07)

Value

Value

isl29125.NO_INTERRUPT

0b00

isl29125.GREEN_INTERRUPT

0b01

:isl29125.RED_INTERRUPT

0b10

isl29125.BLUE_INTERRUPT

0b11

Example

i2c = board.I2C()
isl = isl29125.ISL29125(i2c)


isl.interrupt_threshold = isl29125.BLUE_INTERRUPT
property interrupt_triggered : int

Is set to high when the interrupt threshold have been triggered (out of threshold window) and logic low when not yet triggered.

Value

Value

0b0

Interrupt is cleared or not triggered yet

0b1

interrupt is triggered

Example

i2c = board.I2C()
isl = isl29125.ISL29125(i2c)


print(isl.interrupt_triggered)
property ir_compensation : int
The device provides a programmable active IR compensation which allows fine-tuning
of residual infrared components from the output which allows optimizing the measurement

variation between differing IR-content light sources.

Mode

Value

isl29125.IR_ON

0b1

isl29125.IR_OFF

0b0

Example

i2c = board.I2C()
isl = isl29125.ISL29125(i2c)


isl.ir_compensation = isl29125.IR_ON
property ir_compensation_value : int

The effective IR compensation is from 106 to 169 in the CONF2 register. Consult datasheet for detailed IR filtering calibration

with the following values:

* BIT5: 32
* BIT4: 16
* BIT3: 8
* BIT2: 4
* BIT1: 2
* BIT0: 1

Example

i2c = board.I2C()
isl = isl29125.ISL29125(i2c)


isl._ir_compensation_value = 48
property low_threshold : int

The interrupt threshold level is a 16-bit number (Low Threshold-1 and Low Threshold-2). The lower interrupt threshold registers are used to set the lower trigger point for interrupt generation. If the ALS value crosses below or is equal to the lower threshold, an interrupt is asserted on the interrupt pin (LOW) and the interrupt status bit (HIGH).

property operation_mode : str

The device has various RGB operating modes. The device powers up on a disable mode. All operating modes are in continuous ADC conversion. The following bits are used to enable the operating mode

Mode

Value

isl29125.POWERDOWN

0b000

isl29125.GREEN_ONLY

0b001

isl29125.RED_ONLY

0b010

isl29125.BLUE_ONLY

0b011

isl29125.STANDBY

0b100

isl29125.RED_GREEN_BLUE

0b101

isl29125.GREEN_RED

0b110

isl29125.GREEN_BLUE

0b111

Example

i2c = board.I2C()
isl = isl29125.ISL29125(i2c)


isl.operation_mode = isl29125.BLUE_ONLY
property persistent_control : int

To minimize interrupt events due to ‘transient’ conditions, an interrupt persistence option is available. IN the event of transient condition an ‘X-consecutive’ number of interrupt must happen before the interrupt flag and pint (INT) pin gets driven low. The interrupt is active-low and remains asserted until clear_register_flag is called

Mode

Value

isl29125.IC1

0b000

isl29125.IC2

0b001

isl29125.IC4

0b010

isl29125.IC8

0b011

Example

i2c = board.I2C()
isl = isl29125.ISL29125(i2c)


isl.persistent_control = isl29125.IC4
property red

red property

property sensing_range : str
The Full Scale RGB Range has two different selectable ranges at bit 3.

The range determines the ADC resolution (12 bits and 16 bits). Each range has a maximum allowable lux value. Higher range values offer better resolution and wider lux value

Mode

Value

isl29125.LUX_375

0b0 375 lux

isl29125.LUX_10K

0b1 10000 lux

Example

i2c = board.I2C()
isl = isl29125.ISL29125(i2c)


isl.operation_mode = isl29125.LUX_375