isl29125¶
CircuitPython driver for the ISL29125 Sensor
Author(s): Jose D. Montoya
Implementation Notes¶
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
-
class isl29125.ISL29125(i2c_bus: busio.I2C, address: int =
_I2C_ADDR)[source]¶ Driver for the ISL29125 Light Sensor connected over I2C.
- Parameters:¶
- Raises:¶
RuntimeError – if the sensor is not found
Quickstart: Importing and using the device
Here is an example of using the
ISL29125class. First you will need to import the libraries to use the sensorimport board import circuitpython_isl29125.isl29125 as isl29125Once this is done you can define your
board.I2Cobject and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA isl = isl29125.ISL29125(i2c)Now you have access to the
colorsattributered, 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_12BITS0b016 bitsisl29125.RES_16BITS0b112 bitsExample¶
i2c = board.I2C() isl = isl29125.ISL29125(i2c) isl.operation_mode = isl29125.RES_12BITS
- property blue¶
blue property
- 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_triggeredis set to logic HIGH when the light intensity crosses the interrupt thresholds window (register address 0x04 - 0x07)Value
Value
isl29125.NO_INTERRUPT0b00isl29125.GREEN_INTERRUPT0b01:
isl29125.RED_INTERRUPT0b10isl29125.BLUE_INTERRUPT0b11Example¶
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
0b0Interrupt is cleared or not triggered yet
0b1interrupt 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_ON0b1isl29125.IR_OFF0b0Example¶
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 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.POWERDOWN0b000isl29125.GREEN_ONLY0b001isl29125.RED_ONLY0b010isl29125.BLUE_ONLY0b011isl29125.STANDBY0b100isl29125.RED_GREEN_BLUE0b101isl29125.GREEN_RED0b110isl29125.GREEN_BLUE0b111Example¶
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.IC10b000isl29125.IC20b001isl29125.IC40b010isl29125.IC80b011Example¶
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_3750b0375 luxisl29125.LUX_10K0b110000 luxExample¶
i2c = board.I2C() isl = isl29125.ISL29125(i2c) isl.operation_mode = isl29125.LUX_375