claws / BH1750

An Arduino library for the digital light sensor breakout boards containing the BH1750FVI IC
MIT License
248 stars 107 forks source link

Huge difference in readings CONTINUOUS_HIGH_RES_MODE vs CONTINUOUS_HIGH_RES_MODE_2 #49

Closed wilhelmzeuschner closed 5 years ago

wilhelmzeuschner commented 5 years ago

I get very different readings, which differ by a factor of ~2: 1) CONTINUOUS_HIGH_RES_MODE gives me: 160 "lx" under a bright LED bulb, but facing the wall. 2) CONTINUOUS_HIGH_RES_MODE_2 gives me: 320 "lx" in the same environment.

Example: 1) 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 161 | 2) 227 | 234 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | 324 | (at first I was covering the sensor a bit)

Which one of these readings is correct and what went wrong with the other one? Sadly I cannot really guess which one is correct because I cant really put them in perspective, i.e. I have no idea what to expect. My question is not, which of these readings is correct for my particular scenario, rather which one is correctly calculated / measured.

coelner commented 5 years ago

That is correct because you get a shifted value for the Mode2. It is documented in the datasheet. I am currently working on additional functionality but the patches are not ready yet. Simple solution is to divide the Mode2 values with 2.

coelner commented 5 years ago

@wilhelmzeuschner #46 it is currently in beta status, but your problem is solved

https://github.com/coelner/BH1750/blob/a30562d2783f6bfafb75190a06fd950f9b58a68f/BH1750.cpp#L285-L287

claws commented 5 years ago

Closing this issue as #46 is now merged.