Arduino PAR and LUX Meters

Discuss garden automation systems and software here, including commercial products or Raspberry Pi and Arduino DIY setups.
avfv
LED-Curious
LED-Curious
Reactions:
Posts: 4
Joined: Sat Feb 06, 2021 12:43 pm

PeteR_1, thanks for your feedback.

The raw responses from TCS34725 and TCS34715FN for different wavelengths are very close:
tcs34725_sensivity.png
tcs34715fn_sensivity.png
the difference is constant multiplier 1.7

The old versions of MultispeQ firmware (0_9) used Adafruit_TCS34725::calculateLux function to calculate light intensity:
illuminance = (-0.32466F * r) + (1.57837F * g) + (-0.73191F * b);
and report light intensity in Lux, not umol/m2/s

I mean the error in MultispeQ PAR equation came from this early version.

Last version do this:
lux_local = TCS3471.readCData(); // take 3 measurements, outputs in format - = 65535 or whatever 16 bits is.
r_local = TCS3471.readRData();
g_local = TCS3471.readGData();
b_local = TCS3471.readBData();

lux_average_forpar += lux_local / averages;
r_average_forpar += r_local / averages;
g_average_forpar += g_local / averages;
b_average_forpar += b_local / averages;

Serial_Print("\"light_intensity\":");
Serial_Print_Float(lux_to_uE(lux_average_forpar),2);
Serial_Print(",");
Serial_Print("\"r\":");
Serial_Print_Float(lux_to_uE(r_average_forpar),2);
Serial_Print(",");
Serial_Print("\"g\":");
Serial_Print_Float(lux_to_uE(g_average_forpar),2);
Serial_Print(",");
Serial_Print("\"b\":");
Serial_Print_Float(lux_to_uE(b_average_forpar),2);

function lux_to_uE convert raw values to umol/m2/s using calibration multiplier.

The true Lux calculation required all channels data as described in AMS appnote; but PPFD requires only clear channel (rgb may be used for minor correction).
Using Lux is OK for measuring sun, white LEDs or fluorescent tubes; I measure my DIY LED fixtures for reef tank and orchids, with 660nm and 450nm dominant wavelengths, and I need a PAR measurements in umol/m2/s to build it right.

The CCT and blue/red ratio are important for corals and plants, so I will impement it.
PeteR_1
LED Tinker
LED Tinker
Reactions:
Posts: 368
Joined: Sun Jul 05, 2020 1:10 am

A DIY PAR meter with a TCS34725 (I2C) Color Sensor as the PAR Sensor will be reliable when the RGB data values are used for the PAR calculation, but it needs to be calibrated with a Diffusion Lens for a useful PPFD range; ~ 0 - 2250 umol/s/m2.
TCS34725 Sensor, Monitoring Notebook PC and other sensor housings.
TCS34725 Sensor, Monitoring Notebook PC and other sensor housings.
TCS34725 PAR Sensors and Arduino Nano (in enclosure) with USB connection to (old) notebook PC running Windows XP and Hyperterminal.


@avfv
Thanks for the reply...
Those Github Arduino files were helpful initially but did not provide any additional insight as to the actual equations for the required RGB ratios or the "Slope".

TCS34725 Clear Data PAR Calc compared to RGB PAR Calc  1/8" Acrylic Lens
TCS34725 Clear Data PAR Calc compared to RGB PAR Calc 1/8" Acrylic Lens
Did some preliminary calculations and measurements using the TCS34725 Lux (RGB), TCS34715 PAR (RGB) ratio and Clear PAR calculation;
Compared to the RGB Data PAR the Clear Data PAR stops when the "Clear Data" equals / reaches its limit of 65535 (saturation), but the RGB Data PAR continues. Adding Translucent Acrylic Lenses can extend both PAR ranges (Clear and RGB) but they are still limited by the 65535 max with Clear being maxed out much sooner at lower PAR Value (~ half) compared to RGB PAR. A PAR Meter is needed for true calibration but the sensor's Lux measurements were "calibrated" against a Lux Meter and PPFD calculated with Conversion factors (PPF / Lm = 0.014 for 5000K LED and 0.015 for 3000K LED).

