SparkFun Color Sensor Breakout - HDJD-S822

Don't leave your next physical computing project stranded in a world of black and white! This color sensor module can detect the color of an object and report it back to your processor for applications like color sorting. The great thing about the HDJD-S822 is its simplicity to get it up and running. The gain of the sensor is controlled by digital input pins and it gives you separate analog outputs for red, green, and blue channels.

This breakout board makes it easy to embed the HDJD color sensor in your next project by breakout out all of the necessary pins to standard 0.1" headers.

  • Convert light to R,G,B voltage output
  • Independent gain selection options for each R,G,B channel
  • Supply Voltage: 5VDC
  • Dark voltage: 15mV
  • Maximum output voltage swing: 3V
  • [Schematic](http://cdn.sparkfun.com/datasheets/Sensors/LightImaging/HDJD-S822 Color Sensor Breakout-v11.pdf)
  • [Eagle Files](http://cdn.sparkfun.com/datasheets/Sensors/LightImaging/HDJD-S822 Color Sensor Breakout-v11.zip)
  • Datasheet (HDJD-S822-QR999)
  • Example Code

SparkFun Color Sensor Breakout - HDJD-S822 Product Help and Resources

Core Skill: Soldering

This skill defines how difficult the soldering is on a particular product. It might be a couple simple solder joints, or require special reflow tools.

1 Soldering

Skill Level: Noob - Some basic soldering is required, but it is limited to a just a few pins, basic through-hole soldering, and couple (if any) polarized components. A basic soldering iron is all you should need.
See all skill levels


Core Skill: Programming

If a board needs code or communicates somehow, you're going to need to know how to program or interface with it. The programming skill is all about communication and code.

2 Programming

Skill Level: Rookie - You will need a better fundamental understand of what code is, and how it works. You will be using beginner-level software and development tools like Arduino. You will be dealing directly with code, but numerous examples and libraries are available. Sensors or shields will communicate with serial or TTL.
See all skill levels


Core Skill: Electrical Prototyping

If it requires power, you need to know how much, what all the pins do, and how to hook it up. You may need to reference datasheets, schematics, and know the ins and outs of electronics.

1 Electrical Prototyping

Skill Level: Noob - You don't need to reference a datasheet, but you will need to know basic power requirements.
See all skill levels


Comments

Looking for answers to technical questions?

We welcome your comments and suggestions below. However, if you are looking for solutions to technical questions please see our Technical Assistance page.

  • Jacklin / about 9 years ago * / 1

    cool product indeed [ab]([ab](https://www.example.com` qwe qw ewe **as df>e " ))

  • Dezorian / about 11 years ago * / 3

    The example code did not work for me. The color ratio calculation did not incorporate the fact that each color needs a different irradiance value to reach 3V. And even using the charts from the datasheet, Blue was not recognized very good. The following values worked for me:

    redValue =   (( vRed    * 100)  / 16);
    greenValue = (( vGreen  * 130 ) / 22);
    blueValue =  (( vBlue   * 200 ) / 25); 
    

    First value is the spectral responsivity of the chip (I had to raise the ratio for blue from 170% to 200%). The second value is to equalize the V vs irradiance (in which a again raised the value for blue). Using these values, I could detect six colors using the following code:

    if (redValue > greenValue && redValue > blueValue)
    {
      if (greenValue > 2.6) server.log("Object is Orange.");
      else server.log("Object is Red.");
    }
    else if (greenValue > blueValue && greenValue > redValue)
    {
      if (redValue > 2) server.log("Object is Yellow.");
      else server.log("Object is Green.");
    }
    else 
    {
      if (redValue > 2) server.log("Object is Purple.");
      else server.log("Object is Blue.");
    }
    

    Check out the video

    • Member #580990 / about 10 years ago * / 1

      One thing you could do instead is measure the Red, Green, and Blue of a white card and a black card and write down the RGB values spat out by each. Then use the map() function to map each of the readings to their respective RGB values (black: 0,0,0; white: 255,255,255). Then use these values for color sorting using each colors' RGB value. This automatically scales everything to 100% and gives you good color distinction without having to worry about gain, etc. I can easily pick out seven different colors ranging from white to black (light blue, medium blue, blue-green, dark brown, tan, white, black). I probably could do more TBH.

  • rei_vilo / about 13 years ago / 3

    How could an analog sensor —this HDJD-S822— be twice as expensive as a digital sensor —the SEN-10701 based on ADJD-S311-CR999?

  • Member #385542 / about 10 years ago / 1

    This sensor works acceptably with bright sources, for example reading the average color of a TV, or a bank of LEDs, but it is not very sensitive when trying to use the onboard LED's reflection to detect the color of objects.

    Something like the retired SEN-08924 (TCS230 based) or a newer TCS3472 seems to work much better for that application....

  • Misha0 / about 10 years ago / 1

    Any reason this shouldn't work with the LilyPad arduino? This is my second one I am trying and the color readings are coming out the same. There is no change no matter what color conditions are, as if the sensor is not working. Please help!

  • Member #544857 / about 11 years ago / 1

    hi everybody kindly tell me is this sensor works for just detecting RGB colour ? or anybody have any library please share it with me .. thanks

  • MOSFred / about 11 years ago / 1

    This breakout doesn't have any current protection. I just fried 4 of them by accidentally driving the outputs with my Arduino Uno. Beware...

  • Member #394014 / about 12 years ago / 1

    What is the distance it can mesure? Say I want to measure a dot in an accuracy of 1x1mm blocks from 10 meters away, is this ok to use or should I use a camera?

  • zhiran / about 12 years ago / 1

    it doesn't need calibrate!

  • Member #192372 / about 12 years ago / 1

    I have read through the datasheet, and I am still not sure of what I need to do with the gain setting pins, should I attach them to DI/O/'s and then what, any explanation would be helpful.

  • Znegl / about 13 years ago / 1

    Isn't the recommended decoupling capacitor of 100nF already on the board? Seems like someone forgot to remove it from the copy-paste :)

  • Jollian / about 13 years ago / 1

    Can this be used to determine the color temperature in kelvin of a light source? such as an LED, to determine if the rating of 6500K is accurate or not?

  • philfromseattle / about 13 years ago / 1

    It would be nice to see a comparison between this and the ADJD-S311 sensor. What does $10 more get you?

Customer Reviews

No reviews yet.