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.
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
Parts Required
Here are the parts I used
Name | Link | |
ESP32 | ||
MAX44009 | ||
Connecting cables |
Connection
Module Pin | LOLIN32 Pin |
Vin | 3v3 |
Gnd | Gnd |
SCL | 22 |
SDA | 21 |
Code
#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); }
Output
Open the serial monitor and change the light intensity on the sensor, here is an example
Ambient Light luminance :24.48 lux
Ambient Light luminance :21.42 lux
Ambient Light luminance :21.42 lux
Ambient Light luminance :9.94 lux
Ambient Light luminance :9.94 lux
Ambient Light luminance :13.77 lux
Ambient Light luminance :22.95 lux
Ambient Light luminance :22.95 lux
Ambient Light luminance :42.84 lux
Ambient Light luminance :55.08 lux
Ambient Light luminance :55.08 lux
Ambient Light luminance :55.08 lux
This handy little table from wikipedia shows some typical lux values
Illuminance (lux) | Surfaces illuminated by |
0.0001 | Moonless, overcast night sky (starlight) |
0.002 | Moonless clear night sky with airglow |
0.05–0.36 | Full moon on a clear night[4] |
3.4 | Dark limit of civil twilight under a clear sky |
20–50 | Public areas with dark surroundings |
50 | Family living room lights |
80 | Office building hallway/toilet lighting |
100 | Very dark overcast day |
320–500 | Office lighting |
400 | Sunrise or sunset on a clear day. |
1000 | Overcast day; typical TV studio lighting |
10,000–25,000 | Full daylight (not direct sun) |
32,000–100,000 | Direct sunlight |
Link
https://datasheets.maximintegrated.com/en/ds/MAX44009.pdf