Hello friends, I hope you all are doing great. Today, I am going to share the new AS7341 Spectral Sensor Library for Proteus Simulation. The AS7341 is a tiny spectrometer on a chip: instead of the three colours of an ordinary colour sensor it measures eight narrow bands of visible light, plus a clear channel and the near-infrared, and it reports them over I2C. With this library you can run a full Proteus simulation of it, register by register, so that the code you test here runs on the real sensor.

Figure: The light-source identifier working in the Proteus simulation.
Updates

AS7341 Spectral Sensor Library for Proteus

Latest version: V1.0 (November 2026, this tutorial)

Other light sensors: BH1750 · TCS34725 · LDR · APDS-9960

Helping Tools

The module is drawn at its real size and comes alive at run time: its PWR LED works, its diffuser takes the colour of the light it measures, and its white LED lights when you switch it on. The demo is a light-source identifier - it reads the whole spectrum, works out whether the light is daylight, a warm bulb, a white LED, a fluorescent tube or a grow light, and draws the spectrum as bars on an OLED.

NOTICE: Our team has put a lot of effort into these small parts: the bodies, the animation and the pop-ups are all our own design, and you get them free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the photodiode board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the AS7341 Spectral Sensor Library for Proteus Simulation:

Figure: The AS7341 Spectral Sensor Library for Proteus Simulation.

What is the AS7341?

The AS7341 from ams OSRAM is an 11-channel spectral sensor in a package of 3.1 x 2.0 mm. Under its window sit photodiodes with tiny interference filters, each one letting through a band about 20 to 50 nm wide: eight bands spread over the visible spectrum from violet to deep red, a clear photodiode for the total light, a near-infrared one at 910 nm, and one more for flicker. Behind them are six analog-to-digital converters (ADCs) and a switch matrix that connects the photodiodes to them.

The channels of the AS7341
ChannelCentreColour
F1415 nmviolet
F2445 nmindigo / blue
F3480 nmblue
F4515 nmcyan / green
F5555 nmgreen
F6590 nmyellow
F7630 nmorange
F8680 nmred
Clearbroadthe whole visible range
NIR910 nmnear-infrared
The AS7341 at a glance
AS7341
Measureseight visible bands, clear, near-infrared (and flicker)
ADCssix, 16 bits each; the SMUX connects the photodiodes to them
Integration(ATIME + 1) x (ASTEP + 1) x 2.78 us
Gain0.5x to 512x
InterfaceI2C at the address 0x39; INT pin, open drain, active LOW
LED driveran LDR pin for an external LED, 4 - 258 mA
Sizethe sensor 3.1 x 2.0 mm; our module 20 x 17 mm

Eight Colours Instead of Three

An RGB colour sensor, such as the one in our TCS34725 Library for Proteus, splits light into red, green and blue - the way our eyes do. That is enough to tell colours apart, but not enough to tell lights apart: a white LED, a fluorescent tube and daylight can all look white to an RGB sensor. The AS7341 sees the shape of the spectrum: the blue spike of an LED, the green line of mercury in a fluorescent tube, the steady climb towards red of a hot filament. That is what makes it useful for checking lamps, sorting materials, measuring grow lights and matching colours under any light.

How the AS7341 Talks: Registers and the SMUX

The AS7341 is a register device at the I2C address 0x39. You write the address of a register, then a value, or you write the address and read bytes back - the address moves on by itself. The ID register at 0x92 reads 0x24. These are the registers that matter:

The main registers of the AS7341
RegisterAddressWhat it does
SMUX RAM0x00 - 0x13one nibble per photodiode: the ADC it connects to (ADC number + 1, 0 = off)
ENABLE0x80PON (power on), SP_EN (measure), WEN (wait), SMUXEN (run the SMUX command)
ATIME0x81integration steps - 1
ID0x920x24
ASTATUS0x94saturation and the gain; reading it latches the data
CH0 - CH50x95 - 0xA0the six ADCs, 16 bits each, low byte first
STATUS20xA3AVALID (bit 6): a measurement is ready
CFG10xAAthe gain: 0 = 0.5x, 1 = 1x ... 10 = 512x
CFG60xAFSMUX_CMD: 2 = write the RAM into the SMUX
ASTEP0xCA - 0xCBthe step size, 16 bits (default 999)

