This new ambient light sensor is packaged in a transparent semisphere case that offers better light gathering power. The sensor supports 0-200klx detection range and I2C communication. 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. It is ideal for applications such as smartphones, vehicle smart light, intelligent incubator, etc.

Luminance data reference

warning_yellow.png NOTE:

  1. This sensor can obtain the intensity of ambient light.
  2. The detected data will be transmitted by IIC. Its IIC address cannot be revised.
  3. Write the necessary configuration into the config register(address: 0x04) to set differernt parameter accuracies.
  4. The light intensity data can be read from the data register(address: 0x00~0x03).
  5. This sensor is sealed by software IIC, and can not be used with other equipment or sensors using hardware IIC.


Board Overview


Num Label Description
1 VCC +
2 SCL IIC Clock Input Pin
3 SDA IIC Data Input Pin
4 GND -
5 EN Sensor Chip-select Enable/Disable port, H to enable, L to disable sensor



Connection Diagram

Connection Diagram

Sample Code

 * @file getLightIntensity.ino
 * @brief Set sensor mode and read light values
 * @n Experimental phenomenon: the light value is read once a second after the sensor device starts successfully
 * @copyright   Copyright (c) 2010 DFRobot Co.Ltd (
 * @licence     The MIT License (MIT)
 * @author [Fary](
 * @version  V1.0
 * @date  2020-12-03
 * @ 
#include <DFRobot_B_LUX_V30B.h>
DFRobot_B_LUX_V30B    myLux(13);//The sensor chip is set to 13 pins, SCL and SDA adopt default configuration
   *   eAutomatic:The default automatic configuration, after using this mode does not have to configure the following mode, IC automatic configuration. 
   *   eManual :Manual configuration. This pattern is configured and used in combination with subsequent patterns
   * CDR
   *   eCDR_0:Don't divide the CDR
   *   eCDR_1: Eight divided the CDR
   * TIM
   *   eTime800ms:The collection time is 800ms
   *   eTime400ms:The collection time is 400ms
   *   eTime200ms:The collection time is 200ms
   *   eTime100mse:The collection time is 100ms
   *   Time50ms:The collection time is 50ms
   *   eTime25ms:The collection time is 25ms
   *   eTime12_5ms:The collection time is 12.5ms
   *   eTime6_25ms:The collection time is 6.25ms
   * Manual mode combination
   *   (The collected value cannot exceed the maximum range of each mode. If the read data exceeds the range, the data is not correct)
   *   eManual+eCDR_0+eTime800ms    mode=64    The maximum value collected is: 2938 (Lux)
   *   eManual+eCDR_0+eTime400ms    mode=65    The maximum value collected is: 5875(lux)
   *   eManual+eCDR_0+eTime200ms    mode=66    The maximum value collected is: 11750(lux)
   *   eManual+eCDR_0+eTime100ms    mode=67    The maximum value collected is: 23501(lux)
   *   eManual+eCDR_0+eTime50ms     mode=68    The maximum value collected is: 47002(lux)
   *   eManual+eCDR_0+eTime25ms     mode=69    The maximum value collected is: 94003(lux)
   *   eManual+eCDR_0+eTime12.50ms  mode=70    The maximum value collected is: 200000(lux)
   *   eManual+eCDR_0+eTime6.25ms   mode=71    The maximum value collected is: 200000(lux)
   *   eManual+eCDR_1+eTime800ms    mode=72    The maximum value collected is: 23501(lux)
   *   eManual+eCDR_1+eTime400ms    mode=73    The maximum value collected is: 47002(lux)
   *   eManual+eCDR_1+eTime200ms    mode=74    The maximum value collected is: 94003(lux)
   *   eManual+eCDR_1+eTime100ms    mode=75    The maximum value collected is: 200000(lux)
   *   eManual+eCDR_1+eTime50ms     mode=76    The maximum value collected is: 200000(lux)
   *   eManual+eCDR_1+eTime25ms     mode=77    The maximum value collected is: 200000(lux)
   *   eManual+eCDR_1+eTime12.50ms  mode=78    The maximum value collected is: 200000(lux)
   *   eManual+eCDR_1+eTime6.25ms   mode=79    The maximum value collected is: 200000(lux)
void setup() {
   * The setMode and readMode functions can be omitted. When not configured, the default configuration is the one used last time.
   * When using the setMode function, its return value should be judged. If the return value is 1, the setting is successful.
   * while(!myLux.setMode(myLux.eManual,myLux.eCDR_0,myLux.eTime800ms));
   * Serial.print("mode: ");
   * Serial.println(myLux.readMode());

void loop() {
  Serial.print("value: ");
  Serial.println(" (lux).");

Expected Results

Check the detected light value on the serial monitor.



For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Get Ambient Light Sensor(0-200klx) from DFRobot Store or DFRobot Distributor.

Turn to the Top