RGB Sensor - TCS3400

Hi,
I found an arduino library for this rgb senson on Github:

The library doesn't include any example - only cpp code (and *.h file).
Is there a way i'll be able use it on arduino? (reading RGB values)

Thank you

The header file isn't that hard to interpret.

#include "TCS3400.h"

TCS3400 tcs;

void setup() {
  tcs.begin();
  Serial.begin(9600);
}

void loop() {
  Serial.print(F("R: "));
  Serial.print(tcs.getRed());
  Serial.print(F(" G: "));
  Serial.print(tcs.getGreen());
  Serial.print(F(" B: "));
  Serial.println(tcs.getBlue());
}

should work for a basic setup. As you failed to provide a wiring diagram of your setup and a link to your breakout board, this might not work because your hardware is different.

Thanks!
The code isn't working - returns only "R:"
I have wired the sensor similar to the recomended circuit in the sensor's datasheet (picture attached) when the scl and sda data goes to arduino uno and the voltage from the arduino is regulated to 1.8V.

How do you pull the code from the library and is there any modification needed in the library syntax? (I'm not a programmer so if you can explain i'll be grateful)

Ishai:
I have wired the sensor similar to the recomended circuit in the sensor's datasheet (picture attached)

Please post a schematic of how YOU have wired it EXACTLY.

when the scl and sda data goes to arduino uno and the voltage from the arduino is regulated to 1.8V.

Why?

Even without seeing your actual circuit I can tell that this is a recipe for disaster (could be anything from the thing just not working to you destroying your sensor).

Ishai:
Thanks!
The code isn't working - returns only "R:"
I have wired the sensor similar to the recomended circuit in the sensor's datasheet (picture attached) when the scl and sda data goes to arduino uno and the voltage from the arduino is regulated to 1.8V.

The chip runs at 3.3V, not 1.8V. Certain versions of it support an 1.8V I2C bus, but this chip is basically designed to
run at 3.0V or 3.3V.

Ishai:
How do you pull the code from the library

The src folder contains the source files of the library. In that folder, you'll find a file named TCS3400.h. This is the header file, which contains the function declarations. You can use this as a reference for the functions that are provided by the library. Often that will provide enough information. If you need more information, you can look in the file TCS3400.cpp, which contains the definitions of those functions.

wvmarle:
Please post a schematic of how YOU have wired it EXACTLY.

Why?

Even without seeing your actual circuit I can tell that this is a recipe for disaster (could be anything from the thing just not working to you destroying your sensor).

I made a board according to the attached scheme with a new sensor. Still not working.
Any recommendations?
Thanks for the help!

What is the purpose of those two LEDs, and why do they have those capacitors C2 and C3 in parallel? That doesn't make any sense to me.

Are you seriously using the bare sensor, rather than a breakout board? If so please do attach some clear images of the PCB you designed for it. That may be another source of issues.

How is this thing powered? No indication there, not even actual voltage levels. Same for the connections to your Arduino.

I use the led as a source of lighting (the capacitors are used because of analog voltage supplied to the leds).
The sensors and capacitors are wired according to manufacturers recommendations attached above.
Why do i need something else to pull out data from the sensor?

That's some impressive soldering. That dead bug style wiring does look like a major source of shorts or otherwise bad connections.

For the sensor: have you at least tried an I2C scanner, to see if you can find it? If it doesn't show up on the scanner, your wiring is wrong or the sensor is broken. If it does show up at least it responds to I2C communication, and you know your wiring is fine.

Ishai:
I use the led as a source of lighting (the capacitors are used because of analog voltage supplied to the leds).

And that just doesn't make sense.

How are you making connections to all six pins on the sensor? The blurry picture shows four, sort of.

wvmarle:
That's some impressive soldering. That dead bug style wiring does look like a major source of shorts or otherwise bad connections.

For the sensor: have you at least tried an I2C scanner, to see if you can find it? If it doesn't show up on the scanner, your wiring is wrong or the sensor is broken. If it does show up at least it responds to I2C communication, and you know your wiring is fine.

And that just doesn't make sense.

In other sensor i've tried, the I2C connection works just fine because I found a specific code for it (SCL and SDA pins of the sensor are wired to SCL and SDA pins of the arduino accordingly has shown in the drawing I've attached).
The source power is usb cable connected to the PC while the sensor board gets 3.3V through the arduino.

The leds aren't part of the sensor circuit but a source of light which makes a lot of sense to the purpose of this specific board.

The problem is that I can't manage to write a code for sensors which doesn't have one and I'm trying to figure out how to pull the data from each sensor I'm working with (they all have similar inputs and outputs through I2C with difference in register addresses).

jremington:
How are you making connections to all six pins on the sensor? The blurry picture shows four, sort of.

I have attached a scheme - the connector has 5 pins - 3.3V, SDA, SCL, analog pin (for controllable voltage) and GND.

So did you try an I2C scanner?

First confirm your sensor is connected properly. Until then there's no use to look at drivers or so.

Is I2C scanner a code or device?

I get some kind of parameters from the sensor, but not the correct one. I think I haven't understood so far how to call registers from each sensor.
Thanks again for the help.

Ishai:
Is I2C scanner a code or device?

It's a sketch. You just upload it to your Arduino and it prints the addresses of all the attached I2C devices to the Serial Monitor. There are a few of them listed here:
https://playground.arduino.cc/Main/I2cScanner/
I'm not sure which is the preferred one, but any should work.

Thanks!

I get:

Scanning...
I2C device found at address 0x29 !
done

That's the address of the sensor? If so at least you know your wiring is correct and the sensor is responding to commands. That's great.

So now it's time to look at your code, and the library you found. Are you sure the library as such is OK?

It has the P.N of the sensor.
Other than that... like I've said.. unfortunately I'm a mechanical engineer and not a programmer.

If I don't have any library at all. Is it possible to create one code that will handle with all kinds of RGB I2C sensors (only with wire library) when the only parameters that change are the registers according to the data sheet of each sensor?

I don't think it's possible to create a generic library.

There's the Wire library that facilitates the I2C communication itself; after that it depends highly on the individual sensor on what commands it takes and what response to expect.