0

LOW LUMINOSITY TCS34725
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

LOW LUMINOSITY TCS34725

by Tecla on Sun Apr 20, 2014 2:31 pm

Hello! =)

I am trying to develop a project which consist in a lamp inspired by your project ´´wearables``.

The aim of it, would be to make the luminaire react depending on the level of temperature of color and light outside.
So I bought TCS34725 sensor to start to make experiments controlled by Arduino.
The selected light source is an RGB 60 LEDs strip SMD 5050/m 14,4 w/m 12 V , (in total three meters)
Due to its power, i used TIP 120 transistor so that I am able to connect it to Arduino.
I also hook up a proper 12V transformer for the lamp , and a regulable power supply for Arduino , the RGB lamp connected to the PWM pins and with the following code works perfectly :

Code: Select all | TOGGLE FULL SIZE
// Declaracion de variables
int rojo = 0;
int verde = 0;
int azul = 0;
 
void setup()
{
  // Nada para configurar
}
 
void loop()
{
 
  // Activando la salida PWM 8
  for (int a=0; a<255; a++)
  {
    azul = azul + 1;
    analogWrite(8, azul);
    delay(30);
  }
  // Activando la salida PWM 9
  for (int r=0; r<255; r++)
  {
    rojo = rojo + 1;
    analogWrite(9, rojo);
    delay(30);
  }
  // Activando la salida PWM 10
  for (int v=0; v<255; v++)
  {
    verde = verde + 1;
    analogWrite(10, verde);
    delay(30);
  }
}


The problem comes when i connect the TCS sensor. Though the code works properly, the light doesn´t turn on completely, I use the ´´colorview´´ code from adafruit library and it just brights a little bit stronger when i completely cover the sensor with my hand. But the light is very weak.

Since I've never worked with this kind of sensor, I am not able to figure out what´s the main reason.
Is there any way to turn on this lamp more brightly ?

Here i attach Colorview code
Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include "Adafruit_TCS34725.h"

// Pick analog outputs, for the UNO these three work well
// use ~560  ohm resistor between Red & Blue, ~1K for green (its brighter)
#define redpin 3
#define greenpin 5
#define bluepin 6
// for a common anode LED, connect the common pin to +5V
// for common cathode, connect the common to ground

// set to false if using a common cathode LED
#define commonAnode true

// our RGB -> eye-recognized gamma color
byte gammatable[256];


Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);

void setup() {
  Serial.begin(9600);
  Serial.println("Color View Test!");

  if (tcs.begin()) {
    Serial.println("Found sensor");
  } else {
    Serial.println("No TCS34725 found ... check your connections");
    while (1); // halt!
  }
 
  // use these three pins to drive an LED
  pinMode(redpin, OUTPUT);
  pinMode(greenpin, OUTPUT);
  pinMode(bluepin, OUTPUT);
 
  // thanks PhilB for this gamma table!
  // it helps convert RGB colors to what humans see
  for (int i=0; i<256; i++) {
    float x = i;
    x /= 255;
    x = pow(x, 2.5);
    x *= 255;
     
    if (commonAnode) {
      gammatable[i] = 255 - x;
    } else {
      gammatable[i] = x;     
    }
    //Serial.println(gammatable[i]);
  }
}


void loop() {
  uint16_t clear, red, green, blue;

  tcs.setInterrupt(false);      // turn on LED

  delay(60);  // takes 50ms to read
 
  tcs.getRawData(&red, &green, &blue, &clear);

  tcs.setInterrupt(true);  // turn off LED
 
  Serial.print("C:\t"); Serial.print(clear);
  Serial.print("\tR:\t"); Serial.print(red);
  Serial.print("\tG:\t"); Serial.print(green);
  Serial.print("\tB:\t"); Serial.print(blue);

  // Figure out some basic hex code for visualization
  uint32_t sum = clear;
  float r, g, b;
  r = red; r /= sum;
  g = green; g /= sum;
  b = blue; b /= sum;
  r *= 256; g *= 256; b *= 256;
  Serial.print("\t");
  Serial.print((int)r, HEX); Serial.print((int)g, HEX); Serial.print((int)b, HEX);
  Serial.println();

  //Serial.print((int)r ); Serial.print(" "); Serial.print((int)g);Serial.print(" ");  Serial.println((int)b );

  analogWrite(redpin, gammatable[(int)r]);
  analogWrite(greenpin, gammatable[(int)g]);
  analogWrite(bluepin, gammatable[(int)b]);
}


Thank you very much
Tecla
Tecla
 
Posts: 5
Joined: Wed Jan 08, 2014 6:15 pm

Re: LOW LUMINOSITY TCS34725

by adafruit_support_bill on Sun Apr 20, 2014 3:26 pm

What is the current rating for your 12v power source?

adafruit_support_bill
 
Posts: 62261
Joined: Sat Feb 07, 2009 10:11 am

Re: LOW LUMINOSITY TCS34725

by Tecla on Mon Apr 21, 2014 4:33 am

Max.5A
Attachments
Screen Shot 2014-04-21 at 10.30.57.png
Photo 12V Power Source
Screen Shot 2014-04-21 at 10.30.57.png (542.44 KiB) Viewed 435 times
Tecla
 
Posts: 5
Joined: Wed Jan 08, 2014 6:15 pm

Re: LOW LUMINOSITY TCS34725

by adafruit_support_bill on Mon Apr 21, 2014 7:10 am

5A should be sufficient to power the strip.

uint32_t sum = clear;
float r, g, b;
r = red; r /= sum;
g = green; g /= sum;
b = blue; b /= sum;
r *= 256; g *= 256; b *= 256;


These are all integers. Performing the division before the multiplication will cause truncation of the value. I think you want to do it the other way around. You may also need to add an overall adjustment factor to achieve the desired output range depending on the actual light levels.

adafruit_support_bill
 
Posts: 62261
Joined: Sat Feb 07, 2009 10:11 am

Re: LOW LUMINOSITY TCS34725

by Tecla on Sat Oct 25, 2014 6:07 pm

Hello !

Sorry for late response.
With some help I finally could get a functional code !
Thank you very very much.
Here I leave info about it !
http://www.marinamellado.com/luz/

Best!
Tecla
 
Posts: 5
Joined: Wed Jan 08, 2014 6:15 pm

Re: LOW LUMINOSITY TCS34725

by adafruit_support_bill on Sun Oct 26, 2014 6:28 am

Very nice design! Thanks for posting.

adafruit_support_bill
 
Posts: 62261
Joined: Sat Feb 07, 2009 10:11 am

Re: LOW LUMINOSITY TCS34725

by Tecla on Fri Oct 31, 2014 9:35 am

Thanks to you !
I will post the code once i will finish it, I wish I could make an understandable interface so that people who don't know programming could change the value of the light-colors using your sensor!
I am very excited about the creation of an open source concept for emotional global lighting ! ( maybe sounds crazy ) ahahaha

Now I am studying MA industrial design in UK and I am really curious about wearables … That´s my next challenge.

As I said before. Thank you!
Tecla
 
Posts: 5
Joined: Wed Jan 08, 2014 6:15 pm

Please be positive and constructive with your questions and comments.