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

Temperature conversion problem #6

Open
naskomit opened this issue Jan 17, 2023 · 0 comments
Open

Temperature conversion problem #6

naskomit opened this issue Jan 17, 2023 · 0 comments

Comments

@naskomit
Copy link

I believe the temperature conversion is incorrect at:
https://github.com/fuchsnj/ds18b20/blob/master/src/lib.rs#:~:text=let%20temperature%20%3D,%7D%3B

According to the documentation, with lowering of the resolution, the least significant bits become meaningless, but the conversion factor has to be the same i.e. you should always divide by 16.

    let temperature = match resolution {
        Resolution::Bits12 => (raw_temp as f32) / 16.0,
        Resolution::Bits11 => (raw_temp as f32) / 16.0,
        Resolution::Bits10 => (raw_temp as f32) / 16.0,
        Resolution::Bits9 => (raw_temp as f32) / 16.0,
    };
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