Turning light sensor into color sensor?

I had a terrible experience with the color sensors. I needed a RGB measurement, band by band, at a rough accuracy and repetability. After 2 sensors I gave up.

In this moment I got an idea: why not using a 3 VIS light sensor, each being equipped by a photo color filter?

I am going to experiment this. But the point with the VIS sensors is that they are very sensitive to variations in light (lx). Any experience and ideas, highly appreciated (saves my experiementation time).

Which sensors did you try? Have you tried the AS7262 visible spectrum sensor?

they are very sensitive to variations in light (lx)

That is their designated purpose. What could possibly be the problem with that?

A light sensor changes to much and to rapidly. That is the behavior of a commercial sensor as well. Some averages 10 readings to reduce this variation.

You may download a luxmeter app to a tablet and see for yourself.

Well, not a big problem but something to be considered.

I found sensor accuracy is a matter of marketing. Just as the nomber of pixels in photocameras - nobody needs 16MPx, and sometimes this increases the noise. I always set my camera to 5-9 MPx if I can.

+++

That AS7362 is a Sparkfun Qwiic - very very expensive. And not available in the shops I have access to one year ago.

At the time I tried TCS230 - 2 variants (blue and black). The black one refused to send any data while the blue one was promising but I ran out of time.

In fact a photo sensor (the CMOS one) would do the job, but separation of the bands are a mater of insistent tinkering :-).

falexandru:
It changes to much and to rapidly. That is the behavior of a commercial sensor as well. Some averages 10 readings to reduce this variation.

What are you measuring. Daylight doesn't vary. You can measure/sample that once.
Artificial light is most likely not constant, although your brain sees it as constant light.
You might have to sample your light sensor hundreds, maybe thousands of times to get the right reading.
But what's the problem in doing that.
Leo..

Daylight varies. Very much. Download a luxmeter app to the tablet and see. But I can live with this variation. That is a really complex and difficult measurement. But for my demonstrative purpose, if I can reach 10% error in each RGB band, with some 10-20% instant variation, its wonderful. Even 20% is ok.

The point is whether a VIS light sensor can react to a single filtered color (either, R, G, B) and do measure the intensity of the light of that wave length. Even roughly.

falexandru:
Daylight varies. Very much.

Not when you measure each loop().

A PWM-ed LED turns fully on/off hundreds of times a second.
Daylight doesn't.
Leo..

In a given spot, as per sqmm the light varies. The human doing the measurement modifies his.her position, leaving shades, the curtains move (if indoor) etc. Even more variable shades are present outdoor - thinl to tree branches and leaves in wind.

So the number of lx in that point varies. Now is to late in the night here, so I cant show you what I mean. But I will do something to show you this tomorrow.

Certainly, if one averages the readings it appears more stable. And this is the way I am thinking to solve this out.

But the real point is to measure single-wave light by a common VIS sensor. I am speaking about centered wave length, not about pure color.

A light sensor changes to much and to rapidly.

A decent light sensor, and that would include just about any phototube, photodiode or phototransistor ever made, responds in a completely predictable fashion to the light level it sees.

If the light levels are changing, that is a completely different, real world problem, unrelated to the sensor.

That AS7362 is a Sparkfun Qwiic - very very expensive.

$22 is NOT "very very expensive". Skip a few cups of cappuccino instead.

The hobbyist way to do a colour sensor is to use an RGB led and a light dependent resistor. I've done that and it was fun. I think I reached a "RGB measurement, band by band, at a rough accuracy and repetability".
Perhaps you could describe more in detail how you intend to use your sensor. Are you doing an error at the measuring moment, like expecting the sensor to "see" the colour of an object from a short distance?

@Johan_la

I am attempting to reproduce a satellite VIS sensor :-). (Landsat or Sentinel, which ever you like ;-)) for demonstrative purposes.

Therefore the plan is the following:

4 RGB sensors, placed in the corners of a rectangle at a distance of say - 10 cm each other - shall measure the intensity of light in each centered band.

A RGB sensor is supposed to be made in 3 Vis sensors, each filtering one wave length.

That is a sort of "fingerprint" of the "image" that reached the RGB "matrix".

But i would not venture to this before making sure I can build and operate one sensor alone.

Past summer I attempted do do this by the dedicated color sensors, but it turns more complicated than expected. Also, a color sensor is ment to recognize, well, the color. Not to measure the intensity of light on a given wave length.

I have seen examples of indeed using multiple light sensors each covered with a piece of coloured glass as colour filter. That way only a specific colour (wavelength band) was allowed through. Got decent results. Remember to correct for relative sensitivity of your light sensor for the different colours (check the data sheet).

There are also "colour detectors" that use RGB sensors to record the colour of an object, typically used for colour sorting of objects. That may be yet another avenue.

The AS7262 and AS7263 (red to near IR) are very interesting. I have to look more into them, as I also hope to build an inexpensive PAR sensor that can actually handle LED light and not just known-spectrum lights.

Glass filters are going to be fun. The photo ones are a way to go.

I am considering (near) IR sensors as well. That will result in VIS+IR sensor which is even closer to satellite equipment approach.

I am concerned about having 4 (corners) x 3 (R, G,B) = 12 data flows. Perhaps using I2C is a feasible alternative, but I shall use some I2C slaves to bind the sensors. Not sure about feasibility of this light sensor+I2C group in a reasonable code complexity and components's price.

It all depends on your budget... The AS7262 and AS7263 are just over USD 5 each in volume on Digikey (USD 12 a piece in single quantity - making that USD 22-24 breakout board sound like a really good deal).

The TSL2591 can read the full spectrum including part of IR - it has two channels: one for IR and one for visual + IR, so with appropriate filters you can use this to do RGB+IR sensing. It goes for USD 1.13 in bulk, but you need four of them for each corner so not cheaper. Also the single I2C address is an issue trying to read them.

Then there are RGB sensors, which give output for those three colours, like the ISL29125 but there's a very large overlap between green and red. Blue is much better separated. Prices go down to USD 1.33 in bulk, just over USD 4 in single units, again a fixed I2C address so you need multiplexing somehow to read four of them with a single MCU. I'm sure there are more such sensors. You could combine those with dedicated IR and/or UV sensors for an even larger spectral range.

TSL2591 buys here for 12 USD. It is said "no I2C address possible". Sad.

TSL2561 (Sparkfun one) is cheaper (9USD) and apparently can change I2C address.

The TSL2561 is the old one and can indeed select two I2C addresses. This helps but as you want four sensors you still have a problem. If you use the ESP8266 processor you can simply create two I2C buses. Any two pins can be assigned to I2C.

The TSL2591 is its successor, with a.o. a greater range, but fixed I2C address.

The prices I mentioned are just the sensor - not including PCB as the Sparkfun breakouts, I'm assuming you'll build your own PCB for this application.

Perhaps using a multiplexor?

I can get this one:

I have no experience in using one.

Should work. No experience myself, it looks quite straightforward to use this multiplexer.

Nonetheless, you better first settle on a sensor - get one of them, see if you can get it to detect the colour(s) you want it to. You may end up buying 2-3 different sensors before you have one that's satisfactory. Go from there.

Right. The difficulty I can foresee with the multiplexor is in using the libraries.

It seems that before calling the library to read the sensor you just have to set the mux to the correct sensor. Shouldn't be too hard. Just a single byte command to the mux' I2C address to select which bus you want to connect to.

What colour are you trying to measure? The colour of an object? The colour of a printed card? Where do you place the object if the sensors are 10 cm from each other?