Six ADCs, Eleven Channels: the SMUX

Ten light channels and only six ADCs means the sensor cannot measure everything at once. The SMUX (super multiplexer) decides which photodiode goes to which ADC. You describe the connections in 20 bytes of SMUX RAM, set CFG6 to "write", and set SMUXEN in ENABLE; when SMUXEN clears again, the new connections are in place. A full spectrum is therefore two measurements: first F1 to F4 with Clear and NIR, then F5 to F8 with Clear and NIR. Always turn the measurement off before you change the SMUX.

Integration Time and Gain

Each measurement integrates the light for (ATIME + 1) x (ASTEP + 1) x 2.78 microseconds, and the largest count it can reach - full scale - is (ATIME + 1) x (ASTEP + 1), up to 65535. Our demo uses ATIME 29 and ASTEP 599: 50 ms and a full scale of 18000. The gain in CFG1 multiplies the signal from 0.5x to 512x. Too much gain or time and a channel saturates - the ASAT bit flags it - so a real design lowers the gain in bright light.

Features of the AS7341 Spectral Sensor Library for Proteus Simulation

  • A real-looking module: the black board at its real size, 20 x 17 mm, with the sensor and its diffuser, the white LED beside it, the regulator, the level shifter, the pull-ups and our small TEP mark.
  • Animated: the PWR LED, the diffuser taking the colour of the light, and the white LED lighting when you switch it on.
  • The real register map: ENABLE, ATIME, ASTEP, CFG1, CFG6, the SMUX RAM and its commands, ID, ASTATUS, STATUS2, the six ADC channels and, in register bank 1, the LED register.
  • A real SMUX: the model decodes the 20 SMUX bytes you write, so the two-pass F1-F4 / F5-F8 measurement works exactly as on the chip - and a wrong table gives wrong channels.
  • Six lights to measure: daylight, a warm bulb, a white LED, a fluorescent tube, a grow light and the dark, each with its own spectrum, and chips to change the light at any time.
  • A pop-up: the light's spectrum from 380 to 950 nm, the ten channels as bars against full scale, eight live tiles, graphs, an event log and a check page.
  • A complete package: about 1.6 MB with the library, our OLED library, our Arduino UNO V4.0 and the demo, without the source code of the model.

The AS7341 in Proteus

The device is AS7341TEP in TEPAS7341.LIB, under Sensors > Optical, with the prefix U and the model TEPAS7341.DLL. Search AS7341 or spectral in Pick Devices. It has five pins along the bottom: VIN (3.3 to 5 V), GND, SCL, SDA and INT. Its properties set the light: PROFILE (DEMO or STEADY), LIGHT (the light at the start) and LUX (its brightness).

Figure: The AS7341 module, drawn at its real size.

Download AS7341 Spectral Sensor Library for Proteus Simulation

Click the button below to download AS7341-Spectral-Sensor-Library-for-Proteus-v1.0.zip (about 1.6 MB, without the source code of the models):

AS7341 Spectral Sensor Library for Proteus V1.0
  • README.txt: installation, the demo, the wiring, troubleshooting and the limits of the simulation.
  • Proteus Library Files: TEPAS7341.LIB, TEPOLED12864.LIB and ArduinoV4TEP.LIB.
  • Proteus Model Files: TEPAS7341.DLL, TEPOLED.DLL and TEPARDUINO.DLL.
  • Arduino Code: the demo sketch.
  • Proteus Simulation: the demo project, its HEX file and copies of the DLLs.

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install AS7341 Spectral Sensor Library for Proteus Simulation

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
  3. Copy the files from Proteus Model Files into the MODELS folder.
  4. Delete TEPAS7341.IDX from the LIBRARY folder if it is there.
  5. Start Proteus, press P and search for AS7341.

Proteus Simulation of a Light-Source Identifier

