You are on page 1of 8

ISL 25129 RGB Sensor Tutorial

By: Sabrina Jones

Overview
The ISL29125 RGB sensor is a breakout board made to record the light intensity of the
general red, green, and blue spectrums of visible light, that can be seen in the diagram
below, while rejecting Infrared wavelengths. The rejection of Infrared from different
sources of light allows for the sensor to continue measuring in dark or bright rooms. The
ISL29125 contains three photodiode arrays, which convert light into current. The sensor
requires low power and is highly sensitive to slight changes in light

Connecting to the Arduino


SDA, SCL, 3.3V, GND are the pins that will be used for this tutorial. A description of the
pins can be seen below. The voltage (red) is connected the 3.3 volt power pin on the
Arduino. The ground (black) can be connected to either GND pin. The SDA is connected
to the A4 analog pin while the SCL is connected to the A5 analog pin.
Arduino IDE
Google Arduino IDE and select the first link provided. The subsequent page should look
like this:

Select which computer operating system the computer you will be programming on is
using and click on the Just Download link and follow the instructions to install.

Arduino Libraries
Arduino libraries are a great way to share code. They take a desired action and create
simple functions to allow for this task. The Arduino IDE already comes with a number of
libraries and sketches. One can also write the code from scratch or download the libraries
and import them to use them within a sketch.
For this particular sensor the libraries can be found at Sparkfun.com and search for TSL
29125. This should bring you to a page like the one shown below.

The schematic of the sensor as well as directions to connect the sensor to an


Arduino board are given on the site. Github is a site that offers source code and the
ability to download other programmers code or contribute your own.

Follow the Github link that will lead you to this page:
Click on the green Clone or Download button located on the upper right-hand corner.
And download the zip file.

Once the zip has been downloaded you should be able to go in your download files and
select the uncompressed file labeled SparkFun_ISL29125_Breakout_Arduino_Library-
V_1.0.1

You will be given an examples file, enter the file and choose ISL29125Basics Arduino
file which is the sketch we will be using for this tutorial.

Once the file is open it will start your Arduino IDE and present you with a sketch.

After adding the library/zip file to your Arduino libraries the is ready to go.

To upload your sketch to begin outputting data from the sensor you must connect youre
Arduino board to your computer (with the sensor connected correctly as the previous
diagram presented). To connect the Arduino to your computer you will need a standard
USB 2.0 cable type A to type B.
You must select the port for a usb modem and then upload your code and open the serial
monitor on the upper right-hand corner to view your data output.
Example Program

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

This section is the part that indicates which libraries will be used.

//Declare sensor object


SFE_ISL29125 RGB_sensor;

This part is declaring the sensor that will be used.

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();

This above section is making sure that the data output is categorized for each RGB
photodiode.

//Print out readings, change HEX to DEC if you prefer decimal output
Serial.print("Red: "); Serial.println(red,DEC);
Serial.print("Green: "); Serial.println(green,DEC);
Serial.print("Blue: "); Serial.println(blue,DEC);
Serial.println();
delay(2000); The delay can be adjusted depending on how fast you want to collect
data in milliseconds.
}

The data output will be in nanometer measuring the wavelengths of light from its
surroundings.

Your data should look something like this:

With plenty of light:

Red: 542
Green: 379
Blue: 200

Minimal light:

Red: 67
Green: 32
Blue: 20

You might also like