The VEML6040 is a compact digital color sensor developed by Vishay. It measures red, green, blue, and white (RGBW) light intensity using photodiodes and provides digital output through the I²C interface.
It can be used to detect ambient light, estimate correlated color temperature, and read raw RGBW light values, making it useful for lighting control, color detection, display brightness adjustment, and environmental sensing projects.
VEML6040 RGBW color sensor module
VEML6040 module view
Specifications
| Parameter | Value |
|---|---|
| I2C Address | 0x10 |
| Measurement | RGBW light intensity |
| Channels | Red, Green, Blue, White |
| Output | Digital values via I2C |
| Extra Measurements | Ambient light and correlated color temperature |
| Interface | I2C |
Library Installation
To use this sensor with Arduino, install a compatible VEML6040 library using the Arduino Library Manager.
- Open the Arduino IDE.
- Go to Sketch → Include Library → Manage Libraries...
- Search for
VEML6040. - Install a compatible library, such as
VEML6040 by thewknd.
Example
#include <Wire.h>
#include "veml6040.h"
VEML6040 RGBWSensor;
void setup() {
Serial.begin(9600);
Wire.begin(2, 0);
if (!RGBWSensor.begin()) {
Serial.println("ERROR: couldn't detect the sensor");
while (1) {}
}
RGBWSensor.setConfiguration(
VEML6040_IT_320MS +
VEML6040_AF_AUTO +
VEML6040_SD_ENABLE
);
delay(1500);
Serial.println("Vishay VEML6040 RGBW color sensor");
Serial.println("CCT: Correlated Color Temperature in Kelvin");
Serial.println("AL: Ambient Light in lux");
delay(1500);
}
void loop() {
Serial.print("RED: ");
Serial.print(RGBWSensor.getRed());
Serial.print(" GREEN: ");
Serial.print(RGBWSensor.getGreen());
Serial.print(" BLUE: ");
Serial.print(RGBWSensor.getBlue());
Serial.print(" WHITE: ");
Serial.print(RGBWSensor.getWhite());
Serial.print(" CCT: ");
Serial.print(RGBWSensor.getCCT());
Serial.print(" AL: ");
Serial.println(RGBWSensor.getAmbientLight());
delay(400);
}
The code initializes the VEML6040 sensor through the I2C bus and configures it with an integration time of 320 ms. In the main loop, the sensor reads the red, green, blue, and white channels, as well as the estimated correlated color temperature and ambient light level.
Output
The VEML6040 provides raw RGBW values and calculated light information. These values are useful for color sensing, light monitoring, and automatic brightness control projects.
| Measurement | Method | Range | Unit | Description |
|---|---|---|---|---|
| Red | getRed() |
0 – 65535 | Raw value | Light intensity measured on the red channel. |
| Green | getGreen() |
0 – 65535 | Raw value | Light intensity measured on the green channel. |
| Blue | getBlue() |
0 – 65535 | Raw value | Light intensity measured on the blue channel. |
| White | getWhite() |
0 – 65535 | Raw value | Total white light intensity detected by the sensor. |
| Correlated Color Temperature | getCCT() |
~2000 – ~10000 | Kelvin | Indicates whether the detected light is warmer or cooler. |
| Ambient Light | getAmbientLight() |
Depends on configuration | Lux | Estimated ambient light intensity. |
Note: The RGBW raw values can vary depending on the configured integration time and gain. A longer integration time, such as 320 ms, increases sensitivity and may produce higher readings in low-light conditions.
ESP8266