added json-support and description for TFA 30.3161 rain sensor

This commit is contained in:
c1-10p
2017-08-26 17:04:33 +00:00
committed by Benjamin Larsson
parent 6850e981b6
commit eb838065da

View File

@@ -14,7 +14,8 @@ extern uint8_t reverse8(uint8_t x);
static int kw9015b_callback(bitbuffer_t *bitbuffer) {
bitrow_t *bb = bitbuffer->bb;
char time_str[LOCAL_TIME_BUFLEN];
data_t *data;
int i,iRain,device;
unsigned char chksum;
float fTemp;
@@ -37,18 +38,34 @@ static int kw9015b_callback(bitbuffer_t *bitbuffer) {
(reverse8(bb[i][2])>>4)+(reverse8(bb[i][2])&0x0F)+
(reverse8(bb[i][3])>>4)+(reverse8(bb[i][3])&0x0F));
if (debug_output >= 1) {
fprintf(stdout, "\nSensor = Inovalley kw9015b, TFA Dostmann 30.3161 (Rain and temperature sensor)\n");
fprintf(stdout, "Device = %d\n", device);
fprintf(stdout, "Temp = %f\n",fTemp);
fprintf(stdout, "Rain = %d\n",iRain);
fprintf(stdout, "checksum = %02x==%02x\n",chksum&0xF,reverse8(bb[i][4]));
fprintf(stdout, "Received Data = %02X %02X %02X %02X %02X\n",
reverse8(bb[i][0]),
reverse8(bb[i][1]),
reverse8(bb[i][2]),
reverse8(bb[i][3]),
reverse8(bb[i][4]));
}
if( (chksum&0x0F) == ( reverse8(bb[i][4]) &0x0F)){
fprintf(stdout, "\nSensor = Temperature and rain event\n");
fprintf(stdout, "Device = %d\n", device);
fprintf(stdout, "Temp = %f\n",fTemp);
fprintf(stdout, "Rain = %d\n",iRain);
fprintf(stdout, "checksum = %02x==%02x\n",chksum&0xF,reverse8(bb[i][4]));
fprintf(stdout, "Received Data = %02X %02X %02X %02X %02X\n",
reverse8(bb[i][0]),
reverse8(bb[i][1]),
reverse8(bb[i][2]),
reverse8(bb[i][3]),
reverse8(bb[i][4]));
/* Get time now */
local_time_str(0, time_str);
data = data_make("time", "", DATA_STRING, time_str,
"model", "", DATA_STRING, "Inovalley kw9015b, TFA Dostmann 30.3161 (Rain and temperature sensor)",
"id", "", DATA_INT, device,
"temperature_C", "Temperature", DATA_FORMAT, "%.01f C", DATA_DOUBLE, fTemp,
"rain","Rain Count", DATA_INT, iRain,
NULL);
data_acquired_handler(data);
return 1;
@@ -61,8 +78,19 @@ static int kw9015b_callback(bitbuffer_t *bitbuffer) {
}
static char *kw9015b_csv_output_fields[] = {
"time",
"model",
"id",
"temperature_C",
"rain",
NULL
};
r_device kw9015b = {
.name = "Inovalley kw9015b rain and Temperature weather station",
.name = "Inovalley kw9015b, TFA Dostmann 30.3161 (Rain and temperature sensor)",
.modulation = OOK_PULSE_PPM_RAW,
.short_limit = 3500,
.long_limit = 4800,
@@ -70,4 +98,5 @@ r_device kw9015b = {
.json_callback = &kw9015b_callback,
.disabled = 1,
.demod_arg = 0,
.fields = kw9015b_csv_output_fields,
};