From fa82a487892741b17e46a87a51015a47569e3661 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:28:33 +0200 Subject: [PATCH] Fix Sonoff WTS01 temperature sensor shows incorrect negative temperature (#19373) --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + .../xdrv_08_serial_bridge.ino | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8b400112..866e49273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file. - DALI received data decoding - ESP32 Ethernet using EthClockMode 3 (#22248) - ESP32 disable SPI DMA for uDisplay (broken since esp-idf 5.3 (core 3.1.0)) (#22264) +- Sonoff WTS01 temperature sensor shows incorrect negative temperature (#19373) ### Removed - Berry Zigbee removed test code (#22263) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 0863a74ae..3f93a017e 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -179,6 +179,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - PZEM continue energy monitoring when one phase fails [#21968](https://github.com/arendst/Tasmota/issues/21968) - BearSSL panic on ESP8266 in rare conditions [#22017](https://github.com/arendst/Tasmota/issues/22017) - ModbusBridge request and response logic [#22075](https://github.com/arendst/Tasmota/issues/22075) +- Sonoff WTS01 temperature sensor shows incorrect negative temperature [#19373](https://github.com/arendst/Tasmota/issues/19373) - Autoconf prevent 'init.bat' from stopping on empty lines [#22158](https://github.com/arendst/Tasmota/issues/22158) - Zigbee extend timeout for MCU reboot from 5s to 10s [#22009](https://github.com/arendst/Tasmota/issues/22009) - Zigbee avoid disabling console serial on ESP32 and improved log messages [#22082](https://github.com/arendst/Tasmota/issues/22082) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_08_serial_bridge.ino b/tasmota/tasmota_xdrv_driver/xdrv_08_serial_bridge.ino index 0eb9a0c43..0e6bbf279 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_08_serial_bridge.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_08_serial_bridge.ino @@ -226,7 +226,24 @@ void SerialBridgeInput(void) { if (9 == SBridge.in_byte_counter) { uint32_t *header = (uint32_t*)serial_bridge_buffer; if (0x04010155 == *header) { - SBridge.temperature = (float)serial_bridge_buffer[6] + ((float)serial_bridge_buffer[7] / 100.0f); + /* + 14:43:26.718 WTS: buf6 0x01, buf7 0x5d, temp 1, dec 93 1.93 + 14:43:33.175 WTS: buf6 0x01, buf7 0x12, temp 1, dec 18 1.18 + 14:43:34.252 WTS: buf6 0x01, buf7 0x06, temp 1, dec 6 1.06 + 14:43:35.328 WTS: buf6 0x00, buf7 0x5d, temp 0, dec 93 0.93 + 14:43:42.862 WTS: buf6 0x00, buf7 0x0c, temp 0, dec 12 0.12 + 14:43:43.938 WTS: buf6 0x00, buf7 0x00, temp 0, dec 0 0.00 + 14:43:45.015 WTS: buf6 0x80, buf7 0x0c, temp 128, dec 12 -0.12 + 14:43:53.624 WTS: buf6 0x80, buf7 0x5d, temp 128, dec 93 -0.93 + 14:43:54.700 WTS: buf6 0x81, buf7 0x06, temp 129, dec 6 -1.06 + */ + uint8_t temp = serial_bridge_buffer[6]; + int sign = 1; + if (temp > 127) { + temp -= 128; + sign = -1; + } + SBridge.temperature = sign * ((float)temp + ((float)serial_bridge_buffer[7] / 100.0f)); } } }