Creative Commons images are CC BY-NC-SA 3.0

Description: Atlas Scientific is on a mission to make high-quality sensors for environmental monitoring available to everyday hackers and makers. All of their kits are easy to calibrate and connect to your microcontroller-based project.

Color light sensors are awesome devices for everything from environmental sensors to general robotics. They can be used to monitor slowly changing events like algae blooms or leaf death, or to determine light absorption through a medium. But for all their utility, they have some flaws. First off, they can be complicated to interface to since RGB data often has to be derived using complex signal processing. Secondly, they’re less than rugged, and when you want to deploy one in the field you need a device that can stand up to the weather. Even moisture in the air can make an unprotected sensor unreliable.

Atlas solved these problems by embedding the light sensor in a rugged housing below a layer of transparent epoxy which protects the sensor from moisture while still allowing light to get in. The resulting light probe is water- and dust-proof, sleet and ice tolerant, non reactive in salt water and will readily sink when submerged. On top of all that, it provides both RGB level (in 8-bit RGB format) and light intensity (in lux) as simple comma separated strings over RS-232!

Features:

  • R,G,B data is in true 8-bit RGB format from 0-255
  • light intensity is output in lux (lx)
  • lx given for R ,G and B as well as full spectrum lx
  • RGB color data and lx can be output simultaneously
  • lx range from 0- 3,235 lux
  • Light saturation indicator if lx is over 3,235
  • Three different output modes:
    • RGB only
    • Lx only
    • RGB and lx
  • Data output is a single comma separated string
  • Simple RS-232 connectivity (voltage swing 0-VCC)
  • Harsh environment ready: NEMA 6P and IP 68 rated
  • Wide operating temperature range: -40 Celsius to +85 Celsius
  • Simple instruction set consisting of only 5 commands
  • Reading time: 620ms
  • Wide operating voltage range: 3.1V to 5.5V
  • Shock resistant to 16 mega Pascals

Documents:

Recommended Products

