Fixed negative temperature bug.

master
Marcel 4 months ago
parent 2038a1aa9d
commit bb81f2d6de
  1. 5
      CHANGELOG.md
  2. BIN
      build/src/CMakeFiles/main.dir/main.cpp.obj
  3. BIN
      build/src/main.bin
  4. 57286
      build/src/main.dis
  5. BIN
      build/src/main.elf
  6. 1364
      build/src/main.elf.map
  7. 9403
      build/src/main.hex
  8. BIN
      build/src/main.uf2
  9. 6
      src/main.cpp

@ -57,3 +57,8 @@ First (more or less) working version.
### Fixed
- One of the digital outputs was inverted.
## [1.1.2] - [2024-01-08]
### Fixed
- Negative temperature where converted wrong: -1 became -32767. This was because of a weird format the sensor uses.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

@ -758,6 +758,12 @@ int main() {
if (!NO_I2C_AVAILABLE)
ReadAM2315(&humidity, &temperature);
// Bit 15 of AM2315 temperature is sign (1 = negative). Bit 14-0 is absolute value of teperature
if (temperature&0x8000) {
temperature = temperature & 0x7FFF; // remove sign bit
temperature = -temperature; // make proper signed integer of negative number
}
// Format telemetry string
sprintf(tmp_string, "%.1f,%.1f", (float)temperature/10, (float)humidity/10);
// Copy string (including NULL terminator) to final destination (can not be done without temporary string due to char/uint8_t issues)

Loading…
Cancel
Save