Our demo answers a question an RGB sensor cannot: what kind of light is this? U1 is the AS7341 with PROFILE DEMO: daylight at the start, then a warm bulb at 4 seconds, a white LED at 8, a fluorescent tube at 12, a grow light at 16, the dark at 20 and daylight again at 24. Its SCL and SDA go to A5 and A4 of our Arduino UNO Library for Proteus V4.0. OLED1 is a 128 x 64 yellow-and-blue display from our OLED SSD1306 Library for Proteus on the same I2C bus at 0x3C. The Arduino's built-in monitor is the same window as our TEP Serial Monitor Advance for Proteus. Open AS7341-Spectral-ArduinoUnoV4.pdsprj.

Figure: The whole simulation on an A4 sheet.

The Sketch

The sketch uses plain Wire calls, no library. For each half of the spectrum it turns the measurement off, sets CFG6 to "write the SMUX":

  wr(0xAF, 0x10);                                           // CFG6: SMUX_CMD = 2 (write the RAM into the SMUX)

then writes the 20 bytes of the SMUX table into 0x00 - 0x13 in one transaction, sets SMUXEN and waits for the chip to clear it:

  for (byte n = 0; n < 50 && (rd(0x80) & 0x10); n++) delay(1);   // SMUXEN clears when it is done

Then it switches the measurement on and waits for AVALID before reading ASTATUS and the twelve data bytes behind it:

  while (!(rd(0xA3) & 0x40)) { if (millis() - t0 > 500) return false; delay(2); }   // STATUS2 bit 6: AVALID

With both halves read, it looks at the shape of the spectrum. Light from the sun or a hot filament carries a lot of near-infrared; an LED or a fluorescent tube carries almost none. A filament rises steadily towards red, so its F8 is far above its F2:

  if (nir > mean * 9 / 10) return f[7] > 2UL * f[1] ? "WARM BULB" : "DAYLIGHT";   // sunlight and hot filaments glow in the infrared

Without near-infrared, strong red and blue with little green is a grow light, a green peak at F5 is the mercury line of a fluorescent tube, and a blue spike at F2 with a dip at F3 is a white LED. The OLED shows the name in its yellow band and F1 - F8 and NIR as nine bars, drawn column by column without a frame buffer.

AS7341 Simulation Results

Open the project and press Run. The demo runs 26 simulated seconds and took 208 seconds on our PC with the pop-up open and the pictures being taken. Every number below comes from one simulation run, the demo exactly as it ships.

Daylight

The sketch finds the AS7341 (ID 0x24), sets the integration to 50 ms and the gain to 16x, and starts measuring - about 6 spectra a second, two measurements each. Under daylight the eight bands are almost level - from 5779 counts at F8 (680 nm) to 7228 at F3 (480 nm) - and the near-infrared is high too, 7179: DAYLIGHT. Nothing comes near the full scale of 18000.

Figure: Daylight: a flat spectrum.

A Warm Bulb

At 4 seconds a warm bulb takes over. The bands now climb steadily, from 343 counts at F1 to 3657 at F8 - the curve of a hot filament - and the near-infrared, 8673, is the largest number of all. The sketch names it WARM BULB, the OLED draws a staircase rising to the right, and the diffuser on the module glows amber.

Figure: A warm bulb: rising towards red.
Figure: The OLED: WARM BULB.
Figure: The simulation in the workspace.

A White LED and a Fluorescent Tube

A white LED is a blue chip under a yellow phosphor, and the AS7341 sees exactly that: F2 jumps to 5781 while F3 dips to 2017, a second hump follows around F5 and F6, and the near-infrared falls to 116 - WHITE LED. The fluorescent tube that follows has a different signature: the green line of mercury makes F5 the highest band, 6498, more than twice F4 (2599) and well above F6 (3247), with a second peak at F7 from the red phosphor - FLUORESCENT.

Figure: The OLED: WHITE LED.

A Grow Light and the Dark

The grow light is red and blue LEDs - the colours plants use most: F2 at 5036 and F8 at 4022, with the green bands between them down at about 250 - GROW LIGHT. Then the light goes out: every channel falls below 10, the sketch says DARK and the OLED's bars lie flat. At 24 seconds daylight returns, and the readings match the first ones within a few counts.

Figure: A grow light: red and blue.

The Graphs, the Event Log and the Check Page

The Graphs page plots the blue (F2), green (F5), red (F8) and near-infrared channels over time - each change of light a step. The Event log keeps the register writes, the SMUX maps and each change of the light. The Check page sums up the run: 311 measurements of 50 ms at 16x gain, the SMUX rewritten before every one of them, none saturated; 8692 reads and no NACK.

