From 60657999e5096cac0b6e946a94c651bf810756df Mon Sep 17 00:00:00 2001 From: John Pochmara <127617714+jpochmara@users.noreply.github.com> Date: Mon, 3 Feb 2025 10:36:48 -0800 Subject: [PATCH] Add rain start detection feature for WS90 sensor (#3183) --- src/devices/fineoffset_ws90.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/devices/fineoffset_ws90.c b/src/devices/fineoffset_ws90.c index 422b0bfb8..f7bcebd76 100644 --- a/src/devices/fineoffset_ws90.c +++ b/src/devices/fineoffset_ws90.c @@ -50,11 +50,17 @@ Packet layout: - V = uv index, scale 10 - U = unknown (bytes 14 and 15 appear to be fixed at 3f ff) - R = rain total (R3 << 8 | R4) * 0.1 mm +- RS = rain start dection ((R1 & 0x10) >>4), 1 = raining, 0 = not raining - S = super cap voltage, unit of 0.1V, lower 6 bits, mask 0x3f - Z = Firmware version. 0x82 = 130 = 1.3.0 - A = checksum - X = CRC +Rain start info: +Status 1 will be reset to 0 when: +- Once the top is dry +- After the amount of water on the top has remained unchanged for two hours. + */ static int fineoffset_ws90_decode(r_device *decoder, bitbuffer_t *bitbuffer) @@ -106,6 +112,7 @@ static int fineoffset_ws90_decode(r_device *decoder, bitbuffer_t *bitbuffer) int wind_max = ((b[7] & 0x40) << 2) | (b[12]); int uv_index = (b[13]); int rain_raw = (b[19] << 8 ) | (b[20]); + int rain_start = (b[16] & 0x10) >> 4; int supercap_V = (b[21] & 0x3f); int firmware = b[29]; @@ -130,6 +137,7 @@ static int fineoffset_ws90_decode(r_device *decoder, bitbuffer_t *bitbuffer) "light_lux", "Light", DATA_COND, light_raw != 0xffff, DATA_FORMAT, "%.1f lux", DATA_DOUBLE, (double)light_lux, "flags", "Flags", DATA_FORMAT, "%02x", DATA_INT, flags, "rain_mm", "Total Rain", DATA_FORMAT, "%.1f mm", DATA_DOUBLE, rain_raw * 0.1f, + "rain_start", "Rain Start", DATA_INT, rain_start, "supercap_V", "Supercap Voltage", DATA_COND, supercap_V != 0xff, DATA_FORMAT, "%.1f V", DATA_DOUBLE, supercap_V * 0.1f, "firmware", "Firmware Version", DATA_INT, firmware, "data", "Extra Data", DATA_STRING, extra, @@ -156,6 +164,7 @@ static char const *const output_fields[] = { "flags", "unknown", "rain_mm", + "rain_start", "supercap_V", "firmware", "data",