I have recently bought the Adafruit AS7341 breakout, and want to use it on my Adafruit Feather Sense board.
After wiring and running the code exactly as the Adafruit AS7341 product guide tells me to, I get an error when initiating the sensor telling me to check my wiring. (Code and error log below.) Running the same sensor on my Adafruit ItsyBitsy nRF52840 gives no errors, and works as expected. After consulting your I2C address list, I suspect the sensor does not initiate because it shares I2C address with the APDS9960 sensor on board the Feather Sense. Is this correct? Also, is there anything I can do to fix this conflict, like changing the I2C address of the AS7341 or some how disabling the APDS9960?
Code:
Code: Select all
# SPDX-FileCopyrightText: 2020 Bryan Siepert, written for Adafruit Industries
# SPDX-License-Identifier: MIT
from time import sleep
import board
from adafruit_as7341 import AS7341
i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
sensor = AS7341(i2c)
def bar_graph(read_value):
scaled = int(read_value / 1000)
return "[%5d] " % read_value + (scaled * "*")
while True:
print("F1 - 415nm/Violet %s" % bar_graph(sensor.channel_415nm))
print("F2 - 445nm//Indigo %s" % bar_graph(sensor.channel_445nm))
print("F3 - 480nm//Blue %s" % bar_graph(sensor.channel_480nm))
print("F4 - 515nm//Cyan %s" % bar_graph(sensor.channel_515nm))
print("F5 - 555nm/Green %s" % bar_graph(sensor.channel_555nm))
print("F6 - 590nm/Yellow %s" % bar_graph(sensor.channel_590nm))
print("F7 - 630nm/Orange %s" % bar_graph(sensor.channel_630nm))
print("F8 - 680nm/Red %s" % bar_graph(sensor.channel_680nm))
print("Clear %s" % bar_graph(sensor.channel_clear))
print("Near-IR (NIR) %s" % bar_graph(sensor.channel_nir))
print("\n------------------------------------------------")
sleep(1)
Code: Select all
Traceback (most recent call last):
File "code.py", line 9, in <module>
File "adafruit_as7341.py", line 358, in __init__
RuntimeError: Failed to find an AS7341 sensor - check your wiring!