I just got one of the new AS7343 14-Channel Multi-Spectral Sensor Breakouts.
AS7343 14-Channel Multi-Spectral Sensor Breakout (pimoroni.com)
I have it connected to my Pico W Explorer running a modified version of the Tufty demo py file.
I looked up the RGB values for the nm values for each channel and edited the file to match them up.
From the data sheet: R,G,B
F1: 396...415 405 nm violet (130, 0, 200)
F2: 415...435 425 nm blue (84, 0, 255)
FZ: 440...460 450 nm light blue (0, 70, 255)
F3: 465...485 475 nm turqois (0, 192, 255)
F4: 505...525 515 nm light green (31, 255, 0)
FY: 545...565 555 nm pail green (179, 255, 0)
F5: 540...560 550 nm pail green (163, 255, 0)
FXL: 590...610 600 nm orange (255, 190, 0
F6: 630...650 640 nm red (255, 33, 0)
F7: 680...700 690 nm red (255, 0, 0)
F8: 735...756 745 nm dark red (171, 0, 0)
NIR: 645...865 855 nm near ir (97, 0, 0)
Blue 400...450 nm
Indigo 450...490 nm
Cyan 490...530 nm
Green 530...570 nm
Yellow 570...600 nm
Orange 600...630 nm
Red 630...700 nm
One issue is the order that they are placed in the demo file isnāt ideal. Not as far as wavelength goes.
āFZ: {0}, FY: {1}, FXL: {2}, NIR: {3}, F2: {4}, F3: {5}, F4: {6}, F6: {7}, F1: {8}, F5: {9}, F7: {10}, F8: {11}ā.format(*reading)
Ideally Iād prefer
F1, F2, FZ, F3, F4, FY, F5, FXL, F6, F7, F8, NIR
Going to be a bit of work to achieve that though.
from breakout_as7343 import BreakoutAS7343
from pimoroni_i2c import PimoroniI2C
from picographics import PicoGraphics, DISPLAY_PICO_W_EXPLORER, PEN_P4
from pimoroni import Button
from breakout_encoder_wheel import BreakoutEncoderWheel, UP, DOWN, LEFT, RIGHT, CENTRE, NUM_BUTTONS, NUM_LEDS
i2c = PimoroniI2C(sda=20, scl=21)
as7343 = BreakoutAS7343(i2c)
wheel = BreakoutEncoderWheel(i2c)
BUTTON_NAMES = ["Up", "Down", "Left", "Right", "Centre"]
last_pressed = [False] * NUM_BUTTONS
pressed = [False] * NUM_BUTTONS
wheel.clear()
button_a = Button(6)
button_b = Button(7)
button_x = Button(10)
button_y = Button(11)
display = PicoGraphics(display=DISPLAY_PICO_W_EXPLORER, pen_type=PEN_P4, rotate=270)
display.set_font("bitmap8")
display.set_backlight(0.5)
WIDTH, HEIGHT = display.get_bounds()
BLACK = display.create_pen(0, 0, 0)
FZ = display.create_pen(0, 70, 255)
FY = display.create_pen(179, 255, 0)
FXL = display.create_pen(255, 190, 0)
NIR = display.create_pen(97, 0, 0)
F2 = display.create_pen(84, 0, 255)
F3 = display.create_pen(0, 192, 255)
F4 = display.create_pen(31, 255, 0)
F6 = display.create_pen(255, 33, 0)
F1 = display.create_pen(130, 0, 200)
F5 = display.create_pen(163, 255, 0)
F7 = display.create_pen(255, 0, 0)
F8 = display.create_pen(171, 0, 0)
WHITE = display.create_pen(255, 255, 255)
as7343.set_channels(18)
as7343.set_gain(1024)
as7343.set_measurement_time(33) # Roughly 30fps at 16ms/measurement
as7343.set_integration_time(27800)
as7343.set_illumination_current(4)
as7343.set_illumination_led(False)
BAR_WIDTH = 18
BAR_SPACING = 4
MARGIN = display.measure_text("NIR") + 2
BAR_HEIGHT = WIDTH - MARGIN
OFFSET_LEFT = int((HEIGHT - ((BAR_WIDTH + BAR_SPACING) * 12)) / 2)
# Satrting max values for auto-ranging
# From figure 8 of the datasheet
MAX_VALUES = [
2711,
4684,
5970,
13226,
2371,
962,
3926,
4170,
7760,
1967,
6774,
1166
]
LABELS = [
"FZ",
"FY",
"FXL",
"NIR",
"F2",
"F3",
"F4",
"F6",
"F1",
"F5",
"F7",
"F8"
]
while True:
display.set_pen(0)
display.clear()
readings = as7343.read()
for i, reading in enumerate(readings):
MAX_VALUES[i] = max(reading, MAX_VALUES[i])
scaled = int(reading / MAX_VALUES[i] * BAR_HEIGHT)
y = i * (BAR_WIDTH + BAR_SPACING)
y += OFFSET_LEFT
display.set_pen(i + 1)
display.rectangle(MARGIN, y, scaled, BAR_WIDTH)
display.set_pen(WHITE)
display.text(LABELS[i], 0, y + 1)
display.update()