Home » ESP32 and ISL29125 RGB color light sensor

ESP32 and ISL29125 RGB color light sensor

by shedboy71

In this example we look at the ISL29125 RED, GREEN and BLUE color light sensor

Here is some info about the sensor

The ISL29125 is a low power, high sensitivity, RED, GREEN and BLUE color light sensor (RGB) with an I2 C (SMBus compatible) interface. Its state-of-the-art photodiode array provides an accurate RGB spectral response and excellent light source to light source variation (LS2LS).

The ISL29125 is designed to reject IR in light sources allowing the device to operate in environments from sunlight to dark rooms. The integrating ADC rejects 50Hz and 60Hz flicker caused by artificial light sources. A selectable range allows the user to optimize sensitivity suitable for the specific application.

In normal operation mode the device consumes 56µA, which reduces to 0.5µA in power-down mode. The ISL29125 supports hardware and software user programmable interrupt thresholds.

The Interrupt persistency feature reduces false trigger notification. The device operates on supplies (VDD) from 2.25V to 3.63V, I2 C supply from 1.7V to 3.63V, and operating temperature across the -40°C to +85°C range.

FEATURES

  • 56µA operating current, 0.5µA shutdown current
  • Selectable range (Via I2C)
  • I2C (SMBus compatible) output
  • ADC resolution 16 bits
  • Programmable interrupt windows
  • Two optical sensitivity ranges
  • Range 0 = 5.7m lux to 375 lux
  • Range 1 = 0.152 lux to 10,000 lux
  • Operating power supply 2.25 to 3.63V
  • I2C power supply 1.7V to 3.63V
  • 6 Ld ODFN (1.65×1.65×0.7mm) package

 

Connection

 

Lolin32 CJMCU-0401 module
3v3 Vcc
Gnd Gnd
21 – SDA SDA
22 – SCL SCL

Parts List

Here are the parts I used

Name Link
ESP32
ISL29125
Connecting cables

 

Code

This example requires the https://github.com/sparkfun/SparkFun_ISL29125_Breakout_Arduino_Library

#include <Wire.h>
#include "SparkFunISL29125.h"

// Declare sensor object
SFE_ISL29125 RGB_sensor;

void setup()
{
  // Initialize serial communication
  Serial.begin(115200);

  // Initialize the ISL29125 with simple configuration so it starts sampling
  if (RGB_sensor.init())
  {
    Serial.println("Sensor Initialization Successful\n\r");
  }
}

// Read sensor values for each color and print them to serial monitor
void loop()
{
  // Read sensor values (16 bit integers)
  unsigned int red = RGB_sensor.readRed();
  unsigned int green = RGB_sensor.readGreen();
  unsigned int blue = RGB_sensor.readBlue();
  
  // Print out readings, change HEX to DEC if you prefer decimal output
  Serial.print("Red: "); Serial.println(red,HEX);
  Serial.print("Green: "); Serial.println(green,HEX);
  Serial.print("Blue: "); Serial.println(blue,HEX);
  Serial.println();
  delay(2000);
}

 

Output

 

Links

 

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.