9
9
(at your option) any later version.
10
10
*/
11
11
12
+ #include "decoder.h"
13
+
12
14
/**
13
15
Klimalogg/30.3180.IT sensor decoder.
14
16
17
+ Also Klimalogg/30.3181.IT (no humidity) sensor decoder.
18
+
15
19
Working decoder and information from https://github.com/baycom/tfrec
16
20
17
21
The message is 2 bytes of sync word plus 9 bytes of data.
@@ -26,7 +30,7 @@ Data layout:
26
30
- II(15) is either 1 or 0 (fixed, depends on the sensor)
27
31
- s(3:0): Learning sequence 0...f, after learning fixed 8
28
32
- 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
30
34
- BB(7): Low battery if =1
31
35
- BB(6:4): 110 or 111 (for 3199)
32
36
- SS(7:4): sequence number (0...f)
@@ -39,12 +43,9 @@ play with the -l option (5000-15000 range) or a high sample rate.
39
43
40
44
*/
41
45
42
- #include "decoder.h"
43
-
44
46
static int klimalogg_decode (r_device * decoder , bitbuffer_t * bitbuffer )
45
47
{
46
48
uint8_t const preamble_pattern [] = {0xB4 , 0x2B }; // 0x2d, 0xd4 bit reflected
47
- uint8_t b [9 ] = {0 };
48
49
49
50
if (bitbuffer -> bits_per_row [0 ] < 11 * 8 ) {
50
51
return DECODE_ABORT_LENGTH ;
@@ -55,25 +56,33 @@ static int klimalogg_decode(r_device *decoder, bitbuffer_t *bitbuffer)
55
56
return DECODE_ABORT_LENGTH ;
56
57
}
57
58
59
+ uint8_t b [9 ];
58
60
bitbuffer_extract_bytes (bitbuffer , 0 , bit_offset , b , 9 * 8 );
59
61
60
- if (b [7 ] != 0x6a ) // 0x56 bit reflected
62
+ if (b [7 ] != 0x6a ) { // 0x56 bit reflected
61
63
return DECODE_FAIL_SANITY ;
64
+ }
62
65
63
66
reflect_bytes (b , 9 );
64
67
65
68
int crc = crc8 (b , 9 , 0x31 , 0 );
66
- if (crc )
69
+ if (crc ) {
67
70
return DECODE_FAIL_MIC ;
71
+ }
68
72
69
73
/* Extract parameters */
70
74
int id = (b [0 ] & 0x7f ) << 8 | b [1 ];
71
75
int temp_raw = (b [2 ] & 0x0f ) * 100 + (b [3 ] >> 4 ) * 10 + (b [3 ] & 0x0f );
72
76
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
74
78
int battery_low = (b [5 ] & 0x80 ) >> 7 ;
75
79
int sequence_nr = (b [6 ] & 0xf0 ) >> 4 ;
76
80
81
+ // Set humidity error code to 100%
82
+ if (humidity == 0x6a ) {
83
+ humidity = 100 ;
84
+ }
85
+
77
86
/* clang-format off */
78
87
data_t * data = data_make (
79
88
"model" , "" , DATA_STRING , "Klimalogg-Pro" ,
0 commit comments