Skip to content

setQuality

Stefan Armborst edited this page Jan 2, 2020 · 15 revisions

setQuality

sets the Quality for the next measurement.

void setQuality(Quality quality);

result void

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


Parameter Quality

enum Quality
{
  BH1750_HIGH = 0x20,
  BH1750_HIGH2 = 0x21,
  BH1750_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_LOW 31 7.4 121557 7
BH1750_LOW 254 0.9 14836 59
BH1750_HIGH 31 1.85 121557 54
BH1750_HIGH 254 0.23 14836 442
BH1750_HIGH2 31 0.93 60778 54
BH1750_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_LOW and BH1750_HIGH
As you can see: quality BH1750_LOW and quality BH1750_HIGH have the same range (highest lux).
But the conversion time of BH1750_LOW is 7.5 times faster than BH1750_HIGH (442 ms against 59ms at MTreg 254).
The drawback is the resolution: BH1750_LOW x is 4 times less sensitive:

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

As you can see in the table, Quality BH1750_HIGH2 has only the half of the range of BH1750_HIGH or BH1750_LOW.
But the resolution is twice as high. The datasheet recommends the use of BH1750_HIGH2, but when the value is saturated, you have to switch to BH1750_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 startMeasure(BH1750_HIGH2, MTregDefault).
The call startMeasure() with empty brackets will use the same settings set like before.

Clone this wiki locally