Simple test¶
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2# SPDX-FileCopyrightText: Copyright (c) 2022 Carter Nelson for Adafruit Industries
3#
4# SPDX-License-Identifier: Unlicense
5
6import time
7import board
8import adafruit_si1145
9
10# setup I2C bus using board default
11# change as needed for specific boards
12i2c = board.I2C() # uses board.SCL and board.SDA
13# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
14
15# setup sensor
16si1145 = adafruit_si1145.SI1145(i2c)
17
18# loop forever printing values
19while True:
20 vis, ir = si1145.als
21 print("Visible = {}, Infrared = {}".format(vis, ir))
22 time.sleep(1)