1 /* TFA pool temperature sensor
3 * Copyright (C) 2015 Alexandre Coffignal
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
15 static int pool_temperature_sensor_callback(bitbuffer_t *bitbuffer) {
16 bitrow_t *bb = bitbuffer->bb;
18 char time_str[LOCAL_TIME_BUFLEN];
19 local_time_str(0, time_str);
26 if(bitbuffer->bits_per_row[i]!=28){
33 AAAABBBB BBBBCCCC CCCCCCCC DDEE
36 B: device id (changing only after reset)
42 device=(((bb[1][0]&0xF)<<4)+((bb[1][1]&0xF0)>>4));
43 iTemp=((bb[1][1]&0xF)<<8)+bb[1][2];
44 fTemp=(iTemp > 2048 ? iTemp - 4096 : iTemp) / 10.0;
45 channel=(signed short)((bb[1][3]&0xC0)>>6);
47 data = data_make("time", "", DATA_STRING, time_str,
48 "model", "", DATA_STRING, "TFA pool temperature sensor",
49 "id", "Id", DATA_FORMAT, "\t %d", DATA_INT, device,
50 "channel", "Channel number", DATA_FORMAT, "\t %d", DATA_INT, channel,
51 "temperature_C", "Temperature", DATA_FORMAT, "%.01f C", DATA_DOUBLE, fTemp,
53 data_acquired_handler(data);
59 static char *output_fields[] = {
68 r_device tfa_pool_thermometer = {
70 .name = "TFA pool temperature sensor",
71 .modulation = OOK_PULSE_PPM_RAW,
75 .json_callback = &pool_temperature_sensor_callback,
78 .fields = output_fields,