minor: clean up Acurite 590TX

This commit is contained in:
Christian W. Zuckschwerdt 2020-07-30 17:17:45 +02:00
parent 0334a966fb
commit d27cf492b0
4 changed files with 165 additions and 196 deletions

View file

@ -236,6 +236,7 @@ See [CONTRIBUTING.md](./docs/CONTRIBUTING.md).
[160] Interval Data Message (IDM)
[161] Interval Data Message (IDM) for Net Meters
[162]* ThermoPro-TX2 temperature sensor
[163] Acurite 590TX Temperature with optional Humidity
* Disabled by default, use -R n or -G

View file

@ -344,6 +344,7 @@ stop_after_successful_events false
protocol 160 # Interval Data Message (IDM)
protocol 161 # Interval Data Message (IDM) for Net Meters
# protocol 162 # ThermoPro-TX2 temperature sensor
protocol 163 # Acurite 590TX Temperature with optional Humidity
## Flex devices (command line option "-X")

View file

@ -607,6 +607,9 @@ Interval Data Message (IDM) for Net Meters
.TP
[ \fB162\fI\fP ]
* ThermoPro\-TX2 temperature sensor
.TP
[ \fB163\fI\fP ]
Acurite 590TX Temperature with optional Humidity
* Disabled by default, use \-R n or \-G
.SS "Input device selection"

View file

