TCS3200 with Arduino Uno

Hi,
I recently bought a board with the color sensor TCS3200.
I bought it from: http://www.miniinthebox.com/nl/interfacing-tcs3200-kleur-sensor-met-avr-atmega32_p508760.html
It has the inputs S0, S1, S2, S3, E0 and the output, called Out.
What is not clear for me, what does the input E0 mean? Where do I have to connect it?

What I would like to do with the sensor:
I would like to measure the color temperature of a LED. I have at this moment 3 types of LEDs (2700K, 3000K and 4000K), and this I would like to check with the sensor the color temperature.

The color temperature I suppose I can calculate via the following formulae: How to Calculate the Color Temperature / Tint of the Colors in an Image? - Signal Processing Stack Exchange

To use this formula, I should get the measured RGB values from the color sensor.

Can somebody help me please with this? A start would be already a very good help.
I tried already a lot of codes from the internet to measure the RGB values, but I don't get any good result with my Arduino.

Thank you very much in advance.

Aguila:
...
...
What is not clear for me, what does the input E0 mean? Where do I have to connect it?

...
...
Can somebody help me please with this? A start would be already a very good help.
I tried already a lot of codes from the internet to measure the RGB values, but I don't get any good result with my Arduino.

Thank you very much in advance.

http://www.lmgtfy.com/?q=tcs3200+color+sensor+arduino+code

I believe that that sensor is similar to a TCS230 I the way it works (could be wrong).

If it is, I have a library that may be a good starting point for you. There is also a document on how to calibrate the sensor with the library. LInk is in my signature below (code repository).

Hi,

Thank you very much for the reply. I downloaded the documents from your website and tried to do the calibration. Unfortunately this also did not work.
I got the message "Press any key" and I was blocked.

