Problem with Adafruit color sensor: readings do not make sen

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Giustiniano
 
Posts: 5
Joined: Thu Feb 12, 2015 12:50 pm

Problem with Adafruit color sensor: readings do not make sen

Post by Giustiniano »

Hello,

I am using a Raspberry Pi 2 with the adafruit color sensor with white led and IR filter. On the first picture, you can see my setup. The red object I am trying to scan is the red cover of a moleskine notebook. With the led on, an integration time of 700 ms and a 60X gain, the readout is red 1401 green 428 blue 291. Considering the light red of the cover, I would have expected red to be in the order of various tens of thousand, since the output is 48 bit RGB.

I think I connected the pins in the right order: considering the LAN socket at the bottom, I connected the first left pin below VIN, the third pin right to GND, the second left pin to SDA and the third left pin to SCL. I then connected the INT pin to the LED pin.

I am using a half size breadboard, like this one http://www.adafruit.com/products/64 and standard jumper wires. The only thing I did NOT do, because I do not have a solder, is soldering the upper part of the pins once the sensor is plugged in the header, as you can see here https://learn.adafruit.com/adafruit-col ... and-wiring Maybe this is the problem?

To program the sensor, I am using Netbeans with Pi4j using the driver graciously made available by adafruit here https://code.google.com/p/raspberry-pi4 ... 34725.java

Any help would really be appreciated.
Attachments
WP_20150303_22_56_50_Pro (Custom).jpg
WP_20150303_22_56_50_Pro (Custom).jpg (66.04 KiB) Viewed 2516 times
WP_20150303_22_56_58_Pro (Custom).jpg
WP_20150303_22_56_58_Pro (Custom).jpg (63.07 KiB) Viewed 2516 times

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Problem with Adafruit color sensor: readings do not make

Post by adafruit_support_bill »

I would have expected red to be in the order of various tens of thousand, since the output is 48 bit RGB.
The red is more than 3 times the green and almost 5 times more than the green. That sounds about right - considering that is is not a particularly saturated red.
Yes, it is a 48 bit RGB value, but it also has a dynamic range of 3.8 billion to one.

User avatar
Giustiniano
 
Posts: 5
Joined: Thu Feb 12, 2015 12:50 pm

Re: Problem with Adafruit color sensor: readings do not make

Post by Giustiniano »

Thank you for your reply.

Forgive my ignorance, but what does it mean to have a dynamic range of 3.8 billion to one?

Thanks

Enrico

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Problem with Adafruit color sensor: readings do not make

Post by adafruit_support_bill »

what does it mean to have a dynamic range of 3.8 billion to one?
That means it can measure light levels ranging from a dimly lit room to bright sunlight.

User avatar
primexandy
 
Posts: 89
Joined: Sat Sep 06, 2014 11:09 am

Re: Problem with Adafruit color sensor: readings do not make

Post by primexandy »

If you take your RGB results, divide the results by 5.6 to make them all fit into 8 bit, turn them to Hex values then look at the HTML colour you get ...

1401 / 5.6 = FA, 428 / 5.6 = 4C and 291 / 5.6 = 34 you get HTML colour #FA4C34 - which is this colour

....which looks correct to me, so the sensor is working excellently :)

User avatar
Chamaeleon
 
Posts: 5
Joined: Sun Jan 13, 2019 6:23 am

Re: Problem with Adafruit color sensor: readings do not make

Post by Chamaeleon »

Dear Adafruit forum,

I just started to setup a small project to measure color of light and illuminate white wall with RGB LED.
My system is Arduino Uno R3 with Adafruit color sensor TCS34725 and Neopixel Ring with 16 LEDs (WS2812).

It is a small prove of concept for my project to illuminate my living room with same color spirit as the TV picture shows. The known TV backlights are not useful in my case because of complete bookshelves behind the TV.

The setup of the system went well in short time using the Adafruit libraries and Arduino development environment.
I deactivated the sensor LED pushing the pin to ground.

I observed some items which I need to solve and ask for help.

- The measured and emitted color is different to the source for each color. The general color is detected correctly. Red is red, green is green and blue is blue. But different and a white balance seems to be necessary.
I used an RGB App on my Android mobile to illuminate the sensor with the edge colors. Also white light with different temperatures. The result is not satisfying, please refer to the photos. I put a paper around the sensor to block light from Neopixel. Is there a possibility to run a white balance?

- How can I use the high dynamic range of the TCS34725 sensor? The sample source read integer values but it seems to be the case that I get an overrun sometimes which leads to totally wrong colors.

- How can I increase the color saturation? All emitted colors seems to be pale.

- Is there a limited cable length for the neo pixel data in? One time I try to use 1.5m cable and colors change randomly. With short wire it works fine. Both with 470 Ohm resistor.

- What are the possible values to get best smoothly result related to integration time of the sensor. After prove of concept I am able to change the SOC and also LED. What will be best an easy to achieve the illumination of my living room? 4 times LED 3W RGB LED - Common Anode (2530) should be sufficient.

