Merge pull request #295 from sheinz/fix/ds18b20_negative_temp
ds18b20 fix for temperature below zero
This commit is contained in:
commit
4d00566421
1 changed files with 12 additions and 12 deletions
|
@ -174,7 +174,7 @@ bool ds18b20_read_scratchpad(int pin, ds18b20_addr_t addr, uint8_t *buffer) {
|
||||||
|
|
||||||
float ds18b20_read_temperature(int pin, ds18b20_addr_t addr) {
|
float ds18b20_read_temperature(int pin, ds18b20_addr_t addr) {
|
||||||
uint8_t scratchpad[8];
|
uint8_t scratchpad[8];
|
||||||
int temp;
|
int16_t temp;
|
||||||
|
|
||||||
if (!ds18b20_read_scratchpad(pin, addr, scratchpad)) {
|
if (!ds18b20_read_scratchpad(pin, addr, scratchpad)) {
|
||||||
return NAN;
|
return NAN;
|
||||||
|
|
Loading…
Reference in a new issue