TCS34725 with LED removed / cut off with a Flush Cutter Plier.
TCS34725 with LED removed / cut off with a Flush Cutter Plier.
The only electrical modification to the TCS34725 sensors is the removal of the LED with "Flush Cutter Pliers", no de-soldering required. ;)

Prototype TCS34725 PAR Sensors, Enclosures and Waterproof Sensor Housings
Prototype TCS34725 PAR Sensors, Enclosures and Waterproof Sensor Housings
The Original Prototype (left, V1, 100 x 60 x 25mm Enclosure) and several variation of Housings and Waterproof enclosures are shown above. From left to rights are; four Test Sensors V1, V2 and V4 with 3/4" male adapter and Slip Couplings as the sensor housings, the Adapter and Slip Couplings can be easily sealed and waterproofed, V3 is an 1/2" Conduit LB which can hold an Arduino Nano or LGT8F328P or even an STM32 Blue Pill (have 3 on hand). Sensors 1 and 2 are Nano V3 clones, 3 and 4 are LGT8F328P - Nano Clones. The Acrylic Lenses are not permanently installed, for testing purposes, but can be quickly "Crazy Glued" in place. :)

BTW, I'm not a "programmer" and am fairly new to Arduino IDE so the STM Blue Pill is actually beyond my current capability, but have tried the TCS34725 with Arduino IDE and Arduino clones (Uno, Mega, Nano and LGT8F328P - Nano Clone) and they all work as intended.

Code: Select all