Any proposals? Thanks so much!
Attachments
RGB green 255.JPG
RGB green 255.JPG (97.84 KiB) Viewed 2251 times
RGB blue 255.JPG
RGB blue 255.JPG (109.79 KiB) Viewed 2251 times
RGB red 255.JPG
RGB red 255.JPG (122.97 KiB) Viewed 2251 times

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Problem with Adafruit color sensor: readings do not make

Post by adafruit_support_bill »

Color measurement and reproduction is more complex than it may seem at first. And there are several factors that could account for what looks like a blue-shift in your output. In your test, you have removed one variable by using the same white background. But there are still differences in the RGB response curves in the Android screen, TCS34725 and the Neopixels.

One option is to remove the sensor and screen variables from the equation and drive your LEDs based on the video input signal. That is the technique used here:
https://learn.adafruit.com/adalight-diy ... v-lighting

Sticking with the single-sensor approach, you could try to apply some scaling factor to the blue channel to adjust the white-balance. You may find that you need some adjustment on one of the other channels as well for best results.

A third approach would be to use a second sensor for feedback. One would be aimed at the screen and the other at the illuminated wall. You could then adjust the output of your LEDs in real-time to make the color balance match the screen.

User avatar
Chamaeleon
 
Posts: 5
Joined: Sun Jan 13, 2019 6:23 am

Re: Problem with Adafruit color sensor: readings do not make

Post by Chamaeleon »

Dear Bill,
Thank you for your quick answer and proposals.

I saw some diy projects for TV backlight and most of them requires a video signal. But today many sources are TV internal an the video signal is not available. I want to have an independent solution and thought about using a webcam. Due to the fact that I do not need accurate light to continue the picture at the TV edge I thought about changing the camera with a RGB sensor. Sounds more easy :-)
My first try was to measure the white wall beside the TV which reflect the mixed light of all TV colors. This I wanted to reproduce but the RGB light was different. Then I tried to correct the blue and red variables before send them to the LED. But it works only for one color and gets worse for other colors…Maybe I was too impatient and I will try again.

The loopback is a great idea and I think this will work in general. Using Arduino I currently do not know how to interface two sensors at the same time…

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Problem with Adafruit color sensor: readings do not make

Post by adafruit_support_bill »

The i2c address on the TCS34725 is fixed, so to use two of them, you need an i2c multiplexer: https://www.adafruit.com/product/2717
That lets you switch between 8 separate i2c buses.

User avatar
Chamaeleon
 
Posts: 5
Joined: Sun Jan 13, 2019 6:23 am

Re: Problem with Adafruit color sensor: readings do not make

Post by Chamaeleon »

I have done a white balance simply adding red and little green which looks fine :-)
I have done this in front of the TV and a second sensor is not necessary at the moment.
r=r+10;
g=g+2;
using no gain (TCS34725_GAIN_1X)


Now I have to solve the next items.

- I have to scale the balance correction for dark scenario till no light. Otherwise the white balance correction force a red in my case.
- I have to deal with the high dynamic range of the sensor delivering uint16 values and scale it to uint8 for the LED. Overflow of 255 must be avoided which will leads to wrong colors.

Is there any function in the lib which helps me to integrate this?

Again, thank you for the support.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Problem with Adafruit color sensor: readings do not make

Post by adafruit_support_bill »

Find the min and max LED values which correspond to the min and max intensity from your screen.. Then perform a 2-point calibration on each of the 3 sensor channels.
https://learn.adafruit.com/calibrating- ... -calibrate

User avatar
Chamaeleon
 
Posts: 5
Joined: Sun Jan 13, 2019 6:23 am

Re: Problem with Adafruit color sensor: readings do not make

Post by Chamaeleon »

Great instruction! I will do that.

User avatar
Chamaeleon
 
Posts: 5
Joined: Sun Jan 13, 2019 6:23 am

Re: Problem with Adafruit color sensor: readings do not make

Post by Chamaeleon »

Hi again,
I have done the calibration, white balance and data type conversion from integer to byte. All you need is the map() function.
1. Step was to measure the sensor output of all three rgb values while he was directed to my TV. TV shows Win10 desktop with white color. R=255, G=255 and B=255. Same measurement with dark grey nearly black. R=20, G=20 and B=20.
2. Map the rgb values from Sensor to drive the rgb LED. Each rgb channel requires separate mapping.
3. Measure again and reproduce the light at white wall nearby the TV. I was able to do the white balance with my eyes. Win10 white at the TV should look the same as at the wall. I corrected the maximum sensor data for each rgb color. I have done the same with dark grey. I corrected the minimum sensor data for each channel. This also take care about the minimum output that the rgb LED starts working properly. Also I limited the brightness of the LED (power dot) to prevent overheating which was enough for an ambient illumination.

map(value, fromLow, fromHigh, toLow, toHigh)

In my example it is:

red = map(r,6,1698,22,165);
green = map(g,8,2258,22,200);
blue = map(b,9,2318,20,105);

Note, the real input values fromLow and fromHigh should not exceed the settings. Otherwise the output limitation does not work.

Makes fun :-)

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Problem with Adafruit color sensor: readings do not make

Post by adafruit_support_bill »

Good to hear that worked for you. Thanks for posting your results.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”