adafruit_as7341

CircuitPython library for use with the Adafruit AS7341 breakout

  • Author(s): Bryan Siepert

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_as7341.AS7341(i2c_bus: busio.I2C, address: int = 57)

Library for the AS7341 Sensor

Parameters
  • i2c_bus (I2C) – The I2C bus the device is connected to

  • address (int) – The I2C device address. Defaults to 0x39

Quickstart: Importing and using the device

Here is an example of using the AS7341. First you will need to import the libraries to use the sensor

import board
from adafruit_as7341 import AS7341

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
sensor = AS7341(i2c)

Now you have access to the different channels

channel_415nm = sensor.channel_415nm
channel_445nm = sensor.channel_445nm
channel_480nm = sensor.channel_480nm
channel_515nm = sensor.channel_515nm
channel_555nm = sensor.channel_555nm
channel_590nm = sensor.channel_590nm
channel_630nm = sensor.channel_630nm
channel_680nm = sensor.channel_680nm
property all_channels: Tuple[int, ...]

The current readings for all six ADC channels

astep: adafruit_register.i2c_struct.UnaryStruct

The integration time step size in 2.78 microsecond increments

Return type

int

atime: adafruit_register.i2c_struct.UnaryStruct

The integration time step count. Total integration time will be (ATIME + 1) * (ASTEP + 1) * 2.78µS

Return type

int

property channel_415nm: int

The current reading for the 415nm band

property channel_445nm: int

The current reading for the 445nm band

property channel_480nm: int

The current reading for the 480nm band

property channel_515nm: int

The current reading for the 515nm band

property channel_555nm: int

The current reading for the 555nm band

property channel_590nm: int

The current reading for the 590nm band

property channel_630nm: int

The current reading for the 630nm band

property channel_680nm: int

The current reading for the 680nm band

property channel_clear: int

The current reading for the clear sensor

property channel_nir: int

The current reading for the NIR (near-IR) sensor

property flicker_detected: Optional[int]

The flicker frequency detected in Hertz

property flicker_detection_enabled: bool

The flicker detection status of the sensor. True if the sensor is configured to detect flickers. Currently only 1000Hz and 1200Hz flicker detection is supported

property gain: int

The ADC gain multiplier. Must be a valid adafruit_as7341.Gain()

initialize() None

Configure the sensors with the default settings

class adafruit_as7341.Gain

Options for accelerometer_range

Setting

Gain Value

Gain.GAIN_0_5X

0.5

Gain.GAIN_1X

1

Gain.GAIN_2X

2

Gain.GAIN_4X

4

Gain.GAIN_8X

8

Gain.GAIN_16X

16

Gain.GAIN_32X

32

Gain.GAIN_64X

64

Gain.GAIN_128X

128

Gain.GAIN_256X

256

Gain.GAIN_512X

512