23:02:33.748 -> RGBC  : 2610.00 : 2162.00 : 1615.00 : 6395.00 int
23:02:33.795 -> CPAR  : 32.52 umol
23:02:33.842 -> IR    : 0.00 int
23:02:33.842 -> Blue  : 25.29%
23:02:33.842 -> Green : 33.85%
23:02:33.842 -> Red   : 40.86%
23:02:33.888 -> CCT   : 3748.53 K
23:02:33.888 -> LUX   : 1883.56 Lm/m2
23:02:33.935 -> PPFD  : 32.31 umol/s/m2
23:02:33.935 -> ----------------------
23:02:36.923 -> RGBC  : 2610.00 : 2162.00 : 1615.00 : 6394.00 int
23:02:36.966 -> CPAR  : 32.51 umol
23:02:37.013 -> IR    : 0.00 int
23:02:37.013 -> Blue  : 25.29%
23:02:37.013 -> Green : 33.85%
23:02:37.013 -> Red   : 40.86%
23:02:37.060 -> CCT   : 3748.53 K
23:02:37.060 -> LUX   : 1883.56 Lm/m2
23:02:37.108 -> PPFD  : 32.31 umol/s/m2
23:02:37.108 -> ----------------------
RGBC  : 2612.00 : 2163.00 : 1616.00 : 6399.00 int
CPAR  : 32.54 umol
IR    : 0.00 int
Blue  : 25.29%
Green : 33.84%
Red   : 40.87%
CCT   : 3748.18 K
LUX   : 1884.07 Lm/m2
PPFD  : 32.33 umol/s/m2
----------------------
RGBC  : 2611.00 : 2163.00 : 1616.00 : 6398.00 int
CPAR  : 32.53 umol
IR    : 0.00 int
Blue  : 25.29%
Green : 33.85%
Red   : 40.86%
CCT   : 3749.08 K
LUX   : 1883.76 Lm/m2
PPFD  : 32.33 umol/s/m2
----------------------
RGBC  : 2212.00 : 1820.00 : 1353.00 : 5381.00 int
CPAR  : 27.36 umol
IR    : 2.00 int
Blue  : 25.13%
Green : 33.80%
Red   : 41.08%
CCT   : 3721.44 K
LUX   : 1605.67 Lm/m2
PPFD  : 27.27 umol/s/m2
----------------------
RGBC  : 65535.00 : 56566.00 : 42682.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 49624.00 int
Blue  : 25.90%
Green : 34.33%
Red   : 39.77%
CCT   : 3872.40 K
LUX   : 47417.18 Lm/m2
PPFD  : 832.61 umol/s/m2
----------------------
RGBC  : 49386.00 : 40990.00 : 30889.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 27865.00 int
Blue  : 25.47%
Green : 33.80%
Red   : 40.73%
CCT   : 3774.01 K
LUX   : 35041.03 Lm/m2
PPFD  : 612.64 umol/s/m2
----------------------
RGBC  : 53889.00 : 44715.00 : 33701.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 33385.00 int
Blue  : 25.47%
Green : 33.80%
Red   : 40.73%
CCT   : 3773.69 K
LUX   : 38218.34 Lm/m2
PPFD  : 668.40 umol/s/m2
----------------------
RGBC  : 55641.00 : 46166.00 : 34789.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 35530.50 int
Blue  : 25.47%
Green : 33.80%
Red   : 40.73%
CCT   : 3773.17 K
LUX   : 39472.81 Lm/m2
PPFD  : 690.09 umol/s/m2
----------------------
RGBC  : 62463.00 : 51809.00 : 38978.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 43857.50 int
Blue  : 25.43%
Green : 33.81%
Red   : 40.76%
CCT   : 3768.51 K
LUX   : 44454.37 Lm/m2
PPFD  : 774.44 umol/s/m2
----------------------
RGBC  : 58325.00 : 48386.00 : 36427.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 38801.50 int
Blue  : 25.45%
Green : 33.80%
Red   : 40.75%
CCT   : 3770.54 K
LUX   : 41456.33 Lm/m2
PPFD  : 723.26 umol/s/m2
----------------------
RGBC  : 65535.00 : 55090.00 : 41404.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 48247.00 int
Blue  : 25.55%
Green : 34.00%
Red   : 40.45%
CCT   : 3798.10 K
LUX   : 47097.41 Lm/m2
PPFD  : 819.05 umol/s/m2
----------------------
RGBC  : 32179.00 : 26555.00 : 19562.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 6380.50 int
Blue  : 24.98%
Green : 33.92%
Red   : 41.10%
CCT   : 3707.14 K
LUX   : 23823.21 Lm/m2
PPFD  : 397.04 umol/s/m2
----------------------
RGBC  : 7589.00 : 6232.00 : 4506.00 : 18350.00 int
CPAR  : 93.31 umol
IR    : 0.00 int
Blue  : 24.59%
Green : 34.00%
Red   : 41.41%
CCT   : 3653.20 K
LUX   : 5803.62 Lm/m2
PPFD  : 93.22 umol/s/m2
----------------------
RGBC  : 11137.00 : 9175.00 : 6676.00 : 27030.00 int
CPAR  : 137.44 umol
IR    : 0.00 int
Blue  : 24.74%
Green : 34.00%
Red   : 41.27%
CCT   : 3674.88 K
LUX   : 8433.45 Lm/m2
PPFD  : 137.13 umol/s/m2
----------------------
RGBC  : 21783.00 : 18040.00 : 13428.00 : 53350.00 int
CPAR  : 271.27 umol
IR    : 0.00 int
Blue  : 25.22%
Green : 33.88%
Red   : 40.91%
CCT   : 3739.65 K
LUX   : 15831.38 Lm/m2
PPFD  : 269.58 umol/s/m2
----------------------
RGBC  : 48606.00 : 40382.00 : 30455.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 26954.00 int
Blue  : 25.50%
Green : 33.81%
Red   : 40.69%
CCT   : 3778.23 K
LUX   : 34449.29 Lm/m2
PPFD  : 603.36 umol/s/m2
----------------------
RGBC  : 59864.00 : 49744.00 : 37472.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 40772.50 int
Blue  : 25.48%
Green : 33.82%
Red   : 40.70%
CCT   : 3775.88 K
LUX   : 42535.91 Lm/m2
PPFD  : 743.11 umol/s/m2
----------------------
RGBC  : 65535.00 : 57263.00 : 43143.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 50203.00 int
Blue  : 26.00%
Green : 34.51%
Red   : 39.49%
CCT   : 3899.20 K
LUX   : 47906.10 Lm/m2
PPFD  : 838.77 umol/s/m2
----------------------
RGBC  : 59822.00 : 49689.00 : 37443.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 40709.50 int
Blue  : 25.48%
Green : 33.81%
Red   : 40.71%
CCT   : 3775.71 K
LUX   : 42466.87 Lm/m2
PPFD  : 742.43 umol/s/m2
----------------------
RGBC  : 62524.00 : 51937.00 : 39122.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 44024.00 int
Blue  : 25.47%
Green : 33.82%
Red   : 40.71%
CCT   : 3774.96 K
LUX   : 44422.28 Lm/m2
PPFD  : 775.97 umol/s/m2
----------------------
RGBC  : 63543.00 : 52791.00 : 39762.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 45280.50 int
Blue  : 25.47%
Green : 33.82%
Red   : 40.71%
CCT   : 3775.11 K
LUX   : 45157.69 Lm/m2
PPFD  : 788.68 umol/s/m2
----------------------
RGBC  : 63447.00 : 52711.00 : 39700.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 45161.50 int
Blue  : 25.47%
Green : 33.82%
Red   : 40.71%
CCT   : 3774.99 K
LUX   : 45093.48 Lm/m2
PPFD  : 787.49 umol/s/m2
----------------------
RGBC  : 65476.00 : 54412.00 : 40971.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 47662.00 int
Blue  : 25.47%
Green : 33.83%
Red   : 40.70%
CCT   : 3775.07 K
LUX   : 46566.98 Lm/m2
PPFD  : 812.79 umol/s/m2
----------------------
RGBC  : 65376.00 : 54327.00 : 40906.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 47537.00 int
Blue  : 25.47%
Green : 33.83%
Red   : 40.71%
CCT   : 3774.93 K
LUX   : 46497.31 Lm/m2
PPFD  : 811.53 umol/s/m2
----------------------
RGBC  : 65535.00 : 55059.00 : 41445.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 48252.00 int
Blue  : 25.58%
Green : 33.98%
Red   : 40.44%
CCT   : 3800.48 K
LUX   : 46929.81 Lm/m2
PPFD  : 818.88 umol/s/m2
----------------------
RGBC  : 49825.00 : 41380.00 : 31067.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 28368.50 int
Blue  : 25.41%
Green : 33.84%
Red   : 40.75%
CCT   : 3766.62 K
LUX   : 35639.73 Lm/m2
PPFD  : 618.12 umol/s/m2
----------------------
RGBC  : 26888.00 : 22308.00 : 16685.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 173.00 int
Blue  : 25.33%
Green : 33.86%
Red   : 40.81%
CCT   : 3755.25 K
LUX   : 19371.84 Lm/m2
PPFD  : 333.26 umol/s/m2
----------------------
RGBC  : 28774.00 : 23872.00 : 17828.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 2469.50 int
Blue  : 25.30%
Green : 33.87%
Red   : 40.83%
CCT   : 3751.63 K
LUX   : 20793.76 Lm/m2
PPFD  : 356.58 umol/s/m2
----------------------
RGBC  : 29215.00 : 24237.00 : 18087.00 : 65535.00 int
CPAR  : 333.23 umol
IR    : 3002.00 int
Blue  : 25.28%
Green : 33.88%
Red   : 40.84%
CCT   : 3749.77 K
LUX   : 21144.25 Lm/m2
PPFD  : 362.01 umol/s/m2
----------------------
@avfv ,
Just curious about your "Clear Data" PAR Conversion and Calculations, can you please share them? Thanks
My "Clear Data" PAR calculation is [ CPAR = (0.00224 * cdata) * lens_cf ] as shown in the 1st photo of this post, it results in a max reading of 333 umol/s/m2 (CPAR) @ 65535 "Clear Data" as shown in the "Serial Monitor" text above and the RGB PAR maxes out at about 812 umol/s/m2 @ 46,500 Lux, that's with a single 1/8" thick acrylic lens with ~ 44% measured Transparency and "Calibrated" to Lux Meter readings.

