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) [160] Interval Data Message (IDM)
[161] Interval Data Message (IDM) for Net Meters [161] Interval Data Message (IDM) for Net Meters
[162]* ThermoPro-TX2 temperature sensor [162]* ThermoPro-TX2 temperature sensor
[163] Acurite 590TX Temperature with optional Humidity
* Disabled by default, use -R n or -G * 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 160 # Interval Data Message (IDM)
protocol 161 # Interval Data Message (IDM) for Net Meters protocol 161 # Interval Data Message (IDM) for Net Meters
# protocol 162 # ThermoPro-TX2 temperature sensor # protocol 162 # ThermoPro-TX2 temperature sensor
protocol 163 # Acurite 590TX Temperature with optional Humidity
## Flex devices (command line option "-X") ## Flex devices (command line option "-X")

View file

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

View file

@ -868,22 +868,17 @@ static int acurite_606_decode(r_device *decoder, bitbuffer_t *bitbuffer)
return 1; return 1;
} }
static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer) static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
{ {
data_t *data; data_t *data;
uint8_t *b; uint8_t *b;
int row; int row;
uint8_t channel,humidity; int sensor_id; // the sensor ID - basically a random number that gets reset whenever the battery is removed
int16_t temp_raw; // temperature as read from the data packet int battery; // the battery status: 1 is good, 0 is low
float temp_c; // temperature in C int channel;
int battery; // the battery status: 1 is good, 0 is low int humidity;
int sensor_id; // the sensor ID - basically a random number that gets reset whenever the battery is removed int temp_raw; // temperature as read from the data packet
float temp_c; // temperature in C
if (decoder->verbose >1)
bitbuffer_printf(bitbuffer, "%s: ", __func__);
row = bitbuffer_find_repeated_row(bitbuffer, 3, 25); // expected are min 3 rows row = bitbuffer_find_repeated_row(bitbuffer, 3, 25); // expected are min 3 rows
if (row < 0) if (row < 0)
@ -897,17 +892,13 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
b = bitbuffer->bb[row]; b = bitbuffer->bb[row];
if (b[4] != 0) //last byte should be zero if (b[4] != 0) // last byte should be zero
return DECODE_FAIL_SANITY; return DECODE_FAIL_SANITY;
// reject all blank messages // reject all blank messages
if (b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 0) if (b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 0)
return DECODE_FAIL_SANITY; return DECODE_FAIL_SANITY;
// parity check: odd parity on bits [0 .. 10] // parity check: odd parity on bits [0 .. 10]
// i.e. 8 bytes and another 2 bits. // i.e. 8 bytes and another 2 bits.
uint8_t parity = b[0]; // parity as byte uint8_t parity = b[0]; // parity as byte
@ -917,13 +908,12 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
parity = (parity >> 1) ^ (parity & 0x1); // fold to 1 bit parity = (parity >> 1) ^ (parity & 0x1); // fold to 1 bit
if (!parity) { if (!parity) {
//Enable with -vv (verbose decoders)
if (decoder->verbose) { if (decoder->verbose) {
fprintf(stderr, "%s: parity check failed\n", __func__); fprintf(stderr, "%s: parity check failed\n", __func__);
} }
return DECODE_FAIL_MIC; return DECODE_FAIL_MIC;
} }
// Processing the temperature: // Processing the temperature:
// Upper 4 bits are stored in nibble 1, lower 8 bits are stored in nibble 2 // Upper 4 bits are stored in nibble 1, lower 8 bits are stored in nibble 2
// upper 4 bits of nibble 1 are reserved for other usages (e.g. battery status) // upper 4 bits of nibble 1 are reserved for other usages (e.g. battery status)
@ -931,48 +921,33 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
battery = (b[0] & 0x01); //1=ok, 0=low battery battery = (b[0] & 0x01); //1=ok, 0=low battery
//next 2 bits are checksum //next 2 bits are checksum
//next two bits are identify ID (maybe channel ?) //next two bits are identify ID (maybe channel ?)
channel = (uint8_t)((b[1]>>4) & 0x03); channel = (b[1] >> 4) & 0x03;
if ( (b[1] & 0x0F)==0 && b[2]<=100) //MFD: I see no other way to diferentiate humidity from temperature
{ temp_raw = (int16_t)(((b[1] & 0x0F) << 12) | (b[2] << 4));
humidity = b[2]; temp_raw = temp_raw >> 4;
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 */ /* clang-format off */
data = data_make( data = data_make(
"model", "", DATA_STRING, "Acurite-590TX", "model", "", DATA_STRING, "Acurite-590TX",
"id", "", DATA_INT, sensor_id, "id", "", DATA_INT, sensor_id,
"batttery", "Battery", DATA_STRING, battery ? "OK" : "LOW", "battery", "Battery", DATA_STRING, battery ? "OK" : "LOW",
"battery_ok", "Battery OK", DATA_INT, battery, "channel", "Channel", DATA_INT, channel,
"channel", "Channel", DATA_INT, channel, "humidity", "Humidity", DATA_COND, humidity != -1, DATA_INT, humidity,
"humidity", "Humidity", DATA_INT, humidity, "temperature_C", "Temperature", DATA_COND, humidity == -1, DATA_FORMAT, "%.1f C", DATA_DOUBLE, temp_c,
"mic", "Integrity", DATA_STRING, "PARITY", "mic", "Integrity", DATA_STRING, "PARITY",
NULL); NULL);
/* clang-format on */ /* clang-format on */
}else
{
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
/* 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,
"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,
"mic", "Integrity", DATA_STRING, "PARITY",
NULL);
/* clang-format on */
}
decoder_output_data(decoder, data); decoder_output_data(decoder, data);
return 1; return 1;
} }
static int acurite_00275rm_decode(r_device *decoder, bitbuffer_t *bitbuffer) static int acurite_00275rm_decode(r_device *decoder, bitbuffer_t *bitbuffer)
{ {
int crc, battery_low, id, model_flag, valid = 0; int crc, battery_low, id, model_flag, valid = 0;
@ -1084,47 +1059,45 @@ static int acurite_00275rm_decode(r_device *decoder, bitbuffer_t *bitbuffer)
} }
static char *acurite_rain_gauge_output_fields[] = { static char *acurite_rain_gauge_output_fields[] = {
"model", "model",
"id", "id",
"rain", // TODO: remove this "rain", // TODO: remove this
"rain_mm", "rain_mm",
NULL, NULL,
}; };
r_device acurite_rain_896 = { r_device acurite_rain_896 = {
.name = "Acurite 896 Rain Gauge", .name = "Acurite 896 Rain Gauge",
.modulation = OOK_PULSE_PPM, .modulation = OOK_PULSE_PPM,
.short_width = 1000, .short_width = 1000,
.long_width = 2000, .long_width = 2000,
.gap_limit = 3500, .gap_limit = 3500,
.reset_limit = 5000, .reset_limit = 5000,
.decode_fn = &acurite_rain_896_decode, .decode_fn = &acurite_rain_896_decode,
// Disabled by default due to false positives on oregon scientific v1 protocol see issue #353 .disabled = 1, // Disabled by default due to false positives on oregon scientific v1 protocol see issue #353
.disabled = 1, .fields = acurite_rain_gauge_output_fields,
.fields = acurite_rain_gauge_output_fields,
}; };
static char *acurite_th_output_fields[] = { static char *acurite_th_output_fields[] = {
"model", "model",
"id", "id",
"battery", "battery",
"temperature_C", "temperature_C",
"humidity", "humidity",
"status", "status",
"mic", "mic",
NULL, NULL,
}; };
r_device acurite_th = { r_device acurite_th = {
.name = "Acurite 609TXC Temperature and Humidity Sensor", .name = "Acurite 609TXC Temperature and Humidity Sensor",
.modulation = OOK_PULSE_PPM, .modulation = OOK_PULSE_PPM,
.short_width = 1000, .short_width = 1000,
.long_width = 2000, .long_width = 2000,
.gap_limit = 3000, .gap_limit = 3000,
.reset_limit = 10000, .reset_limit = 10000,
.decode_fn = &acurite_th_decode, .decode_fn = &acurite_th_decode,
.disabled = 0, .fields = acurite_th_output_fields,
.fields = acurite_th_output_fields,
}; };
/* /*
@ -1132,41 +1105,40 @@ r_device acurite_th = {
* Should match Acurite 592TX, 5-n-1, etc. * Should match Acurite 592TX, 5-n-1, etc.
*/ */
static char *acurite_txr_output_fields[] = { static char *acurite_txr_output_fields[] = {
"model", "model",
"subtype", "subtype",
"message_type", // TODO: remove this "message_type", // TODO: remove this
"id", "id",
"sensor_id", // TODO: remove this "sensor_id", // TODO: remove this
"channel", "channel",
"sequence_num", "sequence_num",
"battery_low", // TODO: remove this "battery_low", // TODO: remove this
"battery_ok", "battery_ok",
"battery", "battery",
"temperature_C", "temperature_C",
"temperature_F", "temperature_F",
"humidity", "humidity",
"wind_speed_mph", // TODO: remove this "wind_speed_mph", // TODO: remove this
"wind_speed_kph", // TODO: remove this "wind_speed_kph", // TODO: remove this
"wind_avg_mi_h", "wind_avg_mi_h",
"wind_avg_km_h", "wind_avg_km_h",
"wind_dir_deg", "wind_dir_deg",
"rain_inch", // TODO: remove this "rain_inch", // TODO: remove this
"rain_in", "rain_in",
"rain_mm", "rain_mm",
NULL, NULL,
}; };
r_device acurite_txr = { r_device acurite_txr = {
.name = "Acurite 592TXR Temp/Humidity, 5n1 Weather Station, 6045 Lightning", .name = "Acurite 592TXR Temp/Humidity, 5n1 Weather Station, 6045 Lightning",
.modulation = OOK_PULSE_PWM, .modulation = OOK_PULSE_PWM,
.short_width = 220, // short pulse is 220 us + 392 us gap .short_width = 220, // short pulse is 220 us + 392 us gap
.long_width = 408, // long pulse is 408 us + 204 us gap .long_width = 408, // long pulse is 408 us + 204 us gap
.sync_width = 620, // sync pulse is 620 us + 596 us gap .sync_width = 620, // sync pulse is 620 us + 596 us gap
.gap_limit = 500, // longest data gap is 392 us, sync gap is 596 us .gap_limit = 500, // longest data gap is 392 us, sync gap is 596 us
.reset_limit = 4000, // packet gap is 2192 us .reset_limit = 4000, // packet gap is 2192 us
.decode_fn = &acurite_txr_decode, .decode_fn = &acurite_txr_decode,
.disabled = 0, .fields = acurite_txr_output_fields,
.fields = acurite_txr_output_fields,
}; };
/* /*
@ -1180,25 +1152,24 @@ r_device acurite_txr = {
* There should be 40 bits of data though. But the last bit can't be detected. * There should be 40 bits of data though. But the last bit can't be detected.
*/ */
static char *acurite_986_output_fields[] = { static char *acurite_986_output_fields[] = {
"model", "model",
"id", "id",
"channel", "channel",
"battery", "battery",
"temperature_F", "temperature_F",
"status", "status",
NULL, NULL,
}; };
r_device acurite_986 = { r_device acurite_986 = {
.name = "Acurite 986 Refrigerator / Freezer Thermometer", .name = "Acurite 986 Refrigerator / Freezer Thermometer",
.modulation = OOK_PULSE_PPM, .modulation = OOK_PULSE_PPM,
.short_width = 520, .short_width = 520,
.long_width = 880, .long_width = 880,
.gap_limit = 1280, .gap_limit = 1280,
.reset_limit = 4000, .reset_limit = 4000,
.decode_fn = &acurite_986_decode, .decode_fn = &acurite_986_decode,
.disabled = 0, .fields = acurite_986_output_fields,
.fields = acurite_986_output_fields,
}; };
/* /*
@ -1209,86 +1180,79 @@ r_device acurite_986 = {
*/ */
static char *acurite_606_output_fields[] = { static char *acurite_606_output_fields[] = {
"model", "model",
"id", "id",
"battery", "battery",
"temperature_C", "temperature_C",
"mic", "mic",
NULL, NULL,
}; };
static char *acurite_590_output_fields[] = { static char *acurite_590_output_fields[] = {
"model", "model",
"id", "id",
"batttery", "battery",
"channel", "channel",
"temperature_C", "temperature_C",
//"temperature_F", "humidity",
"humidity", "mic",
"mic", NULL,
NULL,
}; };
// 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 = { r_device acurite_606 = {
.name = "Acurite 606TX Temperature Sensor", .name = "Acurite 606TX Temperature Sensor",
// actually tests/acurite/02/gfile002.cu8, check this .modulation = OOK_PULSE_PPM,
//.modulation = OOK_PULSE_PWM, .short_width = 2000,
//.short_width = 576, .long_width = 4000,
//.long_width = 1076, .gap_limit = 7000,
//.gap_limit = 1200, .reset_limit = 10000,
//.reset_limit = 12000, .decode_fn = &acurite_606_decode,
.modulation = OOK_PULSE_PPM, .fields = acurite_606_output_fields,
.short_width = 2000,
.long_width = 4000,
.gap_limit = 7000,
.reset_limit = 10000,
.decode_fn = &acurite_606_decode,
.disabled = 0,
.fields = acurite_606_output_fields,
}; };
static char *acurite_00275rm_output_fields[] = { static char *acurite_00275rm_output_fields[] = {
"model", "model",
"subtype", "subtype",
"probe", // TODO: remove this "probe", // TODO: remove this
"id", "id",
"battery", "battery",
"temperature_C", "temperature_C",
"humidity", "humidity",
"water", "water",
"temperature_1_C", "temperature_1_C",
"humidity_1", "humidity_1",
"ptemperature_C", "ptemperature_C",
"phumidity", "phumidity",
"mic", "mic",
NULL, NULL,
}; };
r_device acurite_00275rm = { r_device acurite_00275rm = {
.name = "Acurite 00275rm,00276rm Temp/Humidity with optional probe", .name = "Acurite 00275rm,00276rm Temp/Humidity with optional probe",
.modulation = OOK_PULSE_PWM, .modulation = OOK_PULSE_PWM,
.short_width = 232, // short pulse is 232 us .short_width = 232, // short pulse is 232 us
.long_width = 420, // long pulse is 420 us .long_width = 420, // long pulse is 420 us
.gap_limit = 520, // long gap is 384 us, sync gap is 592 us .gap_limit = 520, // long gap is 384 us, sync gap is 592 us
.reset_limit = 708, // no packet gap, sync gap is 592 us .reset_limit = 708, // no packet gap, sync gap is 592 us
.sync_width = 632, // sync pulse is 632 us .sync_width = 632, // sync pulse is 632 us
.decode_fn = &acurite_00275rm_decode, .decode_fn = &acurite_00275rm_decode,
.disabled = 0, .fields = acurite_00275rm_output_fields,
.fields = acurite_00275rm_output_fields,
}; };
r_device acurite_590tx = { r_device acurite_590tx = {
.name = "Acurite 590TX Temperature with optional Humidity", .name = "Acurite 590TX Temperature with optional Humidity",
.modulation = OOK_PULSE_PPM, //OOK_PULSE_PWM, .modulation = OOK_PULSE_PPM, //OOK_PULSE_PWM,
.short_width = 500, // short pulse is 232 us .short_width = 500, // short pulse is 232 us
.long_width = 1500, // long pulse is 420 us .long_width = 1500, // long pulse is 420 us
.gap_limit = 1484, // long gap is 384 us, sync gap is 592 us .gap_limit = 1484, // long gap is 384 us, sync gap is 592 us
.reset_limit = 3000, // no packet gap, sync gap is 592 us .reset_limit = 3000, // no packet gap, sync gap is 592 us
.sync_width = 500, // sync pulse is 632 us .sync_width = 500, // sync pulse is 632 us
.decode_fn = &acurite_590tx_decode, .decode_fn = &acurite_590tx_decode,
.disabled = 0, .fields = acurite_590_output_fields,
.fields = acurite_590_output_fields,
}; };