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 (busio.I2C) – The I2C bus the VEML7700 is connected to.
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

Ambient light data.

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

import time
import board
import busio
import adafruit_veml7700

i2c = busio.I2C(board.SCL, board.SDA)
veml7700 = adafruit_veml7700.VEML7700(i2c)

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

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 busio
import adafruit_veml7700

i2c = busio.I2C(board.SCL, 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)
Type:Ambient light gain setting. Gain settings are 2, 1, 1/4 and 1/8. Settings options are
light_high_threshold

Ambient light sensor interrupt high threshold setting.

light_integration_time

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 busio
import adafruit_veml7700

i2c = busio.I2C(board.SCL, 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)
Type:Ambient light integration time setting. Longer time has higher sensitivity. Can be
light_interrupt

Enable interrupt. True to enable, False to disable.

light_interrupt_high

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

light_interrupt_low

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

light_low_threshold

Ambient light sensor interrupt low threshold setting.

light_shutdown

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

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 busio
import adafruit_veml7700

i2c = busio.I2C(board.SCL, 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

White light data.

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

import time
import board
import busio
import adafruit_veml7700

i2c = busio.I2C(board.SCL, board.SDA)
veml7700 = adafruit_veml7700.VEML7700(i2c)

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