TCS34725 Clear Data PAR Calc compared to RGB PAR Calc 3/8" Acrylic Lens
TCS34725 Clear Data PAR Calc compared to RGB PAR Calc 3/8" Acrylic Lens
Note the measured Values with 3/8 inch Acrylic Lens with 6.7115 measured Lens_Cf, maximum range for RGB PAR is now 0 - 2250 umol/s/m2 (PPFD) with CPAR at maximum range of 0 - 985 umol/s/m2 (PPFD)...
avfv
LED-Curious
LED-Curious
Reactions:
Posts: 4
Joined: Sat Feb 06, 2021 12:43 pm

PeteR_1, your builds are very nice!
I perfer STM32 and do not use arduino; the latest STM32CubeIDE very easy to use and work out-of-the-box like arduino IDE, but much more powerful.

My TCS34725 comparison with Apogee MQ-510:

630nm -1.5%
595nm 0
525nm +2%
490nm +5%
450nm 0
420nm -51% !!! UV cut filter installed on TCS34725. It's impossible to correct with rgb channels :(

I use integration time 0xC1 (150ms - this time optimal for flicker rejection and don't reduce upper limit) , 1x gain and calibrate at 450nm - 77 PAR (Apogee) = 9494 counts (clear channel; color channels not used).
But every chip has different response: my second TCS34725 sensor has only 7942 counts on 77 PAR.

I agree, using sum of color channels good for push up upper limit of sensor. I am going to compare clear channel with rgb sum...

I mean, TCS34715 + IR cut filter more suitable for PAR measurement. I test TCS3200 chip, it has no UV filter and similar spectral response - the 420 nm performance of it is perfect, but it has very low upper limit - only 160 PAR.
PeteR_1
LED Tinker
LED Tinker
Reactions:
Posts: 368
Joined: Sun Jul 05, 2020 1:10 am

avfv wrote:
Sun Feb 14, 2021 5:14 pm
PeteR_1, your builds are very nice!
I perfer STM32 and do not use arduino; the latest STM32CubeIDE very easy to use and work out-of-the-box like arduino IDE, but much more powerful.

My TCS34725 comparison with Apogee MQ-510:
630nm -1.5%
595nm 0
525nm +2%
490nm +5%
450nm 0
420nm -51% !!! UV cut filter installed on TCS34725. It's impossible to correct with rgb channels :(

I use integration time 0xC1 (150ms - this time optimal for flicker rejection and don't reduce upper limit) , 1x gain and calibrate at 450nm - 77 PAR (Apogee) = 9494 counts (clear channel; color channels not used). But every chip has different response: my second TCS34725 sensor has only 7942 counts on 77 PAR.

I agree, using sum of color channels good for push up upper limit of sensor. I am going to compare clear channel with rgb sum... I mean, TCS34715 + IR cut filter more suitable for PAR measurement. I test TCS3200 chip, it has no UV filter and similar spectral response - the 420 nm performance of it is perfect, but it has very low upper limit - only 160 PAR.
Thanks for the reply and info... Thanks, I use inexpensive readily available materials to build simply and at low cost while providing accuracy and repeatability. ;)
The plan is to rent an Apogee Meter for final testing of up to a dozen (12) sensors at once, after all the bugs are worked out.

Yes, every sensor would require a Correction Factor (PAR_Coefficient), which in your case is 1.0236820 @ 450nm (2.36820% difference of 65535?).

IMO, if your have the ability to calibrate the Sensor's Slope and offset to match an actual PAR Meter the AMS TSL2561 should work much better as an I2C PAR (only) Sensor for measuring indoor grow lights. It has separate diode for IR which can "eliminate / reject" IR in the PAR equations, has higher UV and Blue responsivity and also appears to be normalized @ ~ 650nm...

Github... https://github.com/ControlEverythingCom ... SL2561.ino

Code: Select all

// TSL2561
// This code is designed to work with the TSL2561_I2CS I2C Mini Module available from ControlEverything.com.

#include<Wire.h>

// TSL2561 I2C address is 0x39(57)
#define Addr 0x39

void setup()
{
  // Initialise I2C communication as MASTER 
  Wire.begin();
  // Initialise serial communication, set baud rate = 9600
  Serial.begin(9600);

  // Starts I2C communication
  Wire.beginTransmission(Addr);
  // Select control register
  Wire.write(0x00 | 0x80);
  // Power ON mode
  Wire.write(0x03);
  // Stop I2C Transmission
  Wire.endTransmission();

  // Starts I2C communication
  Wire.beginTransmission(Addr);
  // Select timing register
  Wire.write(0x01 | 0x80);
  // Nominal integration time = 402ms
  Wire.write(0x02);
  // Stop I2C Transmission
  Wire.endTransmission();
  delay(300);
  
}

void loop()
{ 
  unsigned int data[4];
  for(int i = 0; i < 4; i++)
  {
    // Starts I2C communication
    Wire.beginTransmission(Addr);
    // Select data register
    Wire.write((140 + i));
    // Stop I2C Transmission
    Wire.endTransmission();
    
    // Request 1 byte of data
    Wire.requestFrom(Addr, 1);
    
    // Read 1 bytes of data
    if(Wire.available() == 1)
    {
      data[i] = Wire.read();
     }
     delay(200);
  }
  
  // Convert the data
  double ch0 = ((data[1] & 0xFF) * 256) + (data[0] & 0xFF);
  double ch1 = ((data[3] & 0xFF) * 256) + (data[2] & 0xFF);

  // Output data to serial monitor
  Serial.print("Full Spectrum(IR + Visible) :");
  Serial.println(ch0);
  Serial.print("Infrared Value :");
  Serial.println(ch1);
  Serial.print("Visible Value :");
  Serial.println(ch0-ch1);
}
Image


Image
Photodiode Spectral Response Comparisons of three (3) readily available I2C Light Sensors, highlighted PBAR region...
Last edited by PeteR_1 on Mon Feb 15, 2021 5:04 pm, edited 1 time in total.
User avatar
Salmonetin
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 51
Joined: Wed Jul 15, 2020 5:13 pm

thanks...
Last edited by Salmonetin on Tue Feb 16, 2021 5:36 pm, edited 7 times in total.
PeteR_1
LED Tinker
LED Tinker
Reactions:
Posts: 368
Joined: Sun Jul 05, 2020 1:10 am

Thanks for sharing the links...

Image
TSL2591 will not work as a PAR Sensor because its optimized for Lux (?) Measurements, its missing most of the 400 - 500nm responsivity.
avfv
LED-Curious
LED-Curious
Reactions:
Posts: 4
Joined: Sat Feb 06, 2021 12:43 pm

The TSL2561 is bad for PAR measurement - too much error in yellow-red part - IR diode has significant response in this part of spectrum.
The TSL34725 response looks like response of Apogee 2xx family - bad response in 400-420nm range. But grow light lacks of 420nm light - blue, white and red LEDs don't emit this wavelengths at all.
PeteR_1
LED Tinker
LED Tinker
Reactions:
Posts: 368
Joined: Sun Jul 05, 2020 1:10 am

avfv wrote:
Sun Feb 14, 2021 9:48 pm
The TSL2561 is bad for PAR measurement - too much error in yellow-red part - IR diode has significant response in this part of spectrum.
The TSL34725 response looks like response of Apogee 2xx family - bad response in 400-420nm range. But grow light lacks of 420nm light - blue, white and red LEDs don't emit this wavelengths at all.
TCS34725 PAR Sensors
TCS34725 PAR Sensors
Yes, the TCS34725 has a similar response to the Apogee 100

Image


TSL2561 with highlighted PBAR range compared to SQ-620
TSL2561 with highlighted PBAR range compared to SQ-620
Apogee introduced their new SQ-620 "Extended Range PFD Sensor" for testing current generation of "Enhanced" LED Grow lights, responsivity of the TSL2561 is very close. ;)

