adding the BH1750 from their downloads

This commit is contained in:
Roald Batts 2023-01-15 18:37:43 -05:00
parent f92231dbff
commit 064a8ffd26
16 changed files with 1023 additions and 0 deletions

View file

@ -0,0 +1,44 @@
/*
Example of BH1750 library usage.
This example initialises the BH1750 object using the high resolution
one-time mode and then makes a light level reading every second.
The BH1750 component starts up in default mode when it next powers up.
The BH1750 library automatically reconfigures the one-time mode in
preparation for the next measurement.
*/
#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter;
void setup(){
Serial.begin(9600);
// Initialize the I2C bus (BH1750 library doesn't do this automatically)
Wire.begin();
// On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3);
lightMeter.begin(BH1750::ONE_TIME_HIGH_RES_MODE);
Serial.println(F("BH1750 One-Time Test"));
}
void loop() {
while (!lightMeter.measurementReady(true)) {
yield();
}
float lux = lightMeter.readLightLevel();
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");
lightMeter.configure(BH1750::ONE_TIME_HIGH_RES_MODE);
}