GY-302 BH1750 Digital Light Intensity Module

From Wiki
Revision as of 09:53, 15 October 2019 by Root (Talk | contribs) (Experimental Procedures for Arduino)

Jump to: navigation, search

Introduction

GY-302 1.jpg GY-302 2.jpg
BH1750FVI is a digital Ambient Light Sensor IC for I2C bus interface. This IC is the most suitable to receive the ambient light data for adjusting LCD and Keypad backlight power of Mobile phone. It is possible to detect wide range at High resolution.(1 – 65535 lx)

Features

1. Type: GY-302;
2. Size: 13.9mm x 18.5mm;
3. ROHM original package BH1750FVI chip;
4. Power Supply: 3~5V;
5. Date Range: 0~65535;
6. Sensor build-in 16-bit AD converter;
7. Direct digital output, omit complex calculations and calibration;
8. No ambient light distinction;
9. Dichroism close to visual sensitivity;
10. High precision determination accurate to 1 Lu for different lights.

Introduction of Pins

Introduction of Pins
GND Cathode of power supply.
VCC Anode of power supply connected to 3~5V.
SCL I²C clock
SDA I²C data
ADDR IIC address pin

Experimental Procedures for Arduino

Experimental Procedures for Arduino

Step 1: Connect the circuit:

GY-302 Sunfounder Uno
VCC VCC
GND GND
SDA A4
SCL A5
ADDR

Step 1: Connect the circuit:
GY-302 4.jpg
Step 2: Compile and upload the code.

/*
 Sample code for the BH1750 Light sensor
  
 Connection:
 VCC-5v
 GND-GND
 SCL-SCL(analog pin 5)
 SDA-SDA(analog pin 4)
 ADD-NC
 */
#include <Wire.h> //BH1750 IIC Mode 
#include <math.h> 
int BH1750address = 0x23; //setting i2c address
 
byte buff[2];
void setup()
{
  Wire.begin();
  Serial.begin(57600);//init Serial rate
}
 
void loop()
{
  int i;
  uint16_t val=0;
  BH1750_Init(BH1750address);
  delay(200);
 
  if(2==BH1750_Read(BH1750address))
  {
    val=((buff[0]<<8)|buff[1])/1.2;
    Serial.print(val,DEC);     
    Serial.println("[lx]"); 
  }
  delay(150);
}
 
int BH1750_Read(int address) //
{
  int i=0;
  Wire.beginTransmission(address);
  Wire.requestFrom(address, 2);
  while(Wire.available()) //
  {
    buff[i] = Wire.read();  // receive one byte
    i++;
  }
  Wire.endTransmission();  
  return i;
}
 
void BH1750_Init(int address) 
{
  Wire.beginTransmission(address);
  Wire.write(0x10);//1lx reolution 120ms
  Wire.endTransmission();
}

GY-302 5.jpg