OPT3001 Digital Ambient Light Sensor and LinkIt one example

In this example we will connect an OPT3001 to a linkIt one

The OPT3001 is a sensor that measures the intensity of visible light. The spectral response of the sensor tightly matches the photopic response of the human eye and includes significant infrared rejection.

The OPT3001 is a single-chip lux meter, measuring the intensity of light as visible by the human eye. The precision spectral response and strong IR rejection of the device enables the OPT3001 to accurately meter the intensity of light as seen by the human eye regardless of light source. The strong IR rejection also aids in maintaining high accuracy when industrial design calls for mounting the sensor under dark glass for aesthetics. The OPT3001 is designed for systems that create light-based experiences for humans, and an ideal preferred replacement for photodiodes, photoresistors, or other ambient light sensors with less human eye matching and IR rejection.

Measurements can be made from 0.01 lux up to 83k lux without manually selecting full-scale ranges by using the built-in, full-scale setting feature. This capability allows light measurement over a 23-bit effective dynamic range.

The digital operation is flexible for system integration. Measurements can be either continuous or single-shot. The control and interrupt system features autonomous operation, allowing the processor to sleep while the sensor searches for appropriate wake-up events to report via the interrupt pin. The digital output is reported over an I2C- and SMBus-compatible, two-wire serial interface.



  • Precision Optical Filtering to Match Human Eye:
    • Rejects > 99% (typ) of IR
  • Automatic Full-Scale Setting Feature Simplifies Software and Ensures Proper Configuration
  • Measurements: 0.01 lux to 83 k lux
  • 23-Bit Effective Dynamic Range With
    Automatic Gain Ranging
  • 12 Binary-Weighted Full-Scale Range Settings:
    < 0.2% (typ) Matching Between Ranges
  • Low Operating Current: 1.8 µA (typ)
  • Operating Temperature Range: –40°C to +85°C
  • Wide Power-Supply Range: 1.6 V to 3.6 V
  • 5.5-V Tolerant I/O



Linkit CJMCU-3001
3v3 Vcc
Gnd Gnd


This example uses the following library https://github.com/closedcube/ClosedCube_OPT3001_Arduino

[codesyntax lang=”cpp”]


This is example for ClosedCube OPT3001 Digital Ambient Light Sensor breakout board 

Initial Date: 02-Dec-2015

Hardware connections for Arduino Uno:
VDD to 3.3V DC
SDA to A4
SCL to A5
GND to common ground

Written by AA for ClosedCube

MIT License


#include <Wire.h>
#include <ClosedCube_OPT3001.h>

ClosedCube_OPT3001 opt3001;

#define OPT3001_ADDRESS 0x44

void setup()
	Serial.println("ClosedCube OPT3001 Arduino Test");

	Serial.print("OPT3001 Manufacturer ID");
	Serial.print("OPT3001 Device ID");

	printResult("High-Limit", opt3001.readHighLimit());
	printResult("Low-Limit", opt3001.readLowLimit());

void loop()
	OPT3001 result = opt3001.readResult();
	printResult("OPT3001", result);

void configureSensor() {
	OPT3001_Config newConfig;
	newConfig.RangeNumber = B1100;	
	newConfig.ConvertionTime = B0;
	newConfig.Latch = B1;
	newConfig.ModeOfConversionOperation = B11;

	OPT3001_ErrorCode errorConfig = opt3001.writeConfig(newConfig);
	if (errorConfig != NO_ERROR)
		printError("OPT3001 configuration", errorConfig);
	else {
		OPT3001_Config sensorConfig = opt3001.readConfig();
		Serial.println("OPT3001 Current Config:");
		Serial.print("Conversion ready (R):");

		Serial.print("Conversion time (R/W):");
		Serial.println(sensorConfig.ConvertionTime, HEX);

		Serial.print("Fault count field (R/W):");
		Serial.println(sensorConfig.FaultCount, HEX);

		Serial.print("Flag high field (R-only):");
		Serial.println(sensorConfig.FlagHigh, HEX);

		Serial.print("Flag low field (R-only):");
		Serial.println(sensorConfig.FlagLow, HEX);

		Serial.print("Latch field (R/W):");
		Serial.println(sensorConfig.Latch, HEX);

		Serial.print("Mask exponent field (R/W):");
		Serial.println(sensorConfig.MaskExponent, HEX);

		Serial.print("Mode of conversion operation (R/W):");
		Serial.println(sensorConfig.ModeOfConversionOperation, HEX);

		Serial.print("Polarity field (R/W):");
		Serial.println(sensorConfig.Polarity, HEX);

		Serial.print("Overflow flag (R-only):");
		Serial.println(sensorConfig.OverflowFlag, HEX);

		Serial.print("Range number (R/W):");
		Serial.println(sensorConfig.RangeNumber, HEX);


void printResult(String text, OPT3001 result) {
	if (result.error == NO_ERROR) {
		Serial.print(": ");
		Serial.println(" lux");
	else {

void printError(String text, OPT3001_ErrorCode error) {
	Serial.print(": [ERROR] Code #");



Open the serial monitor and you should see something like this

OPT3001: 117.44 lux
OPT3001: 117.40 lux
OPT3001: 118.72 lux
OPT3001: 170.88 lux
OPT3001: 230.80 lux
OPT3001: 36.38 lux
OPT3001: 14.03 lux
OPT3001: 26.52 lux
OPT3001: 25.64 lux
OPT3001: 25.73 lux
OPT3001: 25.57 lux
OPT3001: 13.03 lux
OPT3001: 25.24 lux
OPT3001: 19.21 lux
OPT3001: 18.50 lux


OPT3001 CJMCU-3001 ambient light sensor eye like measurement light intensity single chip illumination meter