Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage information MTreg #53

Closed
coelner opened this issue Oct 24, 2018 · 3 comments
Closed

Usage information MTreg #53

coelner opened this issue Oct 24, 2018 · 3 comments

Comments

@coelner
Copy link
Contributor

coelner commented Oct 24, 2018

As you can see, I used the MTreg value to capture outdoor light.
bildschirmfoto von 2018-10-11 09-16-16

It reveals an error. The esp8266 is in deep sleep, therefore it restart completely and the saved MTreg value in the library get lost. But the sensor itself uses another MTreg value. I have no idea how to solve the problem in a nice way, but some thoughts:

  1. include in begin() some resetting to the default MTreg
  2. get/set method to manipulate the saved MTreg in the library space
  3. inform the user to take care of this behavior
  4. (find a hidden possibility to get the current MTreg from the sensor itself)
@bjarnebuchmann
Copy link

I can confirm this issue.
The problem is that the BH1750 library does not always write the default MTreg to the device upon begin(). Rather, it assumes (sometimes falsely so) that the device uses the default MTreg on start. That is not true, if the program is reset (eg waking from deep sleep or rebooting) without giving a full power interrupt, which could reset MTreg on the BH1750.
The solution seems straight forward: setup() should always call

setMTreg( (byte) BH1750_MTreg )
or alt
setMTreg( (byte)BH1750_DEFAULT_MTREG )

to ensure that MTreg on device (BH1750) and object (library) mathches.

/Bjarne

@bjarnebuchmann
Copy link

bjarnebuchmann commented Jul 31, 2019

As a work-around, I will suggest to manually call setMTreg() right after begin(), as per:

setup(){
...
  lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE);
  lightMeter.setMTreg((byte) BH1750_DEFAULT_MTREG);
...
}

@coelner
Copy link
Contributor Author

coelner commented Aug 14, 2020

return configure(mode);

@claws what about this?
return (configure(mode) && setMTreg((byte) BH1750_DEFAULT_MTREG))

coelner pushed a commit to coelner/BH1750 that referenced this issue Aug 14, 2020
@coelner coelner mentioned this issue Aug 20, 2020
coelner pushed a commit to coelner/BH1750 that referenced this issue Sep 24, 2020
coelner pushed a commit to coelner/BH1750 that referenced this issue Sep 24, 2020
coelner pushed a commit to coelner/BH1750 that referenced this issue Nov 1, 2020
add new I2C address example (see claws#71), [fix error in my master]
@claws claws closed this as completed in 1c22536 Jan 3, 2021
coelner pushed a commit to coelner/BH1750 that referenced this issue Oct 13, 2021
add new I2C address example (see claws#71), [fix error in my master]
coelner pushed a commit to coelner/BH1750 that referenced this issue Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants