I2C conflict when using Adafruit AS7341 with Adafruit Feather Sense

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
NorwegianRocketMan
 
Posts: 13
Joined: Thu Jan 05, 2023 8:57 am

I2C conflict when using Adafruit AS7341 with Adafruit Feather Sense

Post by NorwegianRocketMan »

Hi!

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)
Error-log:

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!

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: I2C conflict when using Adafruit AS7341 with Adafruit Feather Sense

Post by dastels »

There's an address conflict between the onboard APDS9960 and the AS7341: both use address 0x39. There doesn't look to be a way to adjust the address(es) on either device. TL;DR you can't use the AS7341 with the Feather Nrf52840 Sense.

Dave

User avatar
NorwegianRocketMan
 
Posts: 13
Joined: Thu Jan 05, 2023 8:57 am

Re: I2C conflict when using Adafruit AS7341 with Adafruit Feather Sense

Post by NorwegianRocketMan »

Thank you for the quick reply!

That is a bummer. Is this still the case if I use a multiplexer?

Also, as an aside (both for me and my students): Why is it that one cannot simply choose an address at random? Why must it be 0x39? Is this somehow related to hardware, or simply an artifact of your firmware/ecosystem? (I am, as you can tell, quite a rookie at this.)

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: I2C conflict when using Adafruit AS7341 with Adafruit Feather Sense

Post by dastels »

A multiplexor won't change the address the AS7341 is at, it just allows you to connect more than one.

The device address is set by the chip, in this case the AS7341. Some will have pins that you can connect to Vcc or ground to adjust the address. Some (as in the case of the AS7341) don't.

There is a chip, the LTC4316 https://www.analog.com/en/products/ltc4 ... t-overview that does I2C address translation, which you can buy at Digikey https://www.digikey.com/en/products/bas ... 316/115624 and Mouser https://www.mouser.com/c/?q=LTC4316 as raw chips. You'd want at to put it on a carrier board to make it easier to work with (on a breadboard and such). See https://learn.adafruit.com/smt-prototyp ... akout-pcbs but I'm not familiar enough with surface mount packages to know if one of the Adafruit boards will work with the MSOP-10 chip.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “For Educators”