#PySpectrometer-AS7343
Real-time spectral analysis application for the AS7343 18-channel spectral sensor, inspired by PySpectrometer2 by Les Wright.
Test using Sansi 15w full spectrum bulb.

Video Demo here >>> Youtube Demo
PySpectrometer-AS7343 transforms the AS7343 discrete spectral sensor into a visual spectrometer with:
- Smooth interpolated spectrum with rainbow gradient fill
- Real-time waterfall display showing spectral changes over time
- Peak detection and labeling with adjustable sensitivity
- Savitzky-Golay filtering for noise reduction
- Calculated metrics: Lux, PPFD, CCT, Blue%
- PNG and CSV export for data analysis
- OpenCV-based GUI with keyboard controls
- AS7343 18-channel spectral sensor
- ESP32-C3 development board (or compatible)
- USB cable for serial communication
- Computer running Python 3.7+
pip install opencv-python numpy scipy pyserialUpload the AS7343 firmware to your ESP32-C3:
# Open in Arduino IDE:
# as7343_18ch_gain_esp32c3.ino
# Board: Seeed_Xiao_ESP32C3 Dev Module
# Uploadcd PySpectrometer-AS7343
python3 PySpectrometer-AS7343.pyWith options:
# Specify serial port
python3 PySpectrometer-AS7343.py --port /dev/ttyUSB0
# Start fullscreen
python3 PySpectrometer-AS7343.py --fullscreen
# Disable waterfall display
python3 PySpectrometer-AS7343.py --no-waterfall| Key | Function |
|---|---|
| Display | |
q |
Quit application |
f |
Toggle fullscreen |
w |
Toggle waterfall display |
m |
Toggle measurement cursor |
| Data | |
s |
Save spectrum (PNG + CSV) |
h |
Hold/freeze peaks |
| Sensor | |
+/- |
Increase/decrease gain |
Space |
Toggle LED (reflectance mode) |
| Processing | |
o/l |
Increase/decrease smoothing |
i/k |
Increase/decrease peak width |
u/j |
Increase/decrease peak threshold |
Shows current status:
- Gain setting
- LED status
- Hold peaks indicator
- Smoothing level
- Peak threshold
- Calculated metrics (Lux, PPFD, CCT, Blue%, NIR, Clear)
Horizontal color bar showing raw spectrum intensity mapped to wavelength colors.
- Rainbow gradient fill under the spectrum curve
- Black outline showing interpolated spectrum
- Data point markers (circles) at actual sensor wavelengths
- Peak labels showing detected peak wavelengths
- Wavelength graticule with 10nm minor / 50nm major gridlines
- Measurement cursor (when enabled) showing wavelength at mouse position
Time-stacked spectra showing how the spectrum changes over time. Newest data appears at top.
PySpectrometer-AS7343 uses all 12 spectral channels of the AS7343, displayed in wavelength order:
| # | Key | Channel | Wavelength | Color |
|---|---|---|---|---|
| 1 | 1 |
F1 | 405nm | Violet |
| 2 | 2 |
F2 | 425nm | Deep Violet |
| 3 | 3 |
FZ | 450nm | Blue |
| 4 | 4 |
F3 | 475nm | Cyan |
| 5 | 5 |
F4 | 515nm | Green |
| 6 | 6 |
F5 | 550nm | Yellow-Green |
| 7 | 7 |
FY | 555nm | Yellow-Green |
| 8 | 8 |
FXL | 600nm | Orange |
| 9 | 9 |
F6 | 620nm | Orange-Red |
| 10 | a |
F7 | 670nm | Red |
| 11 | b |
F8 | 730nm | Deep Red |
| 12 | n |
NIR | 855nm | Near-Infrared |
The display range extends from 380nm to 905nm to show the full channel bandwidth coverage. The spectrum curve tapers naturally to zero at both edges.
Additional channels (not used for this project):
- Clear: Broadband visible light
- F4L, FYL, F5L, FXLL: Left-side duplicates
- FD, FDL: Flicker detection
Calculated from the Clear channel. Requires calibration with a reference lux meter.
- If PAR calibrated: Uses spectral channels with calibration factor
- If only Lux calibrated: Estimated as
Lux / 65(typical for LED grow lights)
Estimated from the ratio of blue (FZ-450nm) to orange (FXL-600nm) channels.
Ratio of blue channels (F1-F4) to total spectral intensity (F1-FXL).
When you press s to save, three files are created:
- spectrum-YYYYMMDD-HHMMSS.png - Screenshot of the display
- spectrum-YYYYMMDD-HHMMSS.csv - Interpolated spectrum data (wavelength, intensity)
- channels-YYYYMMDD-HHMMSS.csv - Raw AS7343 channel values
Calibration data is stored in as7343_calibration.json and persists across sessions.
- Position AS7343 and reference lux meter side-by-side
- Note the reference lux reading
- Edit
as7343_calibration.json:
{
"lux": {
"7": 0.5 // gain_index: factor
}
}Factor = Reference_Lux / Clear_Channel_Value
Similar process using a quantum sensor for reference.
| Feature | PySpectrometer2 | PySpectrometer-AS7343 |
|---|---|---|
| Sensor | Camera + diffraction grating | AS7343 spectral sensor |
| Resolution | 800 continuous points | 12 discrete wavelengths |
| Wavelength Range | ~380-780nm (calibration dependent) | 405-600nm (fixed) |
| Hardware Cost | $50-300 (grating + camera) | $13-20 (sensor + MCU) |
| Setup | Optical alignment required | Plug and play |
| GUI Framework | OpenCV | OpenCV |
| Waterfall | Yes | Yes |
| Peak Detection | Yes | Yes |
| Savitzky-Golay | Yes | Yes |
- Check USB cable connection
- Verify ESP32-C3 drivers are installed
- On Linux, you may need:
sudo usermod -a -G dialout $USER
- Ensure firmware is uploaded and running
- Check that the correct port is selected
- Verify baud rate is 115200
- Increase smoothing with
okey - Adjust gain with
+/-keys - Ensure stable lighting conditions
- Lower threshold with
jkey - Adjust peak width with
k/ikeys
- PySpectrometer2 by Les Wright - Original inspiration and algorithm reference
- AS7343 Datasheet by ams-OSRAM - Channel specifications
- SparkFun - AS7343 Arduino library
- Benb0jangles (2026)
MIT License - See LICENSE file for details.