When looking at the serial monitor for the TCS34735 I am given values that look like this.
Color Temp: 5847 K – Lux: 109 – R: 4109 G: 1327 B: 890 C: 5814
Color Temp: 2767 K – Lux: 460 – R: 4468 G: 1703 B: 1062 C: 6734
Color Temp: 4381 K – Lux: 463 – R: 1379 G: 1012 B: 938 C: 1789
Color Temp: 4276 K – Lux: 588 – R: 1464 G: 1136 B: 997 C: 2153
Color Temp: 3952 K – Lux: 646 – R: 1424 G: 1135 B: 933 C: 2350
Color Temp: 3528 K – Lux: 835 – R: 1713 G: 1362 B: 1036 C: 3101
Does anyone know how to convert these to rgb color values or just color names in general. Anything really.
I am confused because I thought rbg values only went from 0-255.
Koepel
January 21, 2021, 11:51pm
2
I think you have an Arduino board with a library and a example sketch.
I read here that you have a Arduino Uno.
The Arduino Uno has a 5V I2C bus and the TCS34725 has a 3.3V I2C bus. How did you connect them together ? Can you give a link to your TCS34725 module ? The Adafruit module is made compatible with 5V Arduino boards, such as the Uno.
Which library do you use and which example sketch do you use.
I thought rbg values only went from 0-255.
In some cases, yes. In many others, no.
I have it connected to 3.3v. and this is the link I bought it off of https://www.amazon.com/gp/product/B00OKCRU5M/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
I believe it is the Adafruit Model.
#include <Adafruit_TCS34725.h>
#include <Adafruit_TCS34725.h>
#include <Wire.h>
#include "Adafruit_TCS34725.h"
/* Example code for the Adafruit TCS34725 breakout library */
/* Connect SCL to analog 5
Connect SDA to analog 4
Connect VDD to 3.3V DC
Connect GROUND to common ground */
/* Initialise with default values (int time = 2.4ms, gain = 1x) */
// Adafruit_TCS34725 tcs = Adafruit_TCS34725();
/* Initialise with specific int time and gain values */
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);
void setup(void) {
Serial.begin(9600);
if (tcs.begin()) {
Serial.println("Found sensor");
} else {
Serial.println("No TCS34725 found ... check your connections");
while (1);
}
// Now we're ready to get readings!
}
void loop(void) {
uint16_t r, g, b, c, colorTemp, lux;
tcs.getRawData(&r, &g, &b, &c);
// colorTemp = tcs.calculateColorTemperature(r, g, b);
colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
lux = tcs.calculateLux(r, g, b);
Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
Serial.print("Lux: "); Serial.print(lux, DEC); Serial.print(" - ");
Serial.print("R: "); Serial.print(r, DEC); Serial.print(" ");
Serial.print("G: "); Serial.print(g, DEC); Serial.print(" ");
Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
Serial.println(" ");
}
The sensor seems to be working as expected. What do you want to do with it?
If you want to learn a bit about how human color perception and RGB numbers are related, you might start here: HSL and HSV - Wikipedia .
Koepel
January 22, 2021, 7:36pm
6
Yes, that is that is a module from Adafruit, it is compatible with a 5V Arduino board.
Did you read the tutorial : Overview | Adafruit Color Sensors | Adafruit Learning System . There is a lot information when you read every page.
You should power it from the Arduino 5V pin to the module VIN, and don't connect the module 3V3.
That way the I2C level shifter does its job.
If you power it with 3.3V, then the I2C level shifter does not work. Since your Arduino Uno has a 5V I2C bus and the sensor has a 3.3V I2C bus, the I2C level shifter on the module connects the 5V I2C bus with the 3.3V I2C bus.
I wrote a page to scare new users about the I2C bus :o How to make a reliable I2C bus · Koepel/How-to-use-the-Arduino-Wire-library Wiki · GitHub .
system
Closed
May 22, 2021, 7:37pm
7
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.