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

uint16_t is too small for resistors #4

Open
brianjmurrell opened this issue Jan 20, 2018 · 1 comment
Open

uint16_t is too small for resistors #4

brianjmurrell opened this issue Jan 20, 2018 · 1 comment

Comments

@brianjmurrell
Copy link

1MOhm thermistors are not uncommon. 1,000,000 overflows a 16 bit unsigned int.

Bumping the resistor types up to uint32_t seems to fix the overflow.

While I'm bug reporting, is #define VERBOSE_SENSOR_ENABLED 1 really an appropriate default? That seems like something somebody should have to enable if they are debugging.

And finally, why do you return the temperature multiplied by 10?

@tmeysson
Copy link

tmeysson commented Dec 3, 2018

You can divide resistor values by a common number, all that matters is the ratio.
I have a 100K thermistor and a 99K resistor, so I use it with '100' and '99' -- it works.
You can change the #define if you want, helped me a lot when I started it, otherwise I would have missed something. But I guess there should be a more elegant solution.
The temperature is multiplied by 10 because it's an int so otherwise, you wouldn't get the first decimal. Those thermistors have about that accuracy, usually. Though, if you only want 1 degree accuracy, you can hack it out (but then use round() before casting to int, or you'll systematically round down, like 19.9 to 19).

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