The setup I use: 1 arduino UNO board, 1 board with TCS3200 (YL-64, from the website, http://www.miniinthebox.com/nl/interfacing-tcs3200-kleur-sensor-met-avr-atmega32_p508760.html), 8 wires.

What is still not clear for me is how I have to connect the pin EO. Is this the same as OE in the many examples?

Can somebody please help me out with this?

Make sure your serial monitor is sending newlines when you press enter. In the Arduino IDE the option is at the bottom right corner of the serial monitor.

I am pretty sure EO and OE are the same thing. It is the enable for the sensor. You should get a copy of the datasheet for the chip as this will have all the signals explained. Just remember that INPUT to the chip is OUTPUT from the Arduino.

I tried this.
I have selected newline next to the baudrate, which is 57600.
When I press then enter, nothing happens.

I connected the vcc to 5V, GND to ground, S2 to digital pin 12, S3 to digital pin 13 and OUT I have connected to digital pin 8.

The S0, S1 and EO I did not connect.

What I do wrong?
Thanks in advance for the patience.

Hi,
Now I see that I had to press enter.
So I holded the sensor before a black surface, pressed send, than I hold it before a white surface, send and then I got the message: Reading value for DATA. Press any key to start.

And then I always get: RGB is [0, 0, 0] ...

The S0, S1 and EO I did not connect.

This is ok as long as you are putting them either to GND or Vcc. You cannot leave them floating. What you should put them to depends on the datasheet and what you are trying to achieve. I would put S0, S1 to Vcc (full scale) and E0 to GND (enable).

You will also need to use the correct version of the TCS library object constructor (the one without S0, S1, E0 specified in the parameters).

I tried it, by connecting to the gnd and also by connecting to 5V, but none of them are working. After calibration I still have the rgb [0,0,0].
I will try tomorrow again. Thanks a lot for helping.

http://forum.arduino.cc/index.php?topic=216765.0

Hi,

Today I tried again the sensor, but without success. Many codes that the people posted here (MANY thanks for that) and from the internet I have loaded to the arduino.

I have used the following hardware:

  • Arduino Uno
  • 5 wires to connect the Vcc, Gnd, S0, S1, S2,s3, E0, OUT.
  • Color sensor TCS3200 YL-64.

remark: no RGB sensor present.

The color sensor I bought from Interfacing TCS3200 Colour Sensor with AVR ATmega32 review

The description says: TCS3200 colour sensor with AVR ATMEGA32.
Is the AVR ATMEGA32 giving the problem that is does not work?

Back to basics:

  1. Does the LEDs light up when you connect the sensor?
  2. Have you measured the voltages at the sensor using a multimeter to check that these are right?
  3. Have you checked that the EO/OE line is LOW? The low signal enables the chip and nothing will work if this is not the case.

Hi

I used following code:

// TCS230 sensor calibration and color readings
//
// Input and output using the Serial console.
//
#include <MD_TCS230.h>
#include <FreqCount.h>

#define	BLACK_CAL	0
#define	WHITE_CAL	1
#define	READ_VAL	2

// Pin definitions
#define  S2_OUT  12
#define  S3_OUT  13
#define  OE_OUT   8    // LOW = ENABLED 
.....
  1. the 4 LEDs are lighting up when I connect.
  2. It seems I have the correct voltages. Also I checked with multimeter the pin 8 and this gives 0V
  3. According the code, I connect S2 to digital pin 12, S3 to pin 13, OUT to 8, Vcc to 5V and Gnd to the ground.
    Based on your previous explanation I connected S0 to 5V, S1 to 5V, OE to GND.
    Is it ok that I use the calibration code for TCS230 for a TCS3200?
#define  OE_OUT   8    // LOW = ENABLED

This says that OE is connected to 8, not OUT.

OUT needs to be connected to a special pin that depends on the FrequCount library requirements and the Arduino type you are using. The header file (or my documentation?) outlines this. The FreqCount library uses an interrupt to get very accurate timing and counts, so it needs this special pin.

Operation of the sensors is the same but I am guessing now that you are missing the frequency count from the sensor.

Great! Marco_c, you are a great help, what I say, a fantastic help! I had toconnect out to digital pin 5.
The calibration code works. The sensor detects when it is black [0,0,0] and white [255, 255, 255].
Now I need to define the exact code for colored objects, because now it is not totally corresponding.
Do I need to cennect the outer inputs to the digital pins instead of connecting to 5V?

And after I need to know the color temperature. Do you think I will be able to have the exact color temperature of a light? Formula for CCT I have from the internet.
From the first test I do not have a good result, I got for all lights the RGB code [255, 255, 255], so I calculate then same color temperature.

Karma points always welcome :slight_smile:

Do I need to connect the outer inputs to the digital pins instead of connecting to 5V?

I don't know what this means. What are the 'outer inputs'?

Do you think I will be able to have the exact color temperature of a light?

No idea on this one. My use of the sensor is for detecting color, not color temperature. The sensors work by reading the level of reflected light rather than a light source directly. This may not be compatible with reading a color emitted from a colored source. However, assuming that you can read such a source, then there should be formulas that allow you to convert from one to the other. Color space and its attributes is an interesting topic but I am not at all an expert.

Hello,

I am a web programmer trying to learn a bit of Arduino.

I installed marco_c 's library (thank you!) to use with a TCS230 sensor. The vendor said it's TCS3200, but it looks like this, so I'm guessing it's the TCS230.
I used the Calibration example and it worked, but rgb values on serial monitor translate to colors much darker than the objects sensed. I tried different libraries with the same problem, colors are too dark. For example, a green color that should be something around R=172 G=204 B=60 is being recognized as R=160 G=154 B=63.
My ultimate goal is to detect skin color, so some level of accuracy would be important.

Could this be caused by some problem with my settings or could it be sensor malfunction?

I changed pin definitions in the Calibration example to these:

#define  S0 13
#define  S1  12
#define  S2  11
#define  S3  10

And I'm calling the class like this:

MD_TCS230 CS(S2, S3, S0, S1);

OUT is set to D5
OE is set to GND

Can anyone help me?
I have little to no knowledge on hardware/electronics, but I may try to check the sensor if you have some tips.

Thank you in advance!

When you are using the sensor, are you shielding it from externally reflected light? If you are using the sensor as-is in the picture you linked to, you will get different results depending on the light level and other objects in the room.

If you see in my documentation, I built a black cardboard shielding around the LEDs and the sensor. Then when I want to sense, I lock out all the external light from the sensor by putting the shroud in contact with the material to be identified. this stops the external light from influencing the reading and I get the same every time.

I would also say that the colours on the screen will look different from colours in real life because they are produced differently.

Hi, thank you for such a quick response.

Well, I improvised a shield using thin cardboard, but it is not black and it still lets some external light pass through. For some colors the results are a lot different... A pale skin is read as dark brown.

I'll try to make a better shielding and post the results.

Well, I've built a pretty decent shield around the sensor in black cardboard, and the results changed minimally. On human skin, results are the worst, I guess skin has bad reflectance (I found some studies on the subject, like this one).

I put the colors generated from the rgb values on an image to illustrate what's happening (image attached)