Skip to content

Commit 321f231

Browse files
committedJun 14, 2024·
Change Klimalogg-Pro max humidity (closes merbanan#2967)
1 parent cd74bcc commit 321f231

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed
 

‎src/devices/klimalogg.c

+16-7
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
(at your option) any later version.
1010
*/
1111

12+
#include "decoder.h"
13+
1214
/**
1315
Klimalogg/30.3180.IT sensor decoder.
1416
17+
Also Klimalogg/30.3181.IT (no humidity) sensor decoder.
18+
1519
Working decoder and information from https://github.com/baycom/tfrec
1620
1721
The message is 2 bytes of sync word plus 9 bytes of data.
@@ -26,7 +30,7 @@ Data layout:
2630
- II(15) is either 1 or 0 (fixed, depends on the sensor)
2731
- s(3:0): Learning sequence 0...f, after learning fixed 8
2832
- TTT: Temperature in BCD in .1degC steps, offset +40degC (-> -40...+60)
29-
- HH(6:0): rel. Humidity in % (binary coded, no BCD!)
33+
- HH(6:0): rel. Humidity in % (binary coded, no BCD!), 0x6a when saturated or n/a
3034
- BB(7): Low battery if =1
3135
- BB(6:4): 110 or 111 (for 3199)
3236
- SS(7:4): sequence number (0...f)
@@ -39,12 +43,9 @@ play with the -l option (5000-15000 range) or a high sample rate.
3943
4044
*/
4145

42-
#include "decoder.h"
43-
4446
static int klimalogg_decode(r_device *decoder, bitbuffer_t *bitbuffer)
4547
{
4648
uint8_t const preamble_pattern[] = {0xB4, 0x2B}; // 0x2d, 0xd4 bit reflected
47-
uint8_t b[9] = {0};
4849

4950
if (bitbuffer->bits_per_row[0] < 11 * 8) {
5051
return DECODE_ABORT_LENGTH;
@@ -55,25 +56,33 @@ static int klimalogg_decode(r_device *decoder, bitbuffer_t *bitbuffer)
5556
return DECODE_ABORT_LENGTH;
5657
}
5758

59+
uint8_t b[9];
5860
bitbuffer_extract_bytes(bitbuffer, 0, bit_offset, b, 9 * 8);
5961

60-
if (b[7] != 0x6a) // 0x56 bit reflected
62+
if (b[7] != 0x6a) { // 0x56 bit reflected
6163
return DECODE_FAIL_SANITY;
64+
}
6265

6366
reflect_bytes(b, 9);
6467

6568
int crc = crc8(b, 9, 0x31, 0);
66-
if (crc)
69+
if (crc) {
6770
return DECODE_FAIL_MIC;
71+
}
6872

6973
/* Extract parameters */
7074
int id = (b[0] & 0x7f) << 8 | b[1];
7175
int temp_raw = (b[2] & 0x0f) * 100 + (b[3] >> 4) * 10 + (b[3] & 0x0f);
7276
float temperature = (temp_raw - 400) * 0.1f;
73-
int humidity = (b[4] & 0x7f);
77+
int humidity = (b[4] & 0x7f); // fixed 0x6a when saturated or n/a
7478
int battery_low = (b[5] & 0x80) >> 7;
7579
int sequence_nr = (b[6] & 0xf0) >> 4;
7680

81+
// Set humidity error code to 100%
82+
if (humidity == 0x6a) {
83+
humidity = 100;
84+
}
85+
7786
/* clang-format off */
7887
data_t *data = data_make(
7988
"model", "", DATA_STRING, "Klimalogg-Pro",

0 commit comments

Comments
 (0)
Please sign in to comment.