VEML6040 color sensor senses red, green, blue, and white light and incorporates photodiodes, amplifiers, and analog / digital circuits into a single chip using CMOS process.
With the color sensor applied, the brightness, and color temperature of backlight can be adjusted base on ambient light source that makes panel looks more comfortable for end user’s eyes. VEML6040’s adoption of FiltronTM technology achieves the closest ambient light spectral sensitivity to real human eye responses.
VEML6040 provides excellent temperature compensation capability for keeping the output stable under changing temperature. VEML6040’s function are easily operated via the simple command format of I2C (SMBus compatible) interface protocol. VEML6040’s operating voltage ranges from 2.5 V to 3.6 V.
Schematics/Layout
An I2C device
Code
Again we use a library – https://github.com/thewknd/VEML6040
This example worked just fine
[codesyntax lang=”cpp”]
#include “Wire.h”
#include “veml6040.h”
VEML6040 RGBWSensor;
void setup() {
Serial.begin(9600);
Wire.begin();
if(!RGBWSensor.begin()) {
Serial.println(“ERROR: couldn't detect the sensor”);
while(1){}
}
/*
* init RGBW sensor with:
* – 320ms integration time
* – auto mode
* – color sensor enable
*/
RGBWSensor.setConfiguration(VEML6040_IT_320MS + VEML6040_AF_AUTO + VEML6040_SD_ENABLE);
delay(1500);
Serial.println(“Vishay VEML6040 RGBW color sensor auto mode example”);
Serial.println(“CCT: Correlated color temperature in \260K”);
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);
}
[/cpp]
Output
Open the serial monitor – this is what I saw
Links
https://www.vishay.com/docs/84276/veml6040.pdf
VEML6040 Breakout Vishay RGBW Sensor Module