Skip to content

Commit 90bea21

Browse files
authored
Merge pull request #79 from beta-tester/master
BH1750 MTreg min is 31 in the datasheet
2 parents 37068ca + 9437a0c commit 90bea21

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

examples/BH1750autoadjust/BH1750autoadjust.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ After the measurement the MTreg value is changed according to the result:
99
lux > 40000 ==> MTreg = 32
1010
lux < 40000 ==> MTreg = 69 (default)
1111
lux < 10 ==> MTreg = 138
12-
Remember to test your specific sensor! Maybe the MTreg value range from 32
12+
Remember to test your specific sensor! Maybe the MTreg value range from 31
1313
up to 254 is not applicable to your unit.
1414
1515
Connections

src/BH1750.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,12 @@ bool BH1750::configure(Mode mode) {
138138
/**
139139
* Configure BH1750 MTreg value
140140
* MT reg = Measurement Time register
141-
* @param MTreg a value between 32 and 254. Default: 69
141+
* @param MTreg a value between 31 and 254. Default: 69
142142
* @return bool true if MTReg successful set
143143
* false if MTreg not changed or parameter out of range
144144
*/
145145
bool BH1750::setMTreg(byte MTreg) {
146-
// Bug: lowest value seems to be 32!
147-
if (MTreg <= 31 || MTreg > 254) {
146+
if (MTreg < BH1750_MTREG_MIN || MTreg > BH1750_MTREG_MAX) {
148147
Serial.println(F("[BH1750] ERROR: MTreg out of range"));
149148
return false;
150149
}

src/BH1750.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
// Default MTreg value
4040
#define BH1750_DEFAULT_MTREG 69
41+
#define BH1750_MTREG_MIN 31
42+
#define BH1750_MTREG_MAX 254
4143

4244
class BH1750 {
4345

0 commit comments

Comments
 (0)