Customer Comments

  • I was skeptical about purchasing one of these sensors since I saw that so many people are having issues with it. That said, I thought I would clear up some of the things that I confronted when working with this sensor today.

    I connected the sensor in the following manner: - White to TX of Serial3 on an Arduino Mega - Green to RX of Serial3 - Red to +5VDC - Black to GND

    • The sample Arduino Mega code from the manufacturer has a bug where the baud rate for Serial3, the serial port that the sensor is to be communicating on, is set to 9600 instead of 38400–the default baud rate for the sensor

    • The sample Processing code has the baud rate set to 38400 when the Arduino Mega baud rate for Serial0, the serial port for the Arduino Mega to communicate with the computer, is set to 9600, so I changed the baud rate to 9600 in the Processing code.

    • The sample Processing sketch has a bug where it apparently attempts to automatically select which COM port the sensor is connected to, but as my install of the Processing IDE was fresh, I apparently didn’t have whatever library that may be needed in order to make that function automatic. To fix this, I changed this:

      myPort = new Serial(this, Serial.list()[1], 38400);

    to this:

    myPort = new Serial(this, "COMx", 9600);
    

    Where “x” is the number of the COM port that my Arduino Mega is connected to. Yes, you need the double quotes.

    There was some question about angle of view and distance from subject, which I explored for a bit. I found that the sensor has a fairly narrow angle of view, approximately 10-degrees. The working distance is from about 25mm down to about 1mm if illumination is good. I found that as the sensor gets farther from the subject, the color seems to be more influenced by the surrounding colors, but the color in the center of the target is most pronounced.

    Finally, a question that I had was whether or not this device viewed color from the perspective of a spectrometer, or from the perspective of the human eye. The difference is that when one is looking at different colors of light that mix, the eye will see the resulting color from the mixture of the light where a spectrometer will be able to discriminate the light into the separate wavelengths unless some sort of nonlinear crystal is used to mix the two. I was glad to find that this sensor views the color of light from the perspective of the eye, which opens up a great number of potential applications for this.

  • This would have made the RGB Fiber Communication experiment much easier!

  • Hello - I believe that the link to the datasheet on this page is broken. Since it seems that the datasheet can’t be accessed directly, I’ve included a link below to a page where the datasheet can be found:

    https://www.atlas-scientific.com/product_pages/sensors/env-rgb.html

  • can this act as a realtime light level and colour sensor passing that data directly to a LED panel thru an Arduino (no PC involved)? the idea is that it reflects the light level and colour outside directly to the LED panel. thanks.

  • I am getting RGB readings substantially above 255 whenever it is pointed toward a semi-lighted source. Anyone else having this problem?

  • How far or close do you need to be from the source to work?

  • I don’t know if this will help anyone but… One of the things I noticed about this sensor is when I connect it to a PIC32 UART port, if I try to program the pic or pause it when it is running in debug mode the sensor quits sending data. Often it will not start back up until it is power cycled. To solve this I put a 100K resistor from the white wire to Vcc. When the PIC is reset the pins go from being driven to being in a high impedance state, making the color sensor see a start bit.

    Hope this is helpful.

  • Can I connect it to a pc !?, can someone give a code example using C++ !?

  • // Copyleft Zach Vorhies 2014
    // No rights reserved.
    // Tested on an ArduinoMega. Connect pins to RX and TX.
    // Usage:
    //  ColorDetector<HardwareSerial> cd(Serial3);
    //  void setup() { cd.begin(); }
    //  void loop() {
    //    if (cd.Update()) {  // True when new readings have occured.
    //      cd.PrintValues(Serial);  // print values.
    //    }
    //  }
    
    
    template<class StreamT>  // StreamT == HardwareSerial or SoftSerial.
    class ColorDetector {
     public:
      ColorDetector(StreamT& s)
         : input_(""), stream_(s),
           r(0), b(b), g(0),
           r_lx(0), b_lx(0), g_lx(0), total_lx(0),
           saturated(false) {
        input_.reserve(kStrLen);  // Upto 36 characters for the rgb+lx data.     
      }
    
      void begin() {
        stream_.begin(38400);
        stream_.write("M3\r");  // Sets mode0 of the sensor.
      }
    
      // Returns true if new values were parsed.
      bool Update() {
        while (stream_.available() > 0) {
          //if the hardware serial port_3 receives a char 
          //get the char we just received
          char inchar = (char)stream_.read();
          //add it to the inputString
          input_ += inchar; 
          if(inchar == '\r') {
            saturated = input_.indexOf('*') != -1;
    
    
            // Time to parse out the string into values.
            int* values[] = {&r, &g, &b, &r_lx, &g_lx, &b_lx, &total_lx};
            const int values_size = sizeof(values)/sizeof(values[0]);
            int i = 0;
    
            char cpy_str[kStrLen];
            input_.toCharArray(cpy_str, kStrLen);
            input_ = "";  // resets the input.
    
            char* p = cpy_str;
    
            char *str;
             // delimiter is the comma
            while (i < values_size && (str = strtok_r(p, ",", &p)) != NULL) {
              String cpy = str;
              *values[i] = cpy.toInt();
              ++i;
            }
            return true;
          }
          // No update yet.
          return false;
        }
      }
    
      void PrintValues(Stream& output) {
        int* values[] = {&r, &b, &g, &r_lx, &b_lx, &g_lx, &total_lx};
        const int array_size = sizeof(values) / sizeof(values[0]);
        for (int i = 0; i < array_size; ++i) {
          output.print(*values[i]);
          if (i < array_size - 1) {
            output.print(",");
          }
        }
        if (saturated) {
          output.print(",<saturated>");
        }
        output.println();
      }
    
      int r, b, g;
      int r_lx, b_lx, g_lx, total_lx;
      bool saturated;
    
     private:
      static const int kStrLen = 38;
      String input_;
      StreamT& stream_;
    };
    
    
    ColorDetector<HardwareSerial> color_detector(Serial3);
    
    void setup() 
      Serial.begin(9600);
      color_detector.begin();
    }
    
    void loop() {
      if (color_detector.Update()) {
        color_detector.PrintValues(Serial);
      }
    }
    
  • hi, i ’m not much aware of electronics. i want to build a color mixer which ’ll mix 3 primary colors (RGB) to give the exact color sample placed before the sensor. i.e., give red, blue and green proportions of the sample color. can this sensor be used to do so.. pls.. help

  • Hello,

    I just received this sensor, and it feels and looks great. But I cannot seem to get any sensible readings from it using the Arduino along with the sample code. A simple Google search got me to the conclusion that nobody got it to work.

    Can you please post a working sample code that can atleast tell us the RGB and lx values it sees?

    Thank you in advance, Ali

  • None of the sample code works (completely or reliably) on an Arduino Uno (R3, latest IDE is v1.5.4). The problems with getting the serial communication to work with this device are discussed here: http://forum.arduino.cc/index.php?PHPSESSID=bg08293jtk53uprjmclqluav73&topic=146380.0
    It appears that this may be because of a timing conflict between SoftwareSerial and Serial, but as of Jan 17, 2014, no one has posted sample code that works completely. If anyone here has simple code that works, I’d love to see it… :/

  • Awesome sensor, however the read time is 1200 ms; 620 ms is a mistake in the datasheet.

  • Any idea when these might be available again? Thanks.

  • i want to ask about the connection of this sensor..this sensor need another board to connect to arduino mega 2560 or not?if this sensor need other board to connect the arduino,what kind of board?i really need to know because i want to buy this product and i from malaysia.if this product do not work as i expected and i cannot get the output that i want,it will really cost me a lot of money..

  • 620ms seems like quite a long time for an instruction to complete. For higher speed color detection, this should probably be avoided.

  • Guys, 0 – VCC is not a valid RS-232 serial level. If you connected this to a proper RS-232 port, it would not work. Please correct this in the spec as it is misleading and some people would take it to mean you can connect it to a PC or something similar directly.

    RS-232 specifies that the voltage must swing between a negative voltage and a positive voltage to represent logical 0’s and 1’s. The minimum swing normally accepted for this is from -5V to +5v with anything in between being ignored (i.e. 0V).

    • 0-Vcc levels will be recognized by most modern RS-232 hardware. As long as the polarity is correct and this isn’t inverted like TTL, it will work. I can personally attest to these levels working.

  • My biggest complaint about the device is that the surrounding area of the sensor is not matted out. The chip breakout board is not even color neutral and the solder joints are shiny, allowing potential contamination of data if the device is positioned close to the source of light being analyzed. Even the housing is shiny!

    I work with optics and matte black is standard for every device related to light processing, minimizing the bounce and diffusion.

    Perhaps something to consider for the next revision of this thing.

    • Should that matte-r though (pun intended)? I get the impression that the probe is only designed to detect the color of what is directly in front of it, i.e. liquid. How could the reflections off of the housing/solder/etc. even be perceived by the sensor, assuming of course that the container of liquid you are measuring isn’t itself reflective.

  • Is any information available on the field of view or detection range?

  • Can anyone tell where to find more information about the 5 commands this supports. I seem to have it working in a basic way but would like to see what else it supports

    Doh, found it — linky above

Customer Reviews

5 out of 5

Based on 1 ratings:

5 star
1
4 star
0
3 star
0
2 star
0
1 star
0

1 of 1 found this helpful:

A fascinating look into color

Once I was able to get the sample code working, I was fascinated by how well this sensor was able to determine the color of things. It was able to pick up even minor hues of change in the color and it even was able to register some darker grey-ish black parts. A great find!