Hello friends, I hope you all are doing great. Today, I am going to share the AS7341 Grow Light Meter on Raspberry Pi 5 - Proteus Simulation, the eightieth project of our IoT Projects series. If you have searched for an AS7341 spectral sensor with a Raspberry Pi, how to measure a grow light, what PPFD and DLI mean, or a light spectrum analyser in a Proteus simulation, here is a complete one. A lux meter measures light the way a human eye sees it, most sensitive to green. A plant sees light very differently: it counts photons between 400 and 700 nm, and it cares about their colour. Blue keeps a seedling compact and leafy, red drives flowering.
This Raspberry Pi 5 turns an AS7341, a sensor with eight colour channels across the visible spectrum plus clear and near-infrared, into a grow-light meter. It reads the whole spectrum with automatic gain, works out the blue, green and red shares and the red-to-blue ratio, estimates PPFD (the photons a plant can use) and the daily light integral, recognises the type of light, and draws the spectrum as coloured bars on a 1.8" TFT. In this tutorial, we will go through the circuit, light for plants, PPFD and DLI, how a multi-channel spectral sensor works with its SMUX, auto-gain, and identifying a light from its spectrum. Then we measure six lights in the simulation. At the end, you can download the project with the program and every library file.
NOTICE: Our team has put a lot of effort into this project: the circuit, the code and every part in the simulation are our own work, and you get them all free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below. And if our free projects help you, you can buy us a coffee. So, let's get started with the AS7341 grow light meter on Raspberry Pi 5 in Proteus simulation:
What Does This Grow Light Meter Do?
- Reads the spectrum: eight bands from 415 to 680 nm, plus clear and near-infrared, from an AS7341 on the Pi's I2C bus.
- Keeps the readings in range: auto-gain from 0.5x to 512x, for a dim room or a bright grow tent.
- Splits the light: the blue, green and red shares and the red-to-blue ratio.
- Counts photons: PPFD in umol/m2/s and the daily light integral for a 16-hour day.
- Names the light: daylight, a warm bulb, a white LED, a fluorescent tube or a grow light, from the shape of its spectrum.
- Shows it all: the ten channels as coloured bars on a TFT, and a dashboard with the same bars on a laptop or a phone.
It is a great project for learning light measurement, a sensor with an internal multiplexer and some plant science in one go. In the simulation, the AS7341's pop-up shows the true spectrum of each light from 380 to 950 nm and the channels as bars, with buttons to change the light, so every reading the Pi makes can be checked.
Components Used in the Proteus Simulation
All the parts come from our Proteus libraries, each with its own tutorial. The project zip at the end includes every LIB and DLL file and the TEP Pi runtime.
| Part | Proteus device | Library post | Connection |
|---|---|---|---|
| Raspberry Pi 5 | RASPBERRY PI 5 | Raspberry Pi 5 Library for Proteus | PI1, spectrum_meter.py, Ethernet 192.168.1.51 |
| AS7341 spectral sensor | AS7341TEP | AS7341 Spectral Sensor Library for Proteus | U1, I2C1 at 0x39, VIN from the 5V pin |
| TFT 1.8" ST7735 | TFT18ST7735ADVTEP | TFT ST7735 Library for Proteus | TFT1 on SPI0, A0 GPIO25, RESET GPIO24 |
| Laptop WiFi Monitor | LAPTOP WIFI MONITOR | Laptop WiFi Monitor | PC1 |
| Mobile WiFi Monitor | MOBILE WIFI MONITOR | Mobile WiFi Monitor | MOB1 |
Proteus Simulation of the Grow Light Meter: the Circuit
| Part pin | Raspberry Pi 5 | Signal |
|---|---|---|
| AS7341 SDA / SCL | GPIO2 (pin 3) / GPIO3 (pin 5) | I2C1, the sensor at 0x39 |
| AS7341 VIN / GND | 5V (pin 2) / GND | the module makes its own 3.3 V |
| TFT SDA / SCK / CS | GPIO10 (pin 19) / GPIO11 (pin 23) / GPIO8 (pin 24) | SPI0: MOSI, SCLK, CE0 |
| TFT A0 / RESET | GPIO25 (pin 22) / GPIO24 (pin 18) | command or data; reset |
| TFT VCC / LED | 3.3 V (pin 1) | the logic and the backlight |
The circuit is just three parts. The AS7341 module has its own regulator and level shifter, so it takes 5 V from the Pi while its I2C lines work at 3.3 V. The TFT sits on the SPI bus with two more pins, A0 for command or data and RESET. The sensor's INT pin is not needed: the Pi waits for each measurement by reading a status bit.
How the Grow Light Meter Works
Light for Plants: PAR, PPFD and DLI
Photosynthesis uses light between 400 and 700 nm, called PAR, photosynthetically active radiation. What matters to the plant is the number of photons, not their energy: one photon drives one step of photosynthesis whatever its colour. So growers measure PPFD, the photosynthetic photon flux density: micromoles of photons per square metre per second. And because a plant integrates light over the day, they also use the DLI, the daily light integral: PPFD times the seconds of light, in moles per square metre per day. Worked example: 200 umol/m2/s for a 16-hour day is 200 x 16 x 3600 / 1,000,000 = 11.5 mol/m2/day, about right for lettuce; tomatoes want 20 to 30.
Why Lux Is Not Enough
Lux is weighted by the human eye, which peaks in the green at 555 nm and hardly sees deep blue or deep red. A plant uses exactly those colours most. And a red photon carries less energy than a blue one (the energy of a photon is h x c / wavelength), so for the same light power a red light delivers more photons. Two lamps with the same lux can give a plant very different amounts of light. The conversion depends on the spectrum: sunlight gives about 0.0185 umol/m2/s per lux, a warm white LED less, a red-and-blue grow light far more. That is why this meter looks at the spectrum instead of the brightness.
Inside the AS7341
The AS7341 has eight photodiodes under narrow filters, F1 to F8, centred on 415, 445, 480, 515, 555, 590, 630 and 680 nm, plus a clear photodiode that sees everything and an NIR one at 910 nm. But it has only six analogue-to-digital converters. A configurable switch matrix, the SMUX, decides which photodiode feeds which ADC. So a full spectrum takes two measurements: first F1 to F4 plus Clear and NIR, then F5 to F8 plus Clear and NIR. To change the SMUX, the Pi turns the measurement off, writes 20 bytes of SMUX configuration, one nibble per photodiode, gives the SMUX command and waits until it clears. Each measurement integrates for (ATIME + 1) x (ASTEP + 1) x 2.78 microseconds: with ATIME 29 and ASTEP 599, 30 x 600 x 2.78 us = 50 ms, and the full scale is 30 x 600 = 18000 counts.
Auto-Gain
The light under a grow lamp can be a thousand times stronger than in a dim room. The AS7341's gain goes from 0.5x to 512x in eleven steps, each doubling the counts. After each spectrum the Pi checks the strongest channel: above 90 % of full scale it lowers the gain one step and measures again, below 10 % it raises it. Every count is then divided by the gain, so the numbers stay on one scale whatever the gain. Worked example: a channel reading 6089 at 16x is 6089 / 16 = 380.6 counts per unit of gain; the same light at 32x would read about 12178, the same 380.6 after the division.
From Counts to Shares, PPFD and a Name
The blue share is F1 to F3 (400 to 500 nm) over all eight bands, green F4 to F6 (500 to 600 nm), red F7 and F8 (600 to 700 nm), and R:B is red over blue: above 2 the program calls the light red-rich (it favours flowering), under 0.9 blue-rich (compact, leafy growth), in between balanced. For PPFD, each band's reading is multiplied by its wavelength, which turns energy into a relative photon count, and the sum is scaled by one calibration: at the start the light is daylight at 500 lux, which is about 9.25 umol/m2/s. A real meter is calibrated the same way, against a reference quantum sensor, and applies the responsivity of each channel; this project uses the raw shares of the sensor's channels. The light's name comes from the shape of its spectrum: daylight and a hot filament glow in the near-infrared, a warm bulb more in the red than the blue; a white LED has a sharp blue peak at 445 nm from its blue chip; a fluorescent tube has a strong green mercury line near 546 nm; a grow light is red and blue with little green.
Reading the Numbers for Your Plants
The meter gives PPFD and DLI; what a plant needs depends on the crop. Typical daily light integrals are 8 to 12 mol/m2/day for seedlings and herbs, 12 to 17 for lettuce and leafy greens, and 20 to 30 for tomatoes, peppers and other fruiting plants. To turn a DLI target into the PPFD a lamp must give, divide by the seconds of light. Worked example: lettuce wanting 14 mol/m2/day under a 16-hour photoperiod needs 14,000,000 / (16 x 3600) = 243 umol/m2/s at the leaves. A sunny windowsill in winter may give 2 to 5 mol/m2/day, which is why indoor herbs grow leggy without a lamp. PPFD falls quickly with distance from a lamp, so measure at the height of the leaves, and in several spots, since the edges of a tray get much less than the middle.
The Python Code Explained
The program is spectrum_meter.py, written for Raspberry Pi OS with lgpio for the GPIO and I2C and spidev for the SPI bus. The integration time and full scale:
self.wr(0xCA, 0x57); self.wr(0xCB, 0x02) # ASTEP 599: 30 x 600 x 2.78 us = 50 ms, full scale 18000
Changing the SMUX: the 20 configuration bytes, then the command:
self.wr(0xAF, 0x10) # CFG6: SMUX_CMD = 2, write the RAM into the SMUX
lgpio.i2c_write_i2c_block_data(self.h, 0x00, table) # the SMUX RAM 0x00 - 0x13, one nibble a photodiode (ADC + 1)
Waiting for a measurement to be ready:
while not lgpio.i2c_read_byte_data(self.h, 0xA3) & 0x40: # STATUS2 bit 6: AVALID
Auto-gain, and the counts divided by the gain:
if top > 0.9 * FULL and self.gain > 0:
basic = [v / GAINS[g] for v in raw] # counts per unit of gain: one scale whatever the gain
The shares of the spectrum:
blue, green, red = sum(f[0:3]) / total, sum(f[3:6]) / total, sum(f[6:8]) / total
Photons: each band weighted by its wavelength, the one-point calibration, and the DLI:
return sum(v * lam for v, lam in zip(f, BANDS))
cal['k'] = PPFD_K / photons(f) # (the start is daylight at 500 lux: 9.25 umol/m2/s)
dli = ppfd * PHOTOPERIOD_H * 3600 / 1e6
Two of the rules that name the light:
return 'WARM BULB' if f[7] > 2 * f[1] else 'DAYLIGHT' # sunlight and hot filaments glow in the infrared
if f[4] > 1.6 * max(f[3], f[5]):
The TFT shows the light's name in its own colour, the ten channels as bars in the colours they measure (Clear in white, NIR in dark red), and PPFD and R:B below. The bars are redrawn only when one moves by 3 pixels, so the noise of the readings does not keep the SPI bus busy. The dashboard's pages are / (the numbers and the advice), /spectrum.bmp (the bars) and /data (JSON).
How to Run the Proteus Simulation
- Download the project zip below and install the library files (the steps are under the download button).
- Open Pi-5-Spectrum-Meter.pdsprj from the Proteus Simulation folder. Keep spectrum_meter.py and the DLL files next to it.
- Press Play. The start is daylight at 500 lux, and the PPFD is calibrated on it.
- Click U1 for the sensor's pop-up and change the light: Warm bulb, White LED, Fluorescent, Grow light, Dark.
- Watch the TFT, and the dashboard on the Laptop WiFi Monitor (press Go).
Simulation Results: the Grow Light Meter in Proteus
We ran the meter under six lights, one after another from the AS7341's pop-up, with the TFT, the dashboard and the program's output watching. The times below are the program's. The whole run took 63 simulated seconds, and the Pi read a full spectrum, both SMUX halves, once a second.
Daylight: the Calibration
At the start the light is daylight at 500 lux. The Pi found the sensor (ID 0x24) and measured at gain 16x: F1 to F8 read 6089, 7198, 7197, 6844, 6873, 6479, 6108 and 5764, Clear 5971 and NIR 7212. That is a flat spectrum with plenty of near-infrared, so the program named it DAYLIGHT: blue 39 %, green 38 %, red 23 %, R:B 0.58, blue-rich. On this first daylight reading the PPFD was calibrated to 9.25 umol/m2/s, giving a DLI of 0.53 mol/m2/day for a 16-hour day, far too little for vegetables, as you would expect from a dim room.
A Warm Bulb, a White LED and a Fluorescent Tube
Each chip on the pop-up changes the light and its brightness. In the model each light is a stored spectrum scaled by a brightness setting (the pop-up's Brightness tile), so the PPFD values compare these lamps as the model sets them, not lamps of equal lux.
- Warm bulb, 13.2 s: NIR 8673 and F8 3674 against F2 563, a spectrum rising towards the red and glowing in the infrared. WARM BULB: red 48 %, blue 13 %, R:B 3.78, red-rich, PPFD 2.7.
- White LED, 22.2 s: F2 5757, the sharp peak of the blue chip at 445 nm, and almost no infrared (NIR 117). WHITE LED: R:B 0.47, PPFD 3.9.
- Fluorescent tube, 28.2 s: F5 6487, the green mercury line, standing out above its neighbours. FLUORESCENT: green 49 %, R:B 0.82, PPFD 4.5.
The Grow Light
At 34.2 s the light became a red-and-blue grow light. F2 read 5034 and F8 4019, while the green bands F4 to F6 fell to about 255. GROW LIGHT: blue 47 %, green 6 %, red 47 %, R:B 1.00, balanced: growth and flowering, PPFD 2.6. Almost all its light is in the two bands chlorophyll absorbs best, which is why grow lights look pink to us and why lux, built on our green-loving eyes, underrates them.
Darkness and the Auto-Gain
Then the Dark chip. At gain 16x the strongest channel fell to 8 counts, far under 10 % of full scale, so the auto-gain stepped up: 32x, 64x, 128x, 256x and 512x within half a second (46.2 to 46.6 s). Even at 512x every channel read only about 140 counts, the same in every band: the sensor's own noise floor. The program named it DARK, set PPFD to 0 and drew no bars, since shares of noise mean nothing.
Six lights, every one named right from the shape of its spectrum alone.
Download the Project Files
Click the button below to download AS7341-Grow-Light-Meter-Raspberry-Pi-5-Proteus-Simulation-v1.0.zip (about 13.4 MB, without the source code of the models):
AS7341 Grow Light Meter on Raspberry Pi 5 - Proteus Simulation V1.0- Proteus Simulation: Pi-5-Spectrum-Meter.pdsprj, spectrum_meter.py and copies of the models.
- Python Code: spectrum_meter.py, the program.
- Proteus Library Files: the LIB files of every part.
- Proteus Model Files: the DLL models and the TEPPi folder (the Python runtime of the simulated Pi).
- README.txt: the installation steps, the properties, the test results and the links to every library post.
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 the Project Files
- Close Proteus and extract the whole zip file, for example to your Desktop.
- Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
- Copy everything from Proteus Model Files, the DLL files and the TEPPi folder, into the MODELS folder.
- Start Proteus and open the project from the Proteus Simulation folder.
Changing the Code
spectrum_meter.py is plain Python: edit it next to the project and press Play again. The integration time (ATIME, ASTEP), the calibration (PPFD_K), the photoperiod for the DLI and the rules that name the light are near the top. On a real Raspberry Pi the same file runs with python3-lgpio and python3-spidev installed and I2C and SPI enabled in raspi-config.
Ideas to Extend the Project
- Calibrate properly: measure the same lamp with a reference quantum sensor and fit a factor per channel.
- Log the PPFD all day and add up the real DLI instead of the 16-hour estimate.
- Switch a grow light on through a relay when the daylight DLI falls short of the crop's target.
- Add a far-red sensor or a 730 nm channel to measure the red to far-red ratio, which steers stretching and flowering.
- Measure the colour of leaves with the AS7341's own white LED, as a simple plant-health indicator.
- Compare lamps: the umol per watt (efficacy) of each grow light with a power meter beside the sensor.
From Simulation to Real Hardware
- Use a diffuser: a cosine-corrected diffuser over the sensor so that light from the side counts as it should.
- Calibrate against a reference: the raw channel counts are not PPFD until they are calibrated for the sensor and its cover.
- Watch the temperature: under a hot lamp the readings drift; keep the sensor out of the direct heat.
- Mind the flicker: some LED drivers flicker at 100 Hz or more; an integration time that is a multiple of 10 ms averages it out.
- Keep the 3.3 V logic: the AS7341 breakout and the TFT both work at 3.3 V on the Pi's pins.
Troubleshooting
- No measurement, AVALID never comes: enable the measurement (ENABLE = 0x03) only after the SMUX command has finished.
- Every channel reads 18000: saturated; the auto-gain steps down by itself, and in very bright light a shorter integration helps.
- The PPFD stays 0: the calibration needs one daylight reading at the start.
- The light is named wrongly: the rules compare channel ratios; a light with an unusual spectrum may need its own rule.
- The TFT stays black: check CS, RESET, A0, SDA and SCK on pins 24, 18, 22, 19 and 23, and VCC and LED on 3.3 V.
Limitations of the Simulation
- The sensor is our library's model: each light is a stored spectrum folded through the channels' filters, without the noise, temperature drift and angle effects of a real sensor.
- The PPFD is a one-point calibration on daylight, and the shares use the raw channel counts; a real meter applies each channel's responsivity.
- The network to the laptop and the phone is simulated inside Proteus.
- Raspberry Pi is a trademark of Raspberry Pi Ltd and AS7341 a product of ams OSRAM; this project is not made or endorsed by them or by Labcenter.
So, that was all about the AS7341 Grow Light Meter on Raspberry Pi 5 - Proteus Simulation. I hope it helps you understand why plants need photons rather than lux, what PPFD and DLI mean, how a spectral sensor with fewer ADCs than channels reads a whole spectrum, and how the shape of a spectrum tells one lamp from another, all tested in a simulation before you buy a single grow light. More projects with the Raspberry Pi 5 and the ESP32 are coming. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!