adafruit_veml7700

CircuitPython driver for VEML7700 high precision I2C ambient light sensor.

  • Author(s): Kattni Rembor

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_veml7700.VEML7700(i2c_bus, address=16)

Driver for the VEML7700 ambient light sensor.

Parameters
  • i2c_bus (I2C) – The I2C bus the device is connected to

  • address (int) – The I2C device address. Defaults to 0x10

gain_value()

Gain value in integer form. Used for calculating resolution().

integration_time_value()

Integration time value in integer form. Used for calculating resolution().

light = 4

Ambient light data.

This example prints the ambient light data. Cover the sensor to see the values change.

import time
import board
import adafruit_veml7700

i2c = board.I2C()  # uses board.SCL and board.SDA
veml7700 = adafruit_veml7700.VEML7700(i2c)

while True:
    print("Ambient light:", veml7700.light)
    time.sleep(0.1)
light_gain = 2

Ambient light gain setting. Gain settings are 2, 1, 1/4 and 1/8. Settings options are: ALS_GAIN_2, ALS_GAIN_1, ALS_GAIN_1_4, ALS_GAIN_1_8.

This example sets the ambient light gain to 2 and prints the ambient light sensor data.

import time
import board
import adafruit_veml7700

i2c = board.I2C()  # uses board.SCL and board.SDA
veml7700 = adafruit_vcnl4040.VCNL4040(i2c)

veml7700.light_gain = veml7700.ALS_GAIN_2

while True:
    print("Ambient light:", veml7700.light)
    time.sleep(0.1)
light_high_threshold = 1

Ambient light sensor interrupt high threshold setting.

light_integration_time = 4

Ambient light integration time setting. Longer time has higher sensitivity. Can be: ALS_25MS, ALS_50MS, ALS_100MS, ALS_200MS, ALS_400MS, ALS_800MS.

This example sets the ambient light integration time to 400ms and prints the ambient light sensor data.

import time
import board
import adafruit_veml7700

i2c = board.I2C()  # uses board.SCL and board.SDA
veml7700 = adafruit_vcnl4040.VCNL4040(i2c)

veml7700.light_integration_time = veml7700.ALS_400MS

while True:
    print("Ambient light:", veml7700.light)
    time.sleep(0.1)
light_interrupt = 0

Enable interrupt. True to enable, False to disable.

light_interrupt_high = 6

Ambient light high threshold interrupt flag. Triggered when high threshold exceeded.

light_interrupt_low = 6

Ambient light low threshold interrupt flag. Triggered when low threshold exceeded.

light_low_threshold = 2

Ambient light sensor interrupt low threshold setting.

light_shutdown = 0

Ambient light sensor shutdown. When True, ambient light sensor is disabled.

property lux

Light value in lux.

This example prints the light data in lux. Cover the sensor to see the values change.

import time
import board
import adafruit_veml7700

i2c = board.I2C()  # uses board.SCL and board.SDA
veml7700 = adafruit_veml7700.VEML7700(i2c)

while True:
    print("Lux:", veml7700.lux)
    time.sleep(0.1)
resolution()

Calculate the resolution`() necessary to calculate lux. Based on integration time and gain settings.

white = 5

White light data.

This example prints the white light data. Cover the sensor to see the values change.

import time
import board
import adafruit_veml7700

i2c = board.I2C()  # uses board.SCL and board.SDA
veml7700 = adafruit_veml7700.VEML7700(i2c)

while True:
    print("White light:", veml7700.white)
    time.sleep(0.1)