Skip to content

Fix: Negatives temperatures are not correctly returned.#2

Open
achataigner wants to merge 1 commit intoroder:masterfrom
achataigner:fix_negative_temperature_measurement
Open

Fix: Negatives temperatures are not correctly returned.#2
achataigner wants to merge 1 commit intoroder:masterfrom
achataigner:fix_negative_temperature_measurement

Conversation

@achataigner
Copy link

Issue:
When the temperature is negative, the absolute value of the real temperature is returned:
If the temperature is -3°C the method temperature() still returns 3°C.

The negative temperature was not correctly detected: now we test the correct bit to know if the temperature is negative or not.
The same bit is checked in this repo: https://github.com/adafruit/Adafruit_AM2315 in Adafruit_AM2315.cpp:

// change sign
  if (reply[4] >> 7) temp = -temp;

Issue:
When the temperature is negative, the absolute value of the real temperature is returned:
If the temperature is -3°C the method temperature() still returns 3°C.

The negative temperature was not correctly detected: now we test the correct bit to know if the temperature is negative or not.
The same bit is checked in this repo: https://github.com/adafruit/Adafruit_AM2315 in Adafruit_AM2315.cpp:
```c 
// change sign
  if (reply[4] >> 7) temp = -temp;
```
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

Successfully merging this pull request may close these issues.

1 participant