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

Reading light level fails if using the ONETIME modes #17

Closed
gerritv opened this issue Aug 24, 2017 · 3 comments · Fixed by #19
Closed

Reading light level fails if using the ONETIME modes #17

gerritv opened this issue Aug 24, 2017 · 3 comments · Fixed by #19

Comments

@gerritv
Copy link

gerritv commented Aug 24, 2017

These modes power down the chip after the level is read. The present code does not wake up the chip when reading the value in those modes.

I added a save of mode and changed the code in readLightLevel:

uint16_t BH1750::readLightLevel(void) {

    ...

    // Start transmission to sensor
    Wire.beginTransmission(BH1750_I2CADDR);
    switch (MODE) {
        case BH1750_ONE_TIME_HIGH_RES_MODE:
        case BH1750_ONE_TIME_HIGH_RES_MODE_2:
        case BH1750_ONE_TIME_LOW_RES_MODE:
	    __wire_write((uint8_t)MODE);
	    break;
    }
    // Read two bytes from sensor
    Wire.requestFrom(BH1750_I2CADDR, 2);

    ...
}
@gerritv
Copy link
Author

gerritv commented Aug 27, 2017

Awesome, thank you!!!

@coelner
Copy link
Contributor

coelner commented Aug 29, 2017

Please add the right delay time for the one-time measurement (datasheet page 7 and page 5 )

@claws
Copy link
Owner

claws commented Aug 31, 2017

@coelner, if you know what to do you are welcome to submit a merge request with the proposed change.

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

Successfully merging a pull request may close this issue.

3 participants