Another sensor to add to the collection for my Home Weather Station project. I’m adding a Lux level sensor so that I can record the Lux levels thorughout the day. Not sure what for yet, perhaps for some automated sensors, or just to add to it. The more sensors the merrier I say. The better the readings and the more data you can log
What code am I using?
This is the code I’m using on my ESP8266 mini. I’m switching because my Arduino Nano doesn’t have built in WiFi and this device is more powerful and supports Arduino
#include <BH1750.h>
#include <Wire.h>
BH1750 lightMeter;
void setup() {
Serial.begin(115200);
// 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);
// For Wemos / Lolin D1 Mini Pro and the Ambient Light shield use
// Wire.begin(D2, D1);
lightMeter.begin();
Serial.println(F(“BH1750 Test begin”));
}
void loop() {
float lux = lightMeter.readLightLevel();
Serial.print(“Light: “);
Serial.print(lux);
Serial.println(” lx”);
delay(500);
}