Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (20 sloc) 615 Bytes
# CircuitPython Demo - I2C sensor
import time
import adafruit_tsl2561
import board
import busio
i2c = busio.I2C(board.SCL, board.SDA)
# Lock the I2C device before we try to scan
while not i2c.try_lock():
pass
# Print the addresses found once
print("I2C addresses found:", [hex(device_address)
for device_address in i2c.scan()])
# Unlock I2C now that we're done scanning.
i2c.unlock()
# Create library object on our I2C port
tsl2561 = adafruit_tsl2561.TSL2561(i2c)
# Use the object to print the sensor readings
while True:
print("Lux:", tsl2561.lux)
time.sleep(1.0)
You can’t perform that action at this time.