LinkIt One and MAX44009 ambient light sensor example

The MAX44009 ambient light sensor features an I²C digital output that is ideal for a number of portable applications such as smartphones, notebooks, and industrial sensors. At less than 1µA operating current, it is the lowest power ambient light sensor in the industry and features an ultra-wide 22-bit dynamic range from 0.045 lux to 188,000 lux.

Low-light operation allows easy operation in dark-glass applications.

The on-chip photodiode’s spectral response is optimized to mimic the human eye’s perception of ambient light and incorporates IR and UV blocking capability. The adaptive gain block automatically selects the correct lux range to optimize the counts/lux.

Here is a low cost module available that makes the sensor easier to work with

Features

Wide 0.045 Lux to 188,000 Lux Range
VCC = 1.7V to 3.6V
ICC = 0.65µA Operating Current
-40°C to +85°C Temperature Range
Device Address Options – 1001 010x and 1001 011x

 

Connection

Module Pin linkit One Pin
 Vin 3v3
 Gnd Gnd
 SCL SCL
SDA SDA

 

 

Code

 

[codesyntax lang=”cpp”]

#include<Wire.h>

#define Addr 0x4A

void setup()
{

Wire.begin();
// Initialise serial communication
Serial.begin(9600);

Wire.beginTransmission(Addr);
Wire.write(0x02);
Wire.write(0x40);
Wire.endTransmission();
delay(300);
}

void loop()
{
unsigned int data[2];
Wire.beginTransmission(Addr);
Wire.write(0x03);
Wire.endTransmission();

// Request 2 bytes of data
Wire.requestFrom(Addr, 2);

// Read 2 bytes of data luminance msb, luminance lsb
if (Wire.available() == 2)
{
data[0] = Wire.read();
data[1] = Wire.read();
}

// Convert the data to lux
int exponent = (data[0] & 0xF0) >> 4;
int mantissa = ((data[0] & 0x0F) << 4) | (data[1] & 0x0F);
float luminance = pow(2, exponent) * mantissa * 0.045;

Serial.print("Ambient Light luminance :");
Serial.print(luminance);
Serial.println(" lux");
delay(500);
}

[/codesyntax]

 

Output

Open the serial monitor and change the light intensity on the sensor, here is an example

Ambient Light luminance :30.60 lux
Ambient Light luminance :24.48 lux
Ambient Light luminance :24.48 lux
Ambient Light luminance :171.36 lux
Ambient Light luminance :122.40 lux
Ambient Light luminance :122.40 lux
Ambient Light luminance :195.84 lux
Ambient Light luminance :220.32 lux
Ambient Light luminance :220.32 lux
Ambient Light luminance :195.84 lux
Ambient Light luminance :195.84 lux
Ambient Light luminance :1175.04 lux
Ambient Light luminance :110.16 lux
Ambient Light luminance :110.16 lux
Ambient Light luminance :27.54 lux
Ambient Light luminance :36.72 lux
Ambient Light luminance :36.72 lux
Ambient Light luminance :24.48 lux
Ambient Light luminance :0.00 lux

Link

https://datasheets.maximintegrated.com/en/ds/MAX44009.pdf

MAX44009 Ambient Light Sensor Module with 4P Pin Header