Skip to content

Commit

Permalink
Added support for WHB type 9, extended temperature range sensor 30.33…
Browse files Browse the repository at this point in the history
…02.02
  • Loading branch information
Georg Acher committed Aug 17, 2022
1 parent 2f0fae4 commit bf0803b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Supported sensors are (see sensors.txt for more details):
- NRZ/17240baud: 30.3143.IT, 30.3144.IT, 30.3147.IT, 30.3157.IT, 30.3159.IT and probably 30.3146.IT
- NRZ/8842baud: Technoline TX22
- NRZS/6000baud: WeatherHub sensors (TFA 30.3303.02, 30.3305.02, 30.3306.02, 30.3307.02 30.3311.02,
MA10410/TFA 35.1147.01, TFA 35.1147.01, 30.3304.02, 30.5043.01
MA10410/TFA 35.1147.01, TFA 35.1147.01, 30.3302.02, [B30.3304.02, 30.5043.01
Technoline Mobile Alerts:
MA10100 MA10200 MA10650 MA10660)

Expand Down
3 changes: 3 additions & 0 deletions sensors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ X) Probably never supported
30.3311.02 TFA_WHB - - - 6Byte - 6000 PSK-NRZM 4b2dd42b 21600s+ - WeatherHub door sensor
35.1147.01 TFA_WHB X X 2 6Byte X 6000 PSK-NRZM 4b2dd42b ? - WeatherHub station, indoor + outdoor sensor
30.3060.01 TFA_WHB X +3 4 6Byte X 6000 PSK-NRZM 4b2dd42b ? - WeatherHub station, indoor + 3*outdoor sensors
30.3302.02 TFA_WHB X X X 6Byte X 6000 PSK-NRZM 4b2dd42b 120 - WeatherHub temp/humidity + cable temp sensor (extended range -50...+110C)
30.3304.02 TFA_WHB X X X 6Byte X 6000 PSK-NRZM 4b2dd42b ? - WeatherHub temp/humidity + cable temp sensor
30.5043.01 TFA_WHB X - X 6Byte X 6000 PSK-NRZM 4b2dd42b ? - WeatherHub Cosy Radar (3h/24h/7d/24h humidity average)



Notes:

