How to Use Color Sensor Module

Photo of a color sensor module

You can check the color of objects. Colors are displayed in RGB (red, green, blue) data.

About the Component

Photo explaining the sensor position of the color sensor module

The sensor located at the red circle in the photo outputs analog signals (numbers from 0 to 255) indicating the size of each color element. SPACEBLOCK communicates with it using I2C communication using two signal lines, SDA and SCL.

※ Please note that while the color sensor can obtain the size of each color element, it cannot obtain the actual color code.

Photo of the back of the color sensor module

Measure by bringing the back of the sensor into close contact with the object you want to measure.

About I2C

I2C communication uses two signal lines, SDA and SCL. SDA stands for Serial Data and is the signal line for data. SCL stands for Serial Clock and is the signal line for the clock.

Specifications

Voltage5V
Communication MethodI2C
Measurement Distance 3~10mm
Temperature Range-30~70℃
Size 34 x 20 (mm)

Connection

Connect the color sensor module and the SPACEBLOCK microcontroller board using jumper wires (male-female) as follows:

  • Color sensor module's SCL pin to SPACEBLOCK's I2C compatible pin
  • Color sensor module's SDA pin to SPACEBLOCK's I2C compatible pin
  • Color sensor module's G pin to SPACEBLOCK's GND
  • Color sensor module's 5V pin to SPACEBLOCK's 5V
    Connection method between SPACEBLOCK microcontroller board and color sensor module

    ※ The image shows a diagram where the signal lines are connected to the B1 and B3 pins. I2C compatible pins are combinations of B1 and B3, or B0 and B2.

    ※ 5V and GND can also be inserted into the pins with the same markings on the SPACEBLOCK microcontroller board.

    Usage

    When the back of the sensor is in close contact with the object to be measured, it returns a value.
    The larger each color element is, the larger the value will be.
    You can retrieve values from the color sensor module using the block in the 'Input' category of your project.


    For detailed usage of the block, click here.

    Read ~ with the color sensor