I have a few TSL2561 on order, will mount in the same Housings as the TCS34725 and will report the test results.
TCS34725 PAR Sensors Build and Tests
TCS34725 PAR Sensors Build and Tests

Image
https://www.apogeeinstruments.com/exten ... d-sensors/
PeteR_1
LED Tinker
LED Tinker
Reactions:
Posts: 368
Joined: Sun Jul 05, 2020 1:10 am

00schteven wrote:
Wed Jan 20, 2021 5:33 am
My readings with the TCS34725 have been all over the map. With the gain at 1x and integration_time at 700ms over a period of 12 hours my PAR out put ranges from 130 up to 430. Same location, same light, same dimming level. Sometimes the color readings are strange as well, like 95% blue 85% green 12% red. Then the next reading is different.

I feel like I'm missing a peice to the puzzle.
I'm not a programmer but took a look at the Adafruit TCS34725 Github Driver files which appear to be the TCS34725 Driver used for many (most) controller Lux, CCT and RGB calculations and have figured out a possible answer to your erratic measurements.

#1. The AMS TCS34725 Color Sensor was not intended as a "Lux Sensor" for high intensity lights (Grow Lights), the bare sensor has a narrow range of ~ 0 - 8000 Lux, at which point the Clear Channel is "Saturated" (reaches its maximum value of 65535) and stops working, the only way around this is to install a Diffuser Lens of white translucent material (White Translucent Acrylic). Increasing the range to 0 - 150,000 Lux (0 - 2200 PPFD) requires ~ 15% Transparency, its easily measured with a working TCS34725 by taking before and after measurements, without and with the lens. ;)

