Skip to content

jonnor/spectrometer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple spectrometer for edible oils

This is a simple setup for a basic 14 channel visible-spectrum sensor based on ams OSRAM AS7343, using MicroPython firmware.

Classification of edible oil

The device has a stand designed for standard (10 mm) cuvettes, set up for flouresence spectrocopy using white LED and reflectance spectroscopy using white LED.

Initially intended for characterization of edible oils, such as olive oil, canola/rapeseed, sunflower, et.c.

This can be used for things like:

  • Detect/classify the type of oil
  • Detect adulterated oils, for example addition of waste frying oil or other oils in virgin olive oil
  • Detect degraded oil quality, for example due to exessive oxygen/heat exposure or age

The machine learning parts are powered by emlearn-micropython, a machine learning and digital signal processing library for MicroPython.

Status

Proof of Concept.

Can collect data from AS7343, and classify the type pf edible successfully using a nearest-neighbor model. For the demo only 2 dimensions were used, but up to 2x12=24 dimensions can be used.

Short demo video (YouTube).

TODO

  • Speed up the measurement cycle. Want under 1 second total
  • Collect data on different concentrations of oil.
  • Test ability to detect adulteration of extra virgin olive oil
  • Implement regression model to estimate concentrations. Example: PCA+linreg, or PLSR

Operating principle

The device measures the samples under 2 conditions:

  • When exposed to white light from same side as sensor (reflectance)
  • When exposed to 400 nm UV light from the side (floursence)

Many edible oils have a Extra Virgin Olive Oil (EVOO) notably has a red-ish response under UV, which comes from the chlorophyll. This is not present in refined olive oil.

Edible oils under 400nm

The AS7343 has 12 narrow-band channels across the visible spectrum and near-infrared (NIR), plus 2 broad-band channels.

AS7343 channels spectral response

Hardware

Below is the parts that I have used. The AS7343 chip is critical, and a microcontroller that can run MicroPython. If you are willing to adapt the firmware code the other parts can be replaced with other alternatives relatively easily.

Electronics

All should be available from Digikey.

Mechanics

  • 10 mm light-path cuvettes (12.5x12.5x45 mm / 4.5 ml)
  • M3 wood/plastic screws

3d-printed parts

Firmware

Install MicroPython

For the XIAO NRF52840 I used the Zephyr port of MicroPython. As of November 2025 it is not downloadable on micropython.org, but must be built.

Install dependencies

External dependencies

mpremote mip install os-path

Local files

mpremote cp -r firmware/ :

Run

mpremote run firmware/spectrometer_main.py

About

Spectrometer using emlearn-micropython

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors