-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
return half of raw value in both modes involving it resolve #2550 (just for the sensor, no global setting yet)
- Loading branch information
Showing
1 changed file
with
22 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b8921b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now have a decimal reading but presumed the output would either be
#.0
or#.5
for any given light level.With
#define BH1750_MODE BH1750_CONTINUOUS_HIGH_RES_MODE_2
set at build, I'll get#.##
readings, e.g 4.83 then 5.25 on the next 6 second read.Without
#define BH1750_MODE BH1750_CONTINUOUS_HIGH_RES_MODE_2
set at build, I'll get#.#
readings, e.g 4.8 then 5.7 on the next 6 second read.Are the
#.##
two decimal point values read form the sensor or just mathematically calculated values based on read time intervals?b8921b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only other value we could change is MTreg though? aka sensitivity
Sensor seems to already handle spans of time for raw value, we just need to take care of the config.
But, even with doubled MTreg, I think the raw value would be doubled and another multiplication by
69 / 138
aka0.5
would yet again return something close to the originally read one?edit: and meaning, we don't change the raw values too much but only the precision at which they are stored in the sensor reg
b8921b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> 988a972
Slightly different, I'd suggest to use 1s reading interval instead of default 6s
Hopefully not broken :>
b8921b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All still working :-) even at 1 second reads.
The decimal values are still displaying e.g
7.38 or 7.75
or if built without#define BH1750_MODE BH1750_CONTINUOUS_HIGH_RES_MODE_2
,7.9 or 8.2
etc etc.Its not an issue that the values are
#.38 or #.75
etc I just presumed they would either be#.0 or #.5
for any decimal reading.Again, its not an issue I just wondered if the values being displayed were correct?
b8921b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried changing accuracy?
b8921b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the datasheet, it seems it is 'precise up to' not how much the step is. We just grab the latest data directly from the devicce, only thing changing those is MTreg aka accuracy.
btw there is bh1750 driver for Linux, one could easily compare our results connecting to some sbc w/ i2c bus exposed (raspberry pi, etc.)
(ref. https://elixir.bootlin.com/linux/v6.1-rc8/source/drivers/iio/light/bh1750.c; it should be packaged by default, I see one in my /lib/modules/$kernel dir)
b8921b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now. Setting
#define BH1750_ACCURACY 1.44
will give values (at the current brightness) in the range of8.86
and9.21
. I did have a value of10.00
at one point but all other decimal values could be in the range of#.01 - #.99
.Building with accuracy at
1.2
and changing#define BH1750_SENSITIVITY
to1.0, 2.0, 3.0 or 3.68
doesn't affect the value either.I'm happy with the output, it gives me the extra bit of range via the MQTT value every one minute to control the lights I want as per the original issue.
The sensor is built into a housing holding the ESP board so unfortunately I can't easily hook it upto a Linux device.