#2. Your RGB values are probably not in Percentage, its an R-G-B integer of 255 - 255 - 255 and its relative to the Clear Channel which stops working under higher light conditions and throws off the calculations.

#3. The Clear Channel is used in several calculations from Lux to RGB and CCT, when it is saturated or maxed out at 65535 all the equations become invalid / erratic, which happens quickly to a bare sensor under any higher intensity light.

IMO one way around this is to use the AMS equations with the "Raw Data", R-G-B-CData (8 values scaled) and Diffuser Lenses. Currently testing several sensors and all bare sensors have been stable and "close" to actual CCT, RGB and Lux without any Correction factors. All the Arduino ATmega 328P Nanos have measured within 500 Lux, 300K CCT and RGB values (ratios) that reflect the 2700, 3000, 4000 and 5000K LEDs used in the tests.
TCS34725 Sensor LGT8F328P-Clones on left, ATmega328P Nanos on right
TCS34725 Sensor LGT8F328P-Clones on left, ATmega328P Nanos on right
The photo above is @ 7600 Lux with a 3900K CCT Vesta 2750G Grow Light (dimmed).
The sensors are bare, without lenses and do not have any calibration factors / coefficients for Lens or Lux (both @ 1.0).
----------------------------------------------------

TCS34725 (AMS) Lux Calcalations & Coefficients:

