Skip to content

Commit

Permalink
Add rain start detection feature for WS90 sensor (#3183)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpochmara authored Feb 3, 2025
1 parent 5453448 commit 6065799
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/devices/fineoffset_ws90.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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];

Expand All @@ -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,
Expand All @@ -156,6 +164,7 @@ static char const *const output_fields[] = {
"flags",
"unknown",
"rain_mm",
"rain_start",
"supercap_V",
"firmware",
"data",
Expand Down

0 comments on commit 6065799

Please sign in to comment.