diff --git a/src/rtl_433.c b/src/rtl_433.c index b426a318..8eb8f9dd 100755 --- a/src/rtl_433.c +++ b/src/rtl_433.c @@ -782,6 +782,35 @@ static int lacrossetx_callback(uint8_t bb[BITBUF_ROWS][BITBUF_COLS]) { } +static int acurite_th_detect(uint8_t *buf){ + if(buf[5] != 0) return 0; + uint8_t sum = (buf[0] + buf[1] + buf[2] + buf[3]) & 0xff; + if(sum == 0) return 0; + return sum == buf[4]; +} +static float acurite_th_temperature(uint8_t *s){ + uint16_t shifted = (((s[1] & 0x0f) << 8) | s[2]) << 4; // Logical left shift + return (((int16_t)shifted) >> 4) / 10.0; // Arithmetic right shift +} +static int acurite_th_callback(uint8_t bb[BITBUF_ROWS][BITBUF_COLS]) { + uint8_t *buf = NULL; + int i; + for(i = 0; i < BITBUF_ROWS; i++){ + if(acurite_th_detect(bb[i])){ + buf = bb[i]; + break; + } + } + if(buf){ + fprintf(stderr, "Temperature event:\n"); + fprintf(stderr, "protocol = Acurite Temp&Humidity\n"); + fprintf(stderr, "temp = %.1f°C\n", acurite_th_temperature(buf)); + fprintf(stderr, "humidity = %d%%\n\n", buf[3]); + return 1; + } + + return 0; +} // timings based on samp_rate=1024000 r_device rubicson = { @@ -905,6 +934,16 @@ r_device lacrossetx = { /* .json_callback = */ &lacrossetx_callback, }; +r_device acurite_th = { + /* .id = */ 11, + /* .name = */ "Acurite Temperature and Humidity Sensor", + /* .modulation = */ OOK_PWM_D, + /* .short_limit = */ 300, + /* .long_limit = */ 550, + /* .reset_limit = */ 2500, + /* .json_callback = */ &acurite_th_callback, +}; + struct protocol_state { int (*callback)(uint8_t bits_buffer[BITBUF_ROWS][BITBUF_COLS],int16_t bits_per_row[BITBUF_ROWS]); @@ -1777,6 +1816,7 @@ int main(int argc, char **argv) register_protocol(demod, &steffen); register_protocol(demod, &acurite5n1); register_protocol(demod, &lacrossetx); + register_protocol(demod, &acurite_th); if (argc <= optind-1) { usage();