R_Coef = 0.136
G_Coef = 1.000
B_Coef = -0.444
CT_Coef = 3810
CT_Offset = 1391
GA* = 1.0 // ( 1.0 = no Glass or Lens Attenuation)
DF = 310

Lux = ((R_Coef * R’) + (G_Coef * G’) + (B_Coef * B’)) / CPL, where:
CPL = (AGAINx * ATIME_ms) / (GA * DF) and:
IR = (R + G + B – C)/2, and
R’ = R – IR, G’ = G – IR, B’ = B – IR
CCT (°K) = CT_Coef * (B’/R’) + CT_Offset
--------------------------------------------------------------

PAR Sensor Coefficients and Equation:

Lens_cf = 1.0 // (1.0 = no lens)
Lux_cf = 1.0 // (1.0 = no offset or correction factor)
PAR_cf = 1.0 // (1.0 = no offset or correction factor)

PPFD = ((clear * 0.65847) + (red * 1.60537 + (green * 2.30216) + (blue * 0.50019)) * 0.001

---------------------------------------------------------------

Code: Select all

// TCS34725 PAR Meter rev-2.1 (2/17/2021)

#include <Wire.h>

#define Addr 0x29            // TCS34725 I2C address is 0x29
#define TCS34725

void setup()
{

  Wire.begin();
  Serial.begin(9600);

  Wire.beginTransmission(Addr);
  Wire.write(0x83);         // WaitTime
  Wire.write(0xFF);         // 0xff = 2.4 ms 
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x81);         // Atime
  Wire.write(0x00);         // 0x00 = 700 ms, max count = 65536
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x8F);        // AGain 
  Wire.write(0x00);        // 0x00 = 1x
  Wire.endTransmission();

  Wire.beginTransmission(Addr);
  Wire.write(0x80);       // Power On, RGBC enable, Wait Time
  Wire.write(0x03);       // 0x03 = Disable
  Wire.endTransmission();
  delay(800);
}

