Skip to content

Commit

Permalink
Add support for Rubicson pool thermometer 48942 (#2137)
Browse files Browse the repository at this point in the history
  • Loading branch information
robho authored Aug 6, 2022
1 parent d0af8ea commit cd90897
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ See [CONTRIBUTING.md](./docs/CONTRIBUTING.md).
[219] Fine Offset Electronics WH45 air quality sensor
[220] Maverick XR-30 BBQ Sensor
[221] Fine Offset Electronics WN34 temperature sensor
[222] Rubicson pool thermometer 48942
* Disabled by default, use -R n or a conf file to enable
Expand Down
1 change: 1 addition & 0 deletions conf/rtl_433.example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ stop_after_successful_events false
protocol 219 # Fine Offset Electronics WH45 air quality sensor
protocol 220 # Maverick XR-30 BBQ Sensor
protocol 221 # Fine Offset Electronics WN34 temperature sensor
protocol 222 # Rubicson pool thermometer 48942

## Flex devices (command line option "-X")

Expand Down
1 change: 1 addition & 0 deletions include/rtl_433_devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
DECL(fineoffset_wh45) \
DECL(maverick_xr30) \
DECL(fineoffset_wn34) \
DECL(rubicson_pool_48942) \

/* Add new decoders here. */

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ add_library(r_433 STATIC
devices/rojaflex.c
devices/rubicson.c
devices/rubicson_48659.c
devices/rubicson_pool_48942.c
devices/s3318p.c
devices/schraeder.c
devices/scmplus.c
Expand Down
110 changes: 110 additions & 0 deletions src/devices/rubicson_pool_48942.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/** @file
Rubicson pool thermometer 48942 decoder.
Copyright (C) 2022 Robert Högberg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/

/**
Rubicson pool thermometer 48942 decoder.
The device uses OOK and fixed period PWM.
- 0 is encoded as 240 us pulse and 480 us gap,
- 1 is encoded as 480 us pulse and 240 us gap.
A transmission consists of an initial preamble followed by sync
pulses and the data. Sync pulses and data are sent twice.
Preamble:
__ ____ ____ ____ ____
| |____| |____| |____| |____| |__________
480 980 980 980 980 980 980 980 980 3880 [us]
Sync pulses:
___ ___ ___ ___
| |___| |___| |___| |___
730 730 730 730 730 730 730 730 [us]
The device's transmission interval depends on the configured
channel. The interval is 55 + <device channel> seconds.
Data format:
71 ba 4e 60 ba 0
01110001 10111010 01001110 01100000 10111010 0
CCCCRRRR RRRRRR10 BTTTTTTT TTTT0000 XXXXXXXX 0
- C: channel - offset by 1; 0000 means channel 1
The device can be configured to use channels 1-8
- R: random power on id
- 1: constant 1
- 0: constant 0
- B: low battery indicator
- T: temperature - offset by 1024 and scaled by 10
- X: CRC
*/

#include "decoder.h"

static int rubicson_pool_48942_decode(r_device *decoder, bitbuffer_t *bitbuffer)
{
int row = bitbuffer_find_repeated_row(bitbuffer, 2, 41);
if (row < 0 || bitbuffer->bits_per_row[row] != 41)
return DECODE_ABORT_LENGTH;

uint8_t *b = bitbuffer->bb[row];
bitbuffer_invert(bitbuffer);

// validate some static bits
if (b[3] & 0xF || b[5])
return DECODE_ABORT_EARLY;

if (crc8(b, 4, 0x31, 0x00) != b[4])
return DECODE_FAIL_MIC;

int channel = (b[0] >> 4) + 1;
int random_id = (b[0] & 0x0F) << 6 | (b[1] & 0xFC) >> 2;
int battery_low = b[2] >> 7;
float temp_c = ((((b[2] & 0x7F) << 4) | (b[3] >> 4)) - 1024) * 0.1f;

decoder_log_bitbuffer(decoder, 1, __func__, bitbuffer, "");

/* clang-format off */
data_t *data = data_make(
"model", "", DATA_STRING, "Rubicson-48942",
"channel", "Channel", DATA_INT, channel,
"id", "Random ID", DATA_INT, random_id,
"battery_ok", "Battery", DATA_INT, !battery_low,
"temperature_C", "Temperature", DATA_FORMAT, "%.1f C", DATA_DOUBLE, temp_c,
"mic", "Integrity", DATA_STRING, "CRC",
NULL);
/* clang-format on */

decoder_output_data(decoder, data);
return 1;
}

static char *output_fields[] = {
"model",
"channel",
"id",
"battery_ok",
"temperature_C",
"mic",
NULL,
};

r_device rubicson_pool_48942 = {
.name = "Rubicson Pool Thermometer 48942",
.modulation = OOK_PULSE_PWM,
.short_width = 280,
.long_width = 480,
.reset_limit = 6000,
.gap_limit = 5000,
.sync_width = 730,
.decode_fn = &rubicson_pool_48942_decode,
.fields = output_fields,
};

0 comments on commit cd90897

Please sign in to comment.