Difference between revisions of "Light sensor"

From ElectroDragon
Jump to: navigation, search
(Guide)
Line 7: Line 7:
 
* See pin difinition on left image  
 
* See pin difinition on left image  
 
[[File:Specification GY30.jpg|thumbnail]]
 
[[File:Specification GY30.jpg|thumbnail]]
<syntaxhighlight lang="Arduino">
+
* Demo code please see our github
#include <Wire.h> //IIC
+
#include <math.h>
+
 
+
int BH1750address = 0x23;
+
byte buff[2];
+
 
+
void setup()
+
{
+
  Wire.begin();
+
  Serial.begin(9600);
+
}
+
 
+
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.receive();  // receive one byte
+
    i++;
+
  }
+
  Wire.endTransmission(); 
+
  return i;
+
}
+
 
+
void BH1750_Init(int address)
+
{
+
  Wire.beginTransmission(address);
+
  Wire.send(0x10);//1lx reolution 120ms
+
  Wire.endTransmission();
+
}
+
</syntaxhighlight>
+
 
+
 
== Guide ==
 
== Guide ==
 
* Ambient light sensor
 
* Ambient light sensor

Revision as of 14:56, 15 April 2018

Schematic

Arduino Demo Code BH1750

  • See pin difinition on left image
Specification GY30.jpg
  • Demo code please see our github

Guide

  • Ambient light sensor
Header text Resolution ADC output
BH1750 1 - 65535 lx 16 bit digital
TSL2561 0.1 - 40,000+ 16 bit digital
TEMT6000 - -
CdS cell 5528 - -
  • TEMT6000
Wide angle of half sensitivity ϕ = ± 60°
Adapted to human eye responsivity
Wavelength of Peak Sensitivity 570 nm

Documents

BH1750

TSL2561

5528