• Off-the-shelf colour sensors

    Keith04/21/2025 at 13:26 0 comments

    I was pleasantly surprised to find that there are plenty of off-the-shelf colour sensors, so there must be a significant demand for them. Perhaps in cameras, for colour balancing.

    One way to sense light is to apply a charge on the diode's tiny reverse-bias capacitance, and measure  how long the photocurrent takes to discharge it. Or measure how long it takes for the photodiode to charge up a small capacitor. This does not take very long, so a way round this is to set up a circuit to do either process repeatedly, and measure the frequency.

    RGB Light to Frequency converters like the TCS230 and TCS3200 still need the inconvenience of having to measure the frequency. 

    Some sensors include A to D converters with I2C output, which is easy to integrate into systems.

    BH1745 (16-bits resolution)

    TCS34725 (16 bits resolution)

    ISL29125 (16-bit resolution)

    OPT4048 (20-bits resolution, or 26 bits if you include programmable ranges)

    I had a look for sensor modules I can buy on eBay or Amazon, and there are plenty. The most convenient to buy is the Pimoroni BH1745 module in the Raspberry Pi Shop in town. It is the only type they have, so I bought one for £11. It is more expensive the the £6.50 ones I can buy on eBay but I want something to play with now. The BH1745 is obsolete, but there seems plenty of chips in stock and it is not that hard to read three ADC values from some other colour sensor.

    The module has two white LEDs, so that you can illuminate items. I don't need them if I am sensing a LED on a user interface, so I could buy modules without LEDs that are about half the price.

    Pimoroni have a Python library for it.

  • Researching RGB LEDs as colour sensors

    Keith04/13/2025 at 23:19 0 comments

    Like scientific research papers, the first thing to do is to check what is already known.

    RGB LEDs should already have their own spectral response curves, presumably matching their emission curves.

    This project is mostly for my own curiosity really. Are the response curves well separated or not? I suspect the answer is 'not'. The normal human eye is pretty good at telling colours apart, unless you have some form of colour blindness. The human red and green response curves overlap a lot, so sensitivity defects lead to red-green colour-blindness (the most common type). If the LED spectra do the same, then they may be hard to tell apart. A better metric for distinguishing the two might be the difference between the two primary colours.

    A typical photodiode amplifier circuit will work with an LED. It looks like this:

    NB the cathode is indicated by the flattened part of the rim, so the diagram above is a bit misleading.

    The cathode is the 'sensing' end, so an RGB LED must be common anode, not common cathode.

    The 'common' terminal of multi-coloured LEDs is not guaranteed to be at on end or the other. In fact it is usually one of the inner leads. In this case the flat indicates a nominal 'pin 1'. In the LEDs I bought, pins 1 to 4 are red, anode, green and blue respectively. There is no agreed convention for multi-colour LEDs, so you should check the LEDs you receive.

    The op-amp output has to go to zero, so it needs a negative supply rail as well as a positive one. This is not usually available in a logic-based system having only +5V or +3.3V rails.

    I have many TL074 chips available. These contain four FET-input op-amps, so one chip can serve the three RGB LEDs and have one spare. The last could be used to generate a floating ground.

    The first thing I wanted to to do was find their response, and if it overlapped other colours, and by how much. Fortunately, someone else has done this and in a much more scientific way.

    https://hackaday.io/project/167816/logs

    It looks like LEDs are generally fairly insensitive to wavelengths longer than the own emission colour, but are sensitive to shorter wavelengths. There is no sharp peak. And indirect-band-gap LEDs are not sensitive to their own colour.

    So it looks like like LEDs are not the colour-specific sensor I had hoped for, and I shall discontinue this line of investigation.