TCS34725 RGB Color Sensor

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

TCS34725 RGB Color Sensor

#1 Post by grovkillen » 03 May 2017, 13:07

I'm waiting for my TCS34725 sensor to arrive. I also have the older model TCS3200 which is not yet supported. When asking google about information regarding color sensors I came upon this project which I find very cool. It essentially report back a color instead of only RGB values. Could be a feature to consider for the plugin?

Extra links:
Wiki article for TCS34725
Data sheet fo TCS3200

PS. The cost of TCS3200 is about 30%-50% of the price for TCS34725. It might be worth to have a plugin for the older chip as well?

TCS3200 vs. TCS34725 in regards of price.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

krikk
Normal user
Posts: 118
Joined: 28 Feb 2017, 07:57
Location: Austria
Contact:

Re: TCS34725 RGB Color Sensor

#2 Post by krikk » 04 May 2017, 07:58

the rgb values are colors :) ... RED, GREEN, BLUE values, we can only give back numbers from plugins currently so no textual description...

about supporting the old sensor: i wrote the plugin for the TCS34725, and i do not have, nor will i buy an old sensor, because it lacks the i2c interface and the interrupt feature of the new one...

and after a quick look on the old sensor: it has a "complicate" interface:
The output is a square wave (50% duty cycle) with frequency directly proportional to light intensity (irradiance).
...not sure if this would work with the esp8266.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: TCS34725 RGB Color Sensor

#3 Post by grovkillen » 04 May 2017, 08:10

krikk wrote: 04 May 2017, 07:58 the rgb values are colors :) ... RED, GREEN, BLUE values, we can only give back numbers from plugins currently so no textual description...
Great job on the plugin. Thanks! :) I will just skip the old chip if the hookup is to complicated. No problem! :) But regarding textual description please refer to the project I linked in my first post. It uses a mathematical formula to find out what reference color that is the closest in a 3-dimensional matrix. Nothing complicated with that. Just use these values as reference colors and implement the mathematical formula. Sure RGB is colors but I thought your plugin would be something more than just a pass-along-values if the mathematical formula could be processed within the ESP unit. It would stand out! :)

Basic RGB colors and their names.

Image

"Silver" is the odd one here as it is based on 1.5 module of 128. I wouldn't add that to the color scheme. But the rest is based on 0,1,2 module of 128 which I find good.
Last edited by grovkillen on 04 May 2017, 08:16, edited 1 time in total.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

krikk
Normal user
Posts: 118
Joined: 28 Feb 2017, 07:57
Location: Austria
Contact:

Re: TCS34725 RGB Color Sensor

#4 Post by krikk » 04 May 2017, 08:16

implementing the formula and colors would be no problem, but as i said before, plugins can not give back strings (text), they can only give back numeric values, thats a limitiation of the current code, changing this would require major changes in code... another problem is that a plugin currently can only give back 4 values, and even new the sensor does have more than 4 values:
r,g,b, Color temperatur in K, c (clear light value) ...the last one is omitted in the current plugin and is only given via serial logging

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: TCS34725 RGB Color Sensor

#5 Post by grovkillen » 04 May 2017, 08:17

Aha, I did not know that. I will try to create a formula using rules then. Thanks for the support! :)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

krikk
Normal user
Posts: 118
Joined: 28 Feb 2017, 07:57
Location: Austria
Contact:

Re: TCS34725 RGB Color Sensor

#6 Post by krikk » 04 May 2017, 08:32

if you get the rules working, plz report back or even better document them on the. wiki

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: TCS34725 RGB Color Sensor

#7 Post by grovkillen » 04 May 2017, 08:40

krikk wrote: 04 May 2017, 08:32 if you get the rules working, plz report back or even better document them on the. wiki
Will do! :)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: TCS34725 RGB Color Sensor

#8 Post by grovkillen » 11 Jul 2017, 23:09

Ok, so I have now experimented the whole day with this and it takes some time to trim it to give good results. I have these settings:

Image

Image

And this rule on rule page 1 (the definitions takes up almost an entire rule page by it self..)

Code: Select all

On System#Boot do    //When the ESP boots, do
  timerSet,1,30      //Set Timer 1 for the next event in 30 seconds
endon

On Rules#Timer=1 do  //When Timer1 expires, do
  timerSet,1,30       //Resets the Timer 1 for another 30 seconds
  Event colorEvent       //Start analyzing the color
endon
On rule page 2 I have all the definitions defined... some not defined (I just added the "332" for white as well since that is close to white. More "close to" colors need to be added.)

Code: Select all

On colorEvent do
  TaskValueSet,2,1,3
   if [Color#Red]<192
    TaskValueSet,2,1,2
   endif
   if [Color#Red]<64
    TaskValueSet,2,1,1
   endif
  TaskValueSet,2,2,3
   if [Color#Green]<192
    TaskValueSet,2,2,2
   endif
   if [Color#Green]<64
    TaskValueSet,2,2,1
   endif
  TaskValueSet,2,3,3
   if [Color#Blue]<192
    TaskValueSet,2,3,2
   endif
   if [Color#Blue]<64
    TaskValueSet,2,3,1
   endif
//Get color
  TaskValueSet,2,4,[ColorDump#Red][ColorDump#Green][ColorDump#Blue]
  if [ColorDump#Found]=111
   TaskValueSet,3,1,1 //1=black
  endif
  if [ColorDump#Found]=333
   TaskValueSet,3,1,2 //2=white
  endif
  if [ColorDump#Found]=332
   TaskValueSet,3,1,2 //2=white (same as above!)
  endif
  if [ColorDump#Found]=311
   TaskValueSet,3,1,3 //3=red
  endif
  if [ColorDump#Found]=211
   TaskValueSet,3,1,4 //4=maroon
  endif
  if [ColorDump#Found]=131
   TaskValueSet,3,1,5 //5=lime
  endif
  if [ColorDump#Found]=121
   TaskValueSet,3,1,6 //6=green
  endif
  if [ColorDump#Found]=113
   TaskValueSet,3,1,7 //7=blue
  endif
  if [ColorDump#Found]=112
   TaskValueSet,3,1,8 //8=navy
  endif
  if [ColorDump#Found]=331
   TaskValueSet,3,1,9 //9=yellow
  endif
  if [ColorDump#Found]=133
   TaskValueSet,3,1,10 //10=cyan
  endif
  if [ColorDump#Found]=313
   TaskValueSet,3,1,11 //11=magenta
  endif
  if [ColorDump#Found]=222
   TaskValueSet,3,1,12 //12=gray
  endif
  if [ColorDump#Found]=221
   TaskValueSet,3,1,13 //13=olive
  endif
  if [ColorDump#Found]=212
   TaskValueSet,3,1,14 //14=purple
  endif
  if [ColorDump#Found]=122
   TaskValueSet,3,1,15 //15=teal
  endif
endon
Most readings work just fine and I suspect by tweaking the settings a bit more the results would be even better. All my "calibration" and readings are done at a distance of approx 10mm. Please observe this as a proof of concept. I hope this will further evolve into a plugin which will spit out the 1..15 (silver excluded) given by this page:
Image
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: TCS34725 RGB Color Sensor

#9 Post by grovkillen » 01 Aug 2017, 13:27

krikk wrote: 04 May 2017, 08:32 ...
Any thought on the rules? I suggest you add the 1..15 colors as a possible option besides the RGB values.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Post Reply

Who is online

Users browsing this forum: No registered users and 60 guests