Skip to content

setQuality

Starmbi edited this page Jan 12, 2020 · 15 revisions

setQuality

sets the Quality for the next measurement.

void setQuality(BH1750Quality quality);

result void

Internal, at start() the Quality must be send. So, with this function no real call to the sensor is made.


Parameter BH1750Quality

enum BH1750Quality
{
BH1750_QUALITY_HIGH = 0x20,
BH1750_QUALITY_HIGH2 = 0x21,
BH1750_QUALITY_LOW = 0x23,
};

Here a table for comparison of the range and precision of different MTreg's and qualities:

Quality MTreg resolution lux highest lux time
BH1750_QUALITY_LOW 31 7.4 121557 7
BH1750_QUALITY_LOW 254 0.9 14836 59
BH1750_QUALITY_HIGH 31 1.85 121557 54
BH1750_QUALITY_HIGH 254 0.23 14836 442
BH1750_QUALITY_HIGH2 31 0.93 60778 54
BH1750_QUALITY_HIGH2 254 0.11 7418 442

Internal, each Quality can provide the brightness as a 16-bit value (0-65535)


First let's explain the difference between quality BH1750_QUALITY_LOW and BH1750_QUALITY_HIGH.

As you can see: quality BH1750_QUALITY_LOW and quality BH1750_QUALITY_HIGH have the same range (highest lux).
But the conversion time of BH1750_QUALITY_LOW is 7.5 times faster than BH1750_QUALITY_HIGH (442 ms against 59ms at MTreg 254).
The drawback is the resolution: BH1750_QUALITY_LOW x is 4 times less sensitive:

With quality BH1750_QUALITY_HIGH you will read raw data like: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
With quality BH1750_QUALITY_LOW you will read raw data like: 0, 0, 0, 0, 4, 4, 4, 4, 8, 8, ...
So at BH1750_QUALITY_LOW you can only read values as multiples of 4, e.g. 3 or 7 is not possible.


What is the difference between BH1750_QUALITY_HIGH and BH1750_QUALITY_HIGH2?

As you can see in the table, Quality BH1750_QUALITY_HIGH2 has only the half of the range of BH1750_QUALITY_HIGH or BH1750_QUALITY_LOW.
But the resolution is twice as high. The datasheet recommends the use of BH1750_QUALITY_HIGH2, but when the value is saturated, you have to switch to BH1750_QUALITY_HIGH. This Library offers a Auto ranging function that can do the switching for you.


Examples and hints:

There are several ways to set this value.
Every time the value will be stored and used for further measurements.
For example, you can set the Quality at start(BH1750_QUALITY_HIGH2, BH1750_MTREG_DEFAULT).
The call start() with empty brackets will use the settings from the last measurement.

Clone this wiki locally