Gravity: I2C Waterproof Ambient Light Sensor 1-65535lx

Introduction

This waterproof digital ambient light sensor is designed to deliver accurate measurements of light intensity within the range of 1-65535lx. It incorporates a 50Hz/60Hz light noise reject function that ensures stable and reliable performance.
With an easy-to-use Gravity interface and I2C communication, the ambient light sensor is incredibly user-friendly for using with main-controllers like Arduino UNO. Plus, the sensor features an IP68 waterproof rating, which means it can be fully immersed in water without suffering any damage. This makes it perfect for outdoor projects that require reliable light measurement in harsh environments, such as vegetable greenhouses, smart car lights, and weather stations.

Brightness Reference:

Specification

Board Overview

Color Label Description
Green SDA I2C Data Input
Yellow SCL I2C Clock Input
Blue GND Power -
Red VCC Power +

Dimension

Tutorial

Requirements

Connection Diagram

Sample Code

#include "Wire.h"
#define address 0x23                 //I2C Address 0x23
void setup()
{
  Serial.begin(9600);
  Wire.begin();
}
uint8_t buf[4] = {0};
uint16_t data, data1;
float Lux;
void loop()
{
  readReg(0x10, buf, 2);              //Register Address 0x10
  data = buf[0] << 8 | buf[1];
  Lux = (((float)data )/1.2);
  Serial.print("LUX:");
  Serial.print(Lux);
  Serial.print("lx");
  Serial.print("\n");
  delay(500);
}
uint8_t readReg(uint8_t reg, const void* pBuf, size_t size)
{
  if (pBuf == NULL) {
    Serial.println("pBuf ERROR!! : null pointer");
  }
  uint8_t * _pBuf = (uint8_t *)pBuf;
  Wire.beginTransmission(address);
  Wire.write(&reg, 1);
  if ( Wire.endTransmission() != 0) {
    return 0;
  }
  delay(20);
  Wire.requestFrom(address, (uint8_t) size);
  for (uint16_t i = 0; i < size; i++) {
    _pBuf[i] = Wire.read();
  }
  return size;
}

Expected Results

The light value collected by the sensor can be viewed on serial monitor.

FAQ

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

More Documents

DFshopping_car1.png Get Gravity Waterproof Ambient Light Sensor 1-65535lx from DFRobot Store or DFRobot Distributor.

Turn to the Top