Skip to content

Commit

Permalink
Merge pull request #79 from beta-tester/master
Browse files Browse the repository at this point in the history
BH1750 MTreg min is 31 in the datasheet
  • Loading branch information
claws authored Jan 16, 2022
2 parents 37068ca + 9437a0c commit 90bea21
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/BH1750autoadjust/BH1750autoadjust.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ After the measurement the MTreg value is changed according to the result:
lux > 40000 ==> MTreg = 32
lux < 40000 ==> MTreg = 69 (default)
lux < 10 ==> MTreg = 138
Remember to test your specific sensor! Maybe the MTreg value range from 32
Remember to test your specific sensor! Maybe the MTreg value range from 31
up to 254 is not applicable to your unit.
Connections
Expand Down
5 changes: 2 additions & 3 deletions src/BH1750.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,12 @@ bool BH1750::configure(Mode mode) {
/**
* Configure BH1750 MTreg value
* MT reg = Measurement Time register
* @param MTreg a value between 32 and 254. Default: 69
* @param MTreg a value between 31 and 254. Default: 69
* @return bool true if MTReg successful set
* false if MTreg not changed or parameter out of range
*/
bool BH1750::setMTreg(byte MTreg) {
// Bug: lowest value seems to be 32!
if (MTreg <= 31 || MTreg > 254) {
if (MTreg < BH1750_MTREG_MIN || MTreg > BH1750_MTREG_MAX) {
Serial.println(F("[BH1750] ERROR: MTreg out of range"));
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/BH1750.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

// Default MTreg value
#define BH1750_DEFAULT_MTREG 69
#define BH1750_MTREG_MIN 31
#define BH1750_MTREG_MAX 254

class BH1750 {

Expand Down

0 comments on commit 90bea21

Please sign in to comment.