Figure: The Graphs page.
Figure: The Event log.
Figure: The Check page.

The monitor shows the sketch's side: the ID, and one line each time the light changes, with its name and all ten channels.

Figure: The monitor.

Why the Near-Infrared Channel Matters

Our eyes cannot see 910 nm, but it is the easiest clue to where light comes from. Anything hot glows strongly in the infrared - the sun, a candle, a filament bulb - while LEDs and fluorescent tubes make light without heat and give almost none. In our run the warm bulb's NIR is the largest number of all, and the white LED's is close to zero. For single-number light levels, our BH1750 Light Sensor Library for Proteus measures lux and our Photodiode Library for Proteus shows how a bare photodiode responds.

Try It Yourself

  • Click Fluorescent or Grow light in the pop-up at any time: the OLED changes within a fraction of a second.
  • Raise the gain in the sketch from 16x to 64x (CFG1 = 7): the daylight channels hit full scale and ASAT is set.
  • Write the F5-F8 table in both passes: F1 - F4 now read the wrong bands - the SMUX decides everything.
  • Switch the white LED on in register bank 1 (CFG0 bit 4, then 0x74 = 0x80 | drive) and set the light to Dark: the sensor now sees its own LED.
  • Set the module's LUX to 5000 for daylight: lower ATIME or the gain to stay below full scale.

Ideas to Extend the Demo

  • Check a grow light: compare the red and blue bands with the green to see how much of the light a plant can use.
  • Measure the colour of objects: switch the white LED on and hold a card in front of the sensor.
  • Log the spectrum of daylight through the day to the serial monitor and plot it.

Your Own Sketches

The demo sketch is in the zip file, and you can change it in the Arduino IDE. New to Arduino? Start with our Arduino Tutorial for Beginners. Export the compiled binary, and set the UNO's PROGRAM property to the new file. Our guide on How to get the HEX file from Arduino shows you where the file ends up.

Things to Know Before Using a Real AS7341

  • 1.8 V: the bare chip runs at 1.8 V; on a 5 V board use a module with a regulator and a level shifter, as ours.
  • The SMUX: turn SP_EN off before changing it, and wait for SMUXEN to clear before measuring again.
  • Saturation: watch ASAT and lower the gain or the integration in bright light.
  • Raw counts: the channels are not calibrated in watts or lux; compare ratios, or calibrate against a known light.
  • A diffuser in front of the sensor makes the reading independent of the angle of the light.

Troubleshooting

  • The ID is not 0x24: check SDA, SCL and VIN; the sensor answers at 0x39.
  • AVALID never comes: SP_EN is off, or PON is 0.
  • F5 - F8 look like F1 - F4: the SMUX was not rewritten - SP_EN off, CFG6 = 0x10, the 20 bytes, SMUXEN.
  • All channels are the same and high: saturation - lower the gain or ATIME / ASTEP.
  • The part is not simulated: TEPAS7341.DLL is missing from MODELS and from the project folder.

Limitations of the Simulation

  • The registers, their addresses, the SMUX RAM and its commands, the integration time and the gains follow the maker's register map; the module is our own drawing of an AS7341 breakout.
  • Our own choices: the counts - each channel the light's relative power in its band x 0.05 x lux x the gain x the integration steps / 1000 - the spectra of the six lights, the white LED reflected by a 50 % white surface, the ROM's SMUX map taken as the F1-F4 split, and the timing.
  • Not modelled: flicker detection, the FIFO, the automatic gain control, the interrupt persistence and the exact filter curves of the photodiodes.
  • Arduino is a name of Arduino; this library is not made or endorsed by Arduino, Labcenter or the maker of the AS7341.
  • Tested in Proteus 8.5 in November 2026 (the demo as shipped). Proteus 7 is not supported.

So, that was all about the AS7341 Spectral Sensor Library for Proteus Simulation. I hope it helps you build your light meter, your colour sorter or your grow-light checker before the real sensor arrives - and shows that a spectrometer is a simple thing at heart: a row of filtered photodiodes and a little switch matrix in front of six converters. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!