Library for BH1750 I2C light sensor. Supports autoranging! True to datasheet. (beware: calls are blocking at the moment)
So there is this light sensor (like the one present in any phone),
I got mine soldered to some nice breakout board.
Few facts about this library: it is very true to the datasheet. it takes advantage of MTreg (time of measurement), which lets you to increase resolution up to 3.86 times at the cost of time it takes to perform a measurement. Measurement is blocking ! I've also implemented an autoranging feature. Just like in those fancy multimeters! It works as follows, thresholds are hard-coded:
- <5 lx switches to Hi-res2 and to max MTreg (so measurement time is like 500ms)
- <1000 lx Hi-res, MTreg default.
- above there is no real need for Hi-res, so Low-res mode is used.
Last note: I greatly recommend you to use log10 value of the luminosity data. it makes much more sense, because it becomes linear.