5 /* Kedsum temperature and humidity sensor (http://amzn.to/25IXeng)
6 My models transmit at a bit lower freq. Around ~433.71 Mhz
8 Copyright (C) 2016 John Lifsey
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 3 as
11 published by the Free Software Foundation.
13 Largely based on prologue, esperanza_ews, s3318p
14 Frame appears to be a differently-endianed version of the esperanza
17 IIIIIIII????CC++++ttttTTTThhhhHHHH?????? PP
19 IIIIIIII unique id. changes on powercycle
20 CC channel, 00 = ch1, 10=ch3
24 hhhh humidity low nibble
25 HHHH humidity high nibble
29 static int kedsum_callback(bitbuffer_t *bitbuffer) {
30 bitrow_t *bb = bitbuffer->bb;
33 char time_str[LOCAL_TIME_BUFLEN];
34 local_time_str(0, time_str);
36 int r = bitbuffer_find_repeated_row(bitbuffer, 6, 42);
37 if (r<0 || bitbuffer->bits_per_row[r] != 42 || bitbuffer->num_rows != 14)
44 uint16_t temperature_with_offset;
47 channel = (uint8_t)(((b[1] & 0x0C) >> 2) + 1);
48 humidity = (uint8_t)((b[3] & 0x03) << 6) | ((b[4] & 0xC0) >> 2) | ((b[3] & 0x3C) >> 2);
50 uint8_t tnH, tnM, tnL;
51 tnL = ((b[1] & 0x03) << 2) | ((b[2] & 0xC0) >> 6); // Low temp nibble
52 tnM = ((b[2] & 0x3C) >> 2); // Med temp nibble
53 tnH = ((b[2] & 0x03) << 2) | ((b[3] & 0xC0) >> 6); // high temp nibble
55 temperature_with_offset = (tnH<<8) | (tnM<<4) | tnL;
56 temperature_f = (temperature_with_offset - 900) / 10.0;
59 fprintf(stdout, "Bitstream HEX = %02x %02x %02x %02x %02x %02x\n",b[0],b[1],b[2],b[3],b[4],b[5]);
60 fprintf(stdout, "Humidity HEX = %02x\n", b[3]);
61 fprintf(stdout, "Humidity DEC = %u\n", humidity);
62 fprintf(stdout, "Channel HEX = %02x\n", b[1]);
63 fprintf(stdout, "Channel = %u\n", channel);
64 fprintf(stdout, "temp_with_offset HEX = %02x\n", temperature_with_offset);
65 fprintf(stdout, "temp_with_offset = %d\n", temperature_with_offset);
66 fprintf(stdout, "TemperatureF = %.1f\n", temperature_f);
69 data = data_make("time", "", DATA_STRING, time_str,
70 "model", "", DATA_STRING, "Kedsum Temperature & Humidity Sensor",
71 "channel", "Channel", DATA_INT, channel,
72 "temperature_F", "Temperature", DATA_FORMAT, "%.02f F", DATA_DOUBLE, temperature_f,
73 "humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
76 data_acquired_handler(data);
80 static char *output_fields[] = {
90 .name = "Kedsum Temperature & Humidity Sensor",
91 .modulation = OOK_PULSE_PPM_RAW,
95 .json_callback = &kedsum_callback,
98 .fields = output_fields