void loop()
{
  unsigned int data[8];

  Wire.beginTransmission(Addr);
  Wire.write(0x94);
  Wire.endTransmission();
  Wire.requestFrom(Addr, 8);

  // cData lsb, cData msb, red lsb, red msb, green lsb, green msb, blue lsb, blue msb
  if (Wire.available() == 8)
 {
    data[0] = Wire.read();
    data[1] = Wire.read();
    data[2] = Wire.read();
    data[3] = Wire.read();
    data[4] = Wire.read();
    data[5] = Wire.read();
    data[6] = Wire.read();
    data[7] = Wire.read();
 }

  // Convert the data
  float cdata = (data[1] * 256.0) + data[0];
  float red = (data[3] * 256.0) + data[2];
  float green = (data[5] * 256.0) + data[4];
  float blue = (data[7] * 256.0) + data[6];
 
  // Calculate the Lux and Lens coefficient or % transperency factor
  float luminance = ((0.136 * red) + (1.000 * green) + (-0.444 * blue)) / 2.258;   //TCS34725 Lux equation rgb =  0.136 ; 1.000 ; -0.444 / (700ms * gain /310 * G_cf)
  float lens_cf = 1.0;           // Lens Coeffecient = Lens_cf ; Acrylite #7328, 1/8" = 2.27 , 44%; 1/4" = 4.0629 , 24.6% ; 3/8" = 6.7115 , 14.89% Transparency
  float lux_cf = 1.0;         // Lux Coefficient, correction factor or Offset; used for calibration with Lux Meter
  float lux = luminance * lens_cf * lux_cf;
  if(lux < 0)
{
  lux = 0;
}
  // Calculate total IR and PAR from CData
  float ir = (red + green + blue - cdata) / 2;    // InfraRed calculation

  // float cpar = (cdata / 419) * lens_cf;    // PPFD using only ClearData measurements
  float cpar = (cdata * 0.00238663) * lens_cf;     // ( /419) = ( * 0.00238663) = CPAR_cf ??
  
  // Calculate the PAR, final PPFD and correction factor - par_cf
  float par = ((cdata * 0.65847) + (red * 1.60537) + (green * 2.30216) + (blue * 0.50019)) * 0.001;    // MultispeQ Beta PAR sensor TCS34715 equation
  float par_cf = 1.0;                         // PAR Correction factor  Default = 1.0 ; Calibrate with Lux * PPF/Lm conversion factors or PPFD
  float ppfd = par * par_cf * lens_cf;            // * Lens Coefficient from Lux Calculations
  if(ppfd < 0)
{
  ppfd = 0;
}
  // Calculate B-G-R Percentages and CCT (Correlated Color Temperature) degrees Kelvin
  float blue_pct = blue / (blue + green + red) * 100;
  float green_pct = green / (blue + green + red) * 100;
  float red_pct = red / (blue + green + red) * 100;  
  float cct = 3810 * (blue / red) + 1391;

  // Output data to serial monitor
  Serial.print("RGBC  : ");
  Serial.print(red, 0);
  Serial.print(" : ");
  Serial.print(green, 0);
  Serial.print(" : ");
  Serial.print(blue, 0);
  Serial.print(" : ");
  Serial.print(cdata, 0);
  Serial.println(" int");
  
  Serial.print("CPAR  : ");
  Serial.print(cpar, 0);
  Serial.println(" umol");  
  Serial.print("IR    : ");
  Serial.print(ir, 0);
  Serial.println(" int");   
  
  Serial.print("Blue  : ");
  Serial.print(blue_pct, 0);
  Serial.println("%");
  Serial.print("Green : ");
  Serial.print(green_pct, 0);
  Serial.println("%");  
  Serial.print("Red   : ");
  Serial.print(red_pct, 0);
  Serial.println("%");
  
  Serial.print("CCT   : ");
  Serial.print(cct, 0);
  Serial.println(" K");  
  Serial.print("LUX   : ");
  Serial.print(lux, 0);
  Serial.println(" Lm/m2"); 
  Serial.print("PPFD  : ");
  Serial.print(ppfd, 0);
  Serial.println(" umol/s/m2");
  Serial.print("---------");
  Serial.println("------------"); 
  delay(3000);
  }
PeteR_1
LED Tinker
LED Tinker
Reactions:
Posts: 368
Joined: Sun Jul 05, 2020 1:10 am

An interesting Peer reviewed article; "New insights into radiative transfer within sea ice derived from autonomous optical propagation measurements"..., the measurement of Photon Flux and Color / wavelengths within and under polar sea ice using PCBs with TCS34725 sensors and I2C multiplexers... :)
https://tc.copernicus.org/articles/15/1 ... -2021.html

Image

https://tc.copernicus.org/articles/15/1 ... 3-2021.pdf
Post Reply