Go Down

Topic: Light-Color-Sensor-I2C-16-bit-RGBW (Read 1 time) previous topic - next topic

MarCar

Hi all

I have bought Arduino UNO and a light color sensor.
I have never used Arduino before and have tried some examples but not sure what to do now.
I want to use the sensor to only recognise one specific frequensy, and in order to do that I have also a green filter that will only allow my desired frequensies.

Any feedback is more than welcome :-)
I think I have attaeched it correct as I get some results when I try the examples, but how do I change/write a program that do what I want?
I want the Arduino to check constantly and when the correct frequensy occurs I want it to give me a signal. So far I have not been able to get it to tell me any frequensies :-(

Regards
Martin

Riva

Do you really need the colour filter? The colour sensor should return the frequency of the light (reflected) from the object you want to measure. Putting a filter in front theoretically limits the sensor to a percentage yes/no for the masked frequency but if the light source used to measure with does not contain this frequency then the result would always be no.
You could probably just use an LDR with the filter fitted.

Magician

Link to data sheet of the sensor?

MarCar

Hi Riva

Maybee not, but first we need to get it working :-)


Hi Magician

Here it is
http://www.ams.com/eng/Products/Light-Sensors/Color-Sensor/TCS3414

Regards
Martin

Magician

Quote
I want the Arduino to check constantly and when the correct frequensy occurs I want it to give me a signal.
This what I thought, sensor light-to-frequency. But after visiting product web-page, it turns out it's Not the case. Sensor outputs digital stream I2C format, basically you need to write a software DRIVER for arduino to communicate with device. Task is too complex even for experienced programmers, definitely not for beginners. Your hope only too google if someone already create a library, for exactly same sensor or something close in hardware - software implementation.

MarCar

Hi again Magician

Sorry, I gave you the wrong link
It should be this one
http://www.ams.com/eng/Products/Light-Sensors/Light-to-Frequency/TSL238

I did manage to get it working now, so it gives me frequensies.
Now the next step is to get some kind of "trigger" when the correct frequensy is present.


Regards
Martin

Magician

Quote
I did manage to get it working now, so it gives me frequensies.

If you have this part done, than everything else is a piece of cake, just couple "if" statement or even one "if" with &&.

robtillaart

Used a TSL235R last year which is also a light to frequency sensor and used this sketch as test of sensor code". 
A trigger can be set by adding a timestamp in the IRQ1() and compare this with the prev time stamp (use volatile vars)

Code: [Select]

/*
*    FILE: TSL235R.pde
*  AUTHOR: Rob Tillaart
*    DATE: 2011 05 16
*
* PURPOSE: prototype TSL235R monitoring 
*
* Digital Pin layout ARDUINO
* =============================
*  2     IRQ 0    - to TSL235R
*
* PIN 1 - GND
* PIN 2 - VDD - 5V
* PIN 3 - SIGNAL
*
*/

volatile unsigned long cnt = 0;
unsigned long oldcnt = 0;
unsigned long t = 0;
unsigned long last;
unsigned long msec = 0;
unsigned int cf = 1466;  // cf = 10^0.166 * 1000 (figure 1 datasheet)

void irq1()
{
  cnt++;
}

///////////////////////////////////////////////////////////////////
//
// SETUP
//
void setup()
{
  Serial.begin(115200);
  Serial.println("START");
  pinMode(2, INPUT);
  digitalWrite(2, HIGH);
  attachInterrupt(0, irq1, RISING);
}

///////////////////////////////////////////////////////////////////
//
// MAIN LOOP
//
void loop()
{
  msec = millis() - last;
  if (msec >= 1000)
  {
    last += msec;
    t = cnt;
    unsigned long hz = (t - oldcnt) * 1000 / msec;
    oldcnt = t;
    unsigned long mw = (hz * cf/1000 + 50)/100; // +50 == rounding last digit
   
    // smoothing possible...
    Serial.print("FREQ: ");
    Serial.print(hz);
    Serial.print("\t ");
    Serial.print(mw); 
    Serial.println(" mW/m2");
  }
}

// END OF FILE
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

crackmech

Hi!

I am also stuck with the similar problem! I want to use a color to digital (or frequency, whichever is easier!) converter. I am new to arduino and programming. Though digging on the 'net gave me http://www.maxwellrosspierson.com/2012/06/07/interfacing-the-arduino-to-the-taos-tcs3414-via-i2c/.

Please if anyone can help me with this. I would like to use an I2C as I need to connect atleast 16 such sensors on the board. Though I would need to read from those sensors one by one (like an array or something), and not all together.  Any suggestions?

Thanks in advance!

Go Up