OPT3001 ambient light sensor
The TI OPT3001 measures light in lux the way the eye sees it, from 0.01 to 83865 lux, auto-ranging, over I2C at 0x44.
Aliases: OPT3001 module, CJMCU-3001, ClosedCube OPT3001, lux meter. Its filter blocks infrared, so it agrees with the eye where a plain photodiode reads high under incandescent light. A screen dims with it; a greenhouse logs with it.
Pins
| Pin | What it does |
|---|---|
VCC, GND |
Supply, 3 to 5 V on the board. |
SCL, SDA |
I2C. The board carries the pull-ups. |
INT |
The limit or conversion-ready interrupt, active low. |
Properties
address, 0x44 to 0x47. lux is the light; the slider changes it.
Reading it on an Arduino
With ClosedCube's library, which Mokxi ships as ClosedCube_OPT3001.h:
#include <ClosedCube_OPT3001.h>
ClosedCube_OPT3001 opt3001;
void setup() {
Serial.begin(9600);
opt3001.begin(0x44);
OPT3001_Config config;
config.rawData = 0;
config.RangeNumber = 0b1100;
config.ModeOfConversionOperation = 0b11;
opt3001.writeConfig(config);
}
void loop() {
Serial.println(opt3001.readResult().lux);
delay(500);
}
How it talks
Sixteen-bit registers: 0x00 the result, an exponent and a twelve-bit mantissa, lux = 0.01 x 2^E x R; 0x01 the configuration (range, 100 or 800 ms, the mode and the flags);
0x02 and 0x03 the limits; 0x7E 0x5449 and 0x7F 0x3001. It powers up shut down;
continuous mode converts every 100 or 800 ms and sets the conversion ready flag, which
reading the configuration clears.
What it does not model
The fault count and the spectral response: the slider is the reading.
Common mistakes
Reading the result before a conversion has finished: it reads zero until the first one, 100 or 800 ms after the mode is set.