Skip to content

Instantly share code, notes, and snippets.

@houmei
Created July 15, 2016 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save houmei/60255efe8029ca7a79e51a9c698a34ab to your computer and use it in GitHub Desktop.
Save houmei/60255efe8029ca7a79e51a9c698a34ab to your computer and use it in GitHub Desktop.
GY302module(BH1750FVI) lux meter
/* GY-302(BH1750FVI) test
Library: https://cmosgr.wordpress.com/2013/09/02/bh1750fvi-gy-302-light-sensor-module/
ADDR - A3(GND)
SDA - SDA(A4)
SCL - SCL(A5)
GND
VCC
*/
#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter;
void setup(){
pinMode(A3,OUTPUT); digitalWrite(A3,0);
Serial.begin(9600);
lightMeter.begin();
Serial.println("Running…");
}
void loop() {
uint16_t lux = lightMeter.readLightLevel();
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment