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

read bits off by 4 bits #1

Open
ehiverson opened this issue Jul 20, 2017 · 0 comments
Open

read bits off by 4 bits #1

ehiverson opened this issue Jul 20, 2017 · 0 comments

Comments

@ehiverson
Copy link

In read():
The correct way to get the data is in the upper 12 bits, not the lower:
uint16_t result = (((((uint16_t)high_byte) << 8) | ((uint16_t)low_byte)) & 0xFFF0) >>4;

In readTemperatureConverted():
Similary, use
uint16_t raw = (((((uint16_t)high_byte) << 8) | ((uint16_t)low_byte)) & 0xFF10) >>7;
as temperature is in the upper 9 bits.

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

1 participant