Simple test

Ensure your device works with this simple test.

examples/isl29125_simpletest.py
import time
import board
import isl29125


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

while True:
    red, green, blue = isl.colors
    print("Red Luminance: ", red)
    print("Green Luminance: ", green)
    print("Blue Luminance:", blue)
    time.sleep(1)

Operation Mode

Example showing how to change the sensor operation mode

examples/isl29125_operation_mode.py
import board
import isl29125


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


print("Red Luminance: ", isl.red)
print("Current Operation Mode Value: ", bin(isl.operation_mode))
# Changing Operation Mode to Blue Only
isl.operation_mode = isl29125.BLUE_ONLY
print("Changed Operation mode to Blue Only:", bin(isl.operation_mode))
print("Red Luminance after change: ", isl.red)

RGB Sensing Range

Example showing how to change the sensor RGB sensing range

examples/isl29125_rgb_sensing_range.py
import time
import board
import isl29125


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

print("Current Sensing Range Value: ", bin(isl.sensing_range))
red, green, blue = isl.colors
print("Red Luminance: ", red)
print("Green Luminance: ", green)
print("Blue Luminance:", blue)
time.sleep(1)

isl.sensing_range = isl29125.LUX_375
print("Changed Sensing Range to 375 lux:", bin(isl.sensing_range))
red, green, blue = isl.colors
print("Red Luminance: ", red)
print("Green Luminance: ", green)
print("Blue Luminance:", blue)
time.sleep(1)

ADC Resolution

Example showing how to change the sensor ADC Resolution

examples/isl29125_rgb_sensing_range.py
import time
import board
import isl29125


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

print("Current Sensing Range Value: ", bin(isl.sensing_range))
red, green, blue = isl.colors
print("Red Luminance: ", red)
print("Green Luminance: ", green)
print("Blue Luminance:", blue)
time.sleep(1)

isl.sensing_range = isl29125.LUX_375
print("Changed Sensing Range to 375 lux:", bin(isl.sensing_range))
red, green, blue = isl.colors
print("Red Luminance: ", red)
print("Green Luminance: ", green)
print("Blue Luminance:", blue)
time.sleep(1)

Threshold Example

Example showing the threshold window setting

examples/isl29125_threshold.py
import time
import board
import digitalio
import isl29125

# You will need to test this example with you setup as my sensor int pin does no change
# when entering or exiting the threshold window

switch_pin = digitalio.DigitalInOut(board.D9)

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

print("Current High Threshold: ", isl.high_threshold)
print("Current Low Threshold: ", isl.low_threshold)
isl.interrupt_threshold = isl29125.BLUE_INTERRUPT
print("Setting up Blue Threshold window to 100-300 Lux")
isl.high_threshold = 300
isl.low_threshold = 100
print("Current High Threshold: ", isl.high_threshold)
print("Current Low Threshold: ", isl.low_threshold)

while True:
    print("INT Pin Value:", switch_pin.value)
    isl.clear_register_flag()
    red, green, blue = isl.colors
    print("Red Luminance: ", red)
    print("Green Luminance: ", green)
    print("Blue Luminance:", blue)

    time.sleep(1.5)