adafruit_as726x

Driver for the AS726x spectral sensors

  • Author(s): Dean Miller

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_as726x.AS726x

AS726x spectral sensor base class.

MODE_0: int = 0

Continuously gather samples of violet, blue, green and yellow. Orange and red are skipped and read zero.

MODE_1: int = 1

Continuously gather samples of green, yellow, orange and red. Violet and blue are skipped and read zero.

MODE_2: int = 2

Continuously gather samples of all colors

ONE_SHOT: int = 3

Gather a single sample of all colors and then stop

property driver_led: bool

True when the driver LED is on. False otherwise.

property indicator_led: bool

True when the indicator LED is on. False otherwise.

property driver_led_current: float

The current limit for the driver LED in milliamps. One of:

  • 12.5 mA

  • 25 mA

  • 50 mA

  • 100 mA

property indicator_led_current: int

The current limit for the indicator LED in milliamps. One of:

  • 1 mA

  • 2 mA

  • 4 mA

  • 8 mA

property conversion_mode: int

The conversion mode. One of:

property gain: float

The gain for the sensor

property integration_time: float

The integration time in milliseconds between 2.8 and 714 ms

start_measurement() None

Begin a measurement.

This will set the device to One Shot mode and values will not change after data_ready until start_measurement() is called again or the conversion_mode() is changed.

read_channel(channel: int) int

Read an individual sensor channel

read_calibrated_value(channel: int) float

Read a calibrated sensor channel

property data_ready: bool

True if the sensor has data ready to be read, False otherwise

property temperature: int

The temperature of the device in Celsius

property violet: float

Calibrated violet (450nm) value

property blue: float

Calibrated blue (500nm) value

property green: float

Calibrated green (550nm) value

property yellow: float

Calibrated yellow (570nm) value

property orange: float

Calibrated orange (600nm) value

property red: float

Calibrated red (650nm) value

property raw_violet: int

Raw violet (450nm) 16-bit value

property raw_blue: int

Raw blue (500nm) 16-bit value

property raw_green: int

Raw green (550nm) 16-bit value

property raw_yellow: int

Raw yellow (570nm) 16-bit value

property raw_orange: int

Raw orange (600nm) 16-bit value

property raw_red: int

Raw red (650nm) 16-bit value

class adafruit_as726x.AS726x_I2C(i2c_bus: I2C, address: int = 73)

AS726x spectral sensor via I2C.

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

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

Quickstart: Importing and using the AS726x

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

import board
from adafruit_as726x import AS726x_I2C

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 = AS726x_I2C(i2c)

Now you have access to the different color attributes

violet = sensor.violet
blue = sensor.blue
green = sensor.green
yellow = sensor.yellow
orange = sensor.orange
red = sensor.red
class adafruit_as726x.AS726x_UART(uart: UART)

AS726x spectral sensor via UART.

Parameters:

uart (UART) – The UART connected to the sensor

Quickstart: Importing and using the AS726x

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

import board
from adafruit_as726x import AS726x_UART

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

uart = board.UART()  # uses board.SCL and board.SDA
sensor = AS726x_UART(uart)

Now you have access to the different color attributes

violet = sensor.violet
blue = sensor.blue
green = sensor.green
yellow = sensor.yellow
orange = sensor.orange
red = sensor.red
read_channel(channel: int) float

Read an individual sensor channel

read_calibrated_value(channel: int) float

Read a calibrated sensor channel