Product Introduction #
The Color Sensor is an optical sensing to recognize the surface color of an object. Support red, green, blue (RGB) three basic colors, support bright light induction, can output the corresponding specific value, restore the actual color. The onboard comes with two bright LEDs, which allows the sensor to use normally in the case of low ambient light, realizing the function of “filling light filling”.
Application reference: color calibration device, color printer, plotter, etc.
Parameter Specification #
Parameter | Value/Description |
Operating voltage | 3.3V-5V |
Detection distance | 3-10mm |
Output protocol | I2C |
Operating temperature | -30°C~+70°C |
Size | 3.2cm*2.4cm |
Wiring Diagram #
Note: Expansion board is attached to esp32 controller board.
Color Sensor | ESP32 |
SCL | SCL |
SDA | SDA |
VCC | 5V |
GND | GND |
Sample Code #
#include <ACB_ColorSensor.h>//Import a library of color sensor
#define R “red” //Define the name of the string
#define G “green”
#define B “blue”
ACB_ColorSensor colorSensor; //Create a sensor object
int red_value;//Store color sensor red light values
int green_value;//Store color sensor green light values
int blue_value;//Store color sensor blue light values
void setup() {
Serial.begin(115200);
}
void loop() {
red_value = colorSensor.read(R);
green_value = colorSensor.read(G);
blue_value = colorSensor.read(B);
//Print color value
Serial.print(“R:”);
Serial.println(red_value);
Serial.print(“G:”);
Serial.println(green_value);
Serial.print(“B:”);
Serial.println(blue_value);
}
Note: If you are using an Arduino board, then connect the SCL pin of the Color Sensor to the PIN A5 of the Arduino and the SDA pin to the PIN A4 of the Arduino, set the baud rate to 9600, and upload the program.
Test Result #
After you successfully connect the line according to the wiring diagram and successfully upload the correct program, please turn on the LED light switch of the color sensor, and then put it on different colors. The serial port monitor will output the data of red, green and blue three primary colors.
Related Resources #
Get One Now #
B2B Business: info@acebott.com