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

i16 temperature (milli-degrees celsius) return type insufficient for device operating range #2

Open
tim-seoss opened this issue Apr 23, 2019 · 3 comments

Comments

@tim-seoss
Copy link
Contributor

The temperature method currently returns an i16 (which is documented as being milli-degrees Celsius), so will overflow at temperatures over 32.767°C, or below -32.768°C. The SHT21 operating range is -40°C to +125°C

Possible solutions would be to reduce the number of decimal places (e.g. to 2) or use an i32.

@tim-seoss
Copy link
Contributor Author

I'm happy to create a PR btw.

@dbrgn
Copy link
Owner

dbrgn commented Apr 23, 2019

Good catch 🙂 Using an i32 is probably the best approach.

In the mcp3425 crate, I also added a feature flag that allows using types from the measurements crate (See Temperature). But I doubt a lot of people would use that, especially on embedded devices (since it uses f64).

@tim-seoss
Copy link
Contributor Author

OK, I think it's probably adding measurements::temperature::Temperature like you did in the mcp3425 crate. In the meantime I've added temperature and humidity (both in thousandths and stored as i32 using the "newtype" pattern). Please take a look at the pull request which I'll open in a minute to see what you think...

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