SparkFun will be closed Nov 26th and 27th for the Thanksgiving holiday. Orders placed after 2:00pm MT on the 25th will ship out Monday the 30th.

Retired Product

This product has been retired from our catalog and is no longer for sale. This page is made available for those looking for datasheets and the simply curious.

Creative Commons images are CC BY-NC-SA 3.0

Description: 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


Recommended Products

Customer Comments

  • 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.");
      if (redValue > 2) server.log("Object is Purple.");
      else server.log("Object is Blue.");

    Check out the video

    • 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.

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

  • 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….

  • 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!

  • 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

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

  • 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?

  • it doesn’t need calibrate!

  • 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.

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

  • 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?

  • 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.