|
1 |
| -Introduction |
2 |
| -============ |
| 1 | +AS7343 CircuitPython Library |
| 2 | +============================= |
3 | 3 |
|
4 |
| -.. image:: https://readthedocs.org/projects/adafruit-circuitpython-as7343/badge/?version=latest |
5 |
| - :target: https://adafruit-circuitpython-as7343.readthedocs.io/ |
6 |
| - :alt: Documentation Status |
| 4 | +A CircuitPython driver for the AMS AS7343 14-channel spectral sensor. This device provides high-resolution spectral measurements across the visible and near-infrared spectrum, making it ideal for: |
7 | 5 |
|
8 |
| -.. image:: https://img.shields.io/discord/327254708534116352.svg |
9 |
| - :target: https://adafru.it/discord |
10 |
| - :alt: Discord |
| 6 | +- Color measurement and classification |
| 7 | +- LED spectrum analysis |
| 8 | +- Environmental light sensing |
| 9 | +- Low-cost lab and educational tools |
11 | 10 |
|
12 |
| -.. image:: https://github.com/joepardue/circuitpython-as7343/workflows/Build%20CI/badge.svg |
13 |
| - :target: https://github.com/joepardue/circuitpython-as7343/actions |
14 |
| - :alt: Build Status |
| 11 | +Description |
| 12 | +----------- |
15 | 13 |
|
16 |
| -CircuitPython driver for the AS7343 spectral sensor |
| 14 | +The AMS AS7343 is a spectral sensor offering readings from approximately 380nm to 1000nm. It includes: |
17 | 15 |
|
| 16 | +- 14 photodiode channels: F1–F8, FZ, FY, FXL, NIR, and CLR |
| 17 | +- Adjustable gain (0.5x to 2048x) |
| 18 | +- Integration time in microseconds |
| 19 | +- Internal SMUX (sensor multiplexer) to cycle through photodiode sets |
| 20 | +- I2C interface (address 0x39) |
18 | 21 |
|
19 |
| -Dependencies |
20 |
| -============= |
21 |
| -This driver depends on: |
| 22 | +This driver provides methods to set gain/integration time, select SMUX modes, perform full or partial scans, and manage power settings. |
22 | 23 |
|
23 |
| -* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ |
24 |
| -* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_ |
| 24 | +Features |
| 25 | +-------- |
25 | 26 |
|
26 |
| -Please ensure all dependencies are available on the CircuitPython filesystem. |
27 |
| -This is easily achieved by downloading |
28 |
| -`the Adafruit library and driver bundle <https://circuitpython.org/libraries>`_ |
29 |
| -or individual libraries can be installed using |
30 |
| -`circup <https://github.com/adafruit/circup>`_. |
| 27 | +- Full 14-channel spectral measurement using read_all() |
| 28 | +- SMUX mode selection for visible, NIR, and extended bands |
| 29 | +- Low-power mode and sleep-after-interrupt (SAI) |
| 30 | +- Saturation threshold checking |
| 31 | +- Compatible with CircuitPython and Adafruit BusDevice |
| 32 | + |
| 33 | +Installation |
| 34 | +------------ |
| 35 | + |
| 36 | +1. Download the CircuitPython library bundle from https://circuitpython.org/libraries |
| 37 | +2. Copy the following into the `lib/` directory on your device: |
| 38 | + - `as7343.py` (from this repo) |
| 39 | + - `adafruit_bus_device` (from the bundle) |
31 | 40 |
|
32 | 41 | Usage Example
|
33 |
| -============= |
| 42 | +------------- |
34 | 43 |
|
35 | 44 | .. code-block:: python
|
36 | 45 |
|
37 | 46 | import board
|
38 |
| - import adafruit_as7343 |
| 47 | + import as7343 |
| 48 | + import time |
| 49 | +
|
| 50 | + i2c = board.STEMMA_I2C() |
| 51 | + sensor = as7343.AS7343(i2c) |
| 52 | + sensor.gain = as7343.GAIN_64X |
| 53 | + sensor.integration_time = 100000 |
| 54 | +
|
| 55 | + data = sensor.read_all() |
| 56 | + for ch, val in data.items(): |
| 57 | + print(f"{ch}: {val}") |
| 58 | +
|
| 59 | +Advanced Use |
| 60 | +------------ |
| 61 | + |
| 62 | +SMUX Read Example:: |
| 63 | + |
| 64 | + sensor.read_smux_mode(as7343.SMUX_VISIBLE) |
| 65 | + sensor.read_smux_mode(as7343.SMUX_NIR) |
| 66 | + sensor.read_smux_mode(as7343.SMUX_FZF5) |
| 67 | + |
| 68 | +Power Management:: |
| 69 | + |
| 70 | + sensor.enable_low_power_mode(True) |
| 71 | + sensor.enable_sleep_after_interrupt(True) |
| 72 | + sensor.shutdown() |
| 73 | + sensor.wake() |
| 74 | + |
| 75 | +Threshold Check:: |
| 76 | + |
| 77 | + alerts = sensor.check_thresholds(60000) |
| 78 | + for ch, value in alerts: |
| 79 | + print(f"High reading: {ch} = {value}") |
| 80 | + |
| 81 | +Supported Channels |
| 82 | +------------------ |
| 83 | + |
| 84 | +- F1, F2, F3, F4 – Violet to green (405–515 nm) |
| 85 | +- FY, F5 – Green/yellow (~555–560 nm) |
| 86 | +- F6, F7, F8 – Red to deep red (640–745 nm) |
| 87 | +- FZ, FXL – Additional narrowbands (450, 600 nm) |
| 88 | +- NIR – Near infrared (~855 nm) |
| 89 | +- CLR – Clear (broadband) |
| 90 | + |
| 91 | +License |
| 92 | +------- |
| 93 | + |
| 94 | +MIT License |
| 95 | + |
| 96 | +Author |
| 97 | +------ |
39 | 98 |
|
40 |
| - i2c = board.I2C() |
41 |
| - sensor = adafruit_as7343.AS7343(i2c) |
42 |
| - |
43 |
| - # Example usage code here |
| 99 | +Joe Pardue https://github.com/joepardue/AS7343-circuitpython-bundle |
0 commit comments