30.3181/Temp1, 30.3143/Temp2, 30.3304.02/Temp2: External temperature sensor (NTC 10k @ 25 degC)
Expand Down
48 changes: 35 additions & 13 deletions whb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ map<uint32_t, uint32_t> crc_initvals = {
{ 0x06, 0xa7a41254}, // Temp/hum + temp2
{ 0x07, 0x3303fb1d}, // Station MA10410 (TFA 35.1147.01)
{ 0x08, 0x29f0f49b}, // Rain sensor (+ temp)
{ 0x09, 0xa7a41254}, // Temp/hum + temp2 (TFA 30.3302.02), extended temperature range
{ 0x0b, 0xe7720ae4}, // Wind sensor
{ 0x10, 0x62d0afc1}, // Door sensor
{ 0x11, 0x8cba0708}, // 4 Thermo-hygro-sensors (TFA 30.3060.01)
Expand Down Expand Up @@ -105,12 +106,20 @@ whb_decoder::whb_decoder(sensor_e _type) : decoder(_type)
nrzs=0;
}
//-------------------------------------------------------------------------
double whb_decoder::cvt_temp(uint16_t raw)
double whb_decoder::cvt_temp(uint16_t raw, int extended)
{
if (raw&0x400)
return -((raw^0x7ff)+1)/10.0;
else
return raw/10.0;
if (extended==1) {
// extened range, bit 11 is actually the sign bit (range -204.7 to 204.7)
if (raw&0x800)
return -((raw^0xfff)+1)/10.0;
else
return raw/10.0;
} else {
if (raw&0x400)
return -((raw^0x7ff)+1)/10.0;
else
return raw/10.0;
}
}
//-------------------------------------------------------------------------
// Temp/hum
Expand Down Expand Up @@ -203,19 +212,29 @@ void whb_decoder::decode_04(uint8_t *msg, uint64_t id, int rssi, int offset)
}
//-------------------------------------------------------------------------
// Temp/hum + temp2
void whb_decoder::decode_06(uint8_t *msg, uint64_t id, int rssi, int offset)
// decodes also version 9 with extended temperature range
void whb_decoder::decode_06_09(uint8_t *msg, uint64_t id, int rssi, int offset, int extended)
{
uint16_t seq=BE16(msg)&0x3fff;;
uint16_t temp=BE16(msg+2)&0x7ff;
uint16_t temp2=BE16(msg+4)&0x7ff;
uint16_t temp2, temp2_prev;
int whb_type=6;
if (extended==1) {
temp2=BE16(msg+4)&0xfff;
temp2_prev=BE16(msg+10)&0xfff;
whb_type=9;

} else {
temp2=BE16(msg+4)&0x7ff;
temp2_prev=BE16(msg+10)&0x7ff;
}
uint16_t hum=BE16(msg+6)&0xff;

uint16_t temp_prev=BE16(msg+8)&0x7ff;
uint16_t temp2_prev=BE16(msg+10)&0x7ff;
uint16_t hum_prev=BE16(msg+12)&0xff;

if (dbg>=0) {
printf("WHB06 ID %" PRIx64 "TEMP %g HUM %i TEMP2 %g, PTEMP %g PHUM %i PTEMP2 %g\n",
id, cvt_temp(temp),hum,cvt_temp(temp2), cvt_temp(temp_prev), hum_prev, cvt_temp(temp2_prev));
printf("WHB0%i ID %" PRIx64 "TEMP %g HUM %i TEMP2 %g, PTEMP %g PHUM %i PTEMP2 %g\n",
whb_type, id, cvt_temp(temp),hum,cvt_temp(temp2,extended), cvt_temp(temp_prev), hum_prev, cvt_temp(temp2_prev,extended));
fflush(stdout);
}
sensordata_t sd;
Expand All @@ -231,7 +250,7 @@ void whb_decoder::decode_06(uint8_t *msg, uint64_t id, int rssi, int offset)
store_data(sd);

sd.id=(id<<4LL)|1;
sd.temp=cvt_temp(temp2);
sd.temp=cvt_temp(temp2, extended);
sd.humidity=0;
store_data(sd);
}
Expand Down Expand Up @@ -502,14 +521,17 @@ void whb_decoder::flush(int rssi, int offset)
decode_04(msg, id, rssi, offset);
break;
case 0x06:
decode_06(msg, id, rssi, offset);
decode_06_09(msg, id, rssi, offset);
break;
case 0x07:
decode_07(msg, id, rssi, offset);
break;
case 0x08:
decode_08(msg, id, rssi, offset);
break;
case 0x09:
decode_06_09(msg, id, rssi, offset, 1);
break;
case 0x0b:
decode_0b(msg, id, rssi, offset);
break;
Expand Down
4 changes: 2 additions & 2 deletions whb.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class whb_decoder: public decoder
void store_bit(int bit);
void flush(int rssi,int offset=0);
private:
double cvt_temp(uint16_t raw);
double cvt_temp(uint16_t raw, int extended=0);
void decode_02(uint8_t *msg, uint64_t id, int rssi, int offset); // temp
void decode_03(uint8_t *msg, uint64_t id, int rssi, int offset); // temp/hum
void decode_04(uint8_t *msg, uint64_t id, int rssi, int offset); // temp/hum/water
void decode_06(uint8_t *msg, uint64_t id, int rssi, int offset); // temp/hum + temp (TFA 30.3304.02)
void decode_06_09(uint8_t *msg, uint64_t id, int rssi, int offset, int extended=0); // temp/hum + temp (TFA 30.3304.02, extended range 30.3302.02)
void decode_07(uint8_t *msg, uint64_t id, int rssi, int offset); // Station MA10410 (TFA 35.1147.01)
void decode_08(uint8_t *msg, uint64_t id, int rssi, int offset); // rain
void decode_0b(uint8_t *msg, uint64_t id, int rssi, int offset); // wind
Expand Down

0 comments on commit bf0803b

Please sign in to comment.