@ -868,22 +868,17 @@ static int acurite_606_decode(r_device *decoder, bitbuffer_t *bitbuffer)
return 1;
}
static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
{
data_t *data;
uint8_t *b;
int row;
uint8_t channel,humidity;
int16_t temp_raw; // temperature as read from the data packet
float temp_c; // temperature in C
int battery; // the battery status: 1 is good, 0 is low
int sensor_id; // the sensor ID - basically a random number that gets reset whenever the battery is removed
if (decoder->verbose >1)
bitbuffer_printf(bitbuffer, "%s: ", __func__);
int battery; // the battery status: 1 is good, 0 is low
int channel;
int humidity;
int temp_raw; // temperature as read from the data packet
float temp_c; // temperature in C
row = bitbuffer_find_repeated_row(bitbuffer, 3, 25); // expected are min 3 rows
if (row < 0)
@ -904,10 +899,6 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
if (b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 0)
return DECODE_FAIL_SANITY;
// parity check: odd parity on bits [0 .. 10]
// i.e. 8 bytes and another 2 bits.
uint8_t parity = b[0]; // parity as byte
@ -917,7 +908,6 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
parity = (parity >> 1) ^ (parity & 0x1); // fold to 1 bit
if (!parity) {
//Enable with -vv (verbose decoders)
if (decoder->verbose) {
fprintf(stderr, "%s: parity check failed\n", __func__);
}
@ -931,48 +921,33 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
battery = (b[0] & 0x01); //1=ok, 0=low battery
//next 2 bits are checksum
//next two bits are identify ID (maybe channel ?)
channel = (uint8_t)((b[1]>>4) & 0x03);
if ( (b[1] & 0x0F)==0 && b[2]<=100) //MFD: I see no other way to diferentiate humidity from temperature
{
humidity = b[2];
/* clang-format off */
data = data_make(
"model", "", DATA_STRING, "Acurite-590TX",
"id", "", DATA_INT, sensor_id,
"batttery", "Battery", DATA_STRING, battery ? "OK" : "LOW",
"battery_ok", "Battery OK", DATA_INT, battery,
"channel", "Channel", DATA_INT, channel,
"humidity", "Humidity", DATA_INT, humidity,
"mic", "Integrity", DATA_STRING, "PARITY",
NULL);
/* clang-format on */
}else
{
channel = (b[1] >> 4) & 0x03;
temp_raw = (int16_t)(((b[1] & 0x0F) << 12) | (b[2] << 4));
temp_raw = temp_raw >> 4;
temp_c = temp_raw * 0.1f - 50; //MFD: seems to be a 50 degree offset maybe to be able to go negative
temp_c = (temp_raw - 500) * 0.1f; // NOTE: there seems to be a 50 degree offset?
if (temp_raw >= 0 && temp_raw <= 100) // NOTE: no other way to differentiate humidity from temperature?
humidity = temp_raw;
else
humidity = -1;
/* clang-format off */
data = data_make(
"model", "", DATA_STRING, "Acurite-590TX",
"id", "", DATA_INT, sensor_id,
"batttery", "Battery", DATA_STRING, battery ? "OK" : "LOW",
"battery_ok", "Battery OK", DATA_INT, battery,
"battery", "Battery", DATA_STRING, battery ? "OK" : "LOW",
"channel", "Channel", DATA_INT, channel,
"temperature_C", "Temperature C", DATA_FORMAT, "%.1f", DATA_DOUBLE, temp_c,
//"temperature_F", "Temperature F", DATA_FORMAT, "%.1f", DATA_DOUBLE, temp_c*1.8+32,
"humidity", "Humidity", DATA_COND, humidity != -1, DATA_INT, humidity,
"temperature_C", "Temperature", DATA_COND, humidity == -1, DATA_FORMAT, "%.1f C", DATA_DOUBLE, temp_c,
"mic", "Integrity", DATA_STRING, "PARITY",
NULL);
/* clang-format on */
}
decoder_output_data(decoder, data);
return 1;
}
static int acurite_00275rm_decode(r_device *decoder, bitbuffer_t *bitbuffer)
{
int crc, battery_low, id, model_flag, valid = 0;
@ -1099,8 +1074,7 @@ r_device acurite_rain_896 = {
.gap_limit = 3500,
.reset_limit = 5000,
.decode_fn = &acurite_rain_896_decode,
// Disabled by default due to false positives on oregon scientific v1 protocol see issue #353
.disabled = 1,
.disabled = 1, // Disabled by default due to false positives on oregon scientific v1 protocol see issue #353
.fields = acurite_rain_gauge_output_fields,
};
@ -1123,7 +1097,6 @@ r_device acurite_th = {
.gap_limit = 3000,
.reset_limit = 10000,
.decode_fn = &acurite_th_decode,
.disabled = 0,
.fields = acurite_th_output_fields,
};
@ -1165,7 +1138,6 @@ r_device acurite_txr = {
.gap_limit = 500, // longest data gap is 392 us, sync gap is 596 us
.reset_limit = 4000, // packet gap is 2192 us
.decode_fn = &acurite_txr_decode,
.disabled = 0,
.fields = acurite_txr_output_fields,
};
@ -1197,7 +1169,6 @@ r_device acurite_986 = {
.gap_limit = 1280,
.reset_limit = 4000,
.decode_fn = &acurite_986_decode,
.disabled = 0,
.fields = acurite_986_output_fields,
};
@ -1217,35 +1188,31 @@ static char *acurite_606_output_fields[] = {
NULL,
};
static char *acurite_590_output_fields[] = {
"model",
"id",
"batttery",
"battery",
"channel",
"temperature_C",
//"temperature_F",
"humidity",
"mic",
NULL,
};
r_device acurite_606 = {
.name = "Acurite 606TX Temperature Sensor",
// actually tests/acurite/02/gfile002.cu8, check this
//.modulation = OOK_PULSE_PWM,
//.short_width = 576,
//.long_width = 1076,
//.gap_limit = 1200,
//.reset_limit = 12000,
r_device acurite_606 = {
.name = "Acurite 606TX Temperature Sensor",
.modulation = OOK_PULSE_PPM,
.short_width = 2000,
.long_width = 4000,
.gap_limit = 7000,
.reset_limit = 10000,
.decode_fn = &acurite_606_decode,
.disabled = 0,
.fields = acurite_606_output_fields,
};
@ -1275,11 +1242,9 @@ r_device acurite_00275rm = {
.reset_limit = 708, // no packet gap, sync gap is 592 us
.sync_width = 632, // sync pulse is 632 us
.decode_fn = &acurite_00275rm_decode,
.disabled = 0,
.fields = acurite_00275rm_output_fields,
};
r_device acurite_590tx = {
.name = "Acurite 590TX Temperature with optional Humidity",
.modulation = OOK_PULSE_PPM, //OOK_PULSE_PWM,
@ -1289,6 +1254,5 @@ r_device acurite_590tx = {
.reset_limit = 3000, // no packet gap, sync gap is 592 us
.sync_width = 500, // sync pulse is 632 us
.decode_fn = &acurite_590tx_decode,
.disabled = 0,
.fields = acurite_590_output_fields,
};