Skip to content

Instantly share code, notes, and snippets.

@baskaufs
Last active April 1, 2022 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baskaufs/6bf8c967df0c9312b06e4a4458d585bb to your computer and use it in GitHub Desktop.
Save baskaufs/6bf8c967df0c9312b06e4a4458d585bb to your computer and use it in GitHub Desktop.
CircuitPython code to use with VCNL 4040 proximity and lux sensor
import time
import board
import busio
import adafruit_vcnl4040
i2c = busio.I2C(board.SCL1, board.SDA1)
sensor = adafruit_vcnl4040.VCNL4040(i2c)
while True:
print("Proximity:", sensor.proximity)
print("Light: %d lux" % sensor.lux)
# Use the following line for the plotter function
#print( (sensor.lux,) ) # Force the data to be represented as a 1=tuple
time.sleep(1.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment