Skip to content

Commit

Permalink
Merge pull request #25 from matthias-bs/matthias-bs-patch-1
Browse files Browse the repository at this point in the history
decodeBresser5In1Payload(): added additional rain digit
  • Loading branch information
matthias-bs authored Jan 11, 2023
2 parents b7a0d90 + 14b829e commit 6d185e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions examples/BresserWeatherSensorMQTTCustom/src/WeatherSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
// 20220815 Added support of multiple sensors
// Moved windspeed_ms_to_bft() to WeatherUtils.h/.cpp
// 20221207 Added SENSOR_TYPE_THERMO_HYGRO
// 20220110 Added WEATHER0_RAIN_OV/WEATHER1_RAIN_OV
//
// ToDo:
// -
Expand Down Expand Up @@ -80,11 +81,17 @@
#define SENSOR_TYPE_RAIN 9 // Professional Rain Gauge (from 5-in-1 decoder)


// Sensor specific rain gauge overflow threshold (mm)
#define WEATHER0_RAIN_OV 1000
#define WEATHER1_RAIN_OV 100000


// Flags for controlling completion of reception in getData()
#define DATA_COMPLETE 0x1 // only completed slots (as opposed to partially filled)
#define DATA_TYPE 0x2 // at least one slot with specific sensor type
#define DATA_ALL_SLOTS 0x8 // all slots completed


// Radio message decoding status
typedef enum DecodeStatus {
DECODE_INVALID, DECODE_OK, DECODE_PAR_ERR, DECODE_CHK_ERR, DECODE_DIG_ERR, DECODE_SKIP, DECODE_FULL
Expand Down
6 changes: 3 additions & 3 deletions src/WeatherSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ int WeatherSensor::add_bytes(uint8_t const message[], unsigned num_bytes)
//
// Example input data:
// EA EC 7F EB 5F EE EF FA FE 76 BB FA FF 15 13 80 14 A0 11 10 05 01 89 44 05 00
// CC CC CC CC CC CC CC CC CC CC CC CC CC uu II SS GG DG WW W TT T HH RR R Bt
// CC CC CC CC CC CC CC CC CC CC CC CC CC uu II SS GG DG WW W TT T HH RR RR Bt
// - C = Check, inverted data of 13 byte further
// - uu = checksum (number/count of set bits within bytes 14-25)
// - I = station ID (maybe)
Expand All @@ -427,7 +427,7 @@ int WeatherSensor::add_bytes(uint8_t const message[], unsigned num_bytes)
// - T = temperature in 1/10 °C, BCD coded, TTxT = 1203 => 31.2 °C
// - t = temperature sign, minus if unequal 0
// - H = humidity in percent, BCD coded, HH = 23 => 23 %
// - R = rain in mm, BCD coded, RRxR = 1203 => 31.2 mm
// - R = rain in mm, BCD coded, RRRR = 1203 => 031.2 mm
// - B = Battery. 0=Ok, 8=Low.
// - S = sensor type, only low nibble used, 0x9 for Bresser Professional Rain Gauge
//
Expand Down Expand Up @@ -507,7 +507,7 @@ DecodeStatus WeatherSensor::decodeBresser5In1Payload(uint8_t *msg, uint8_t msgSi
sensor[slot].wind_avg_meter_sec_fp1 = wind_raw;
#endif

int rain_raw = (msg[23] & 0x0f) + ((msg[23] & 0xf0) >> 4) * 10 + (msg[24] & 0x0f) * 100;
int rain_raw = (msg[23] & 0x0f) + ((msg[23] & 0xf0) >> 4) * 10 + (msg[24] & 0x0f) * 100 + ((msg[24] & 0xf0) >> 4) * 1000;
sensor[slot].rain_mm = rain_raw * 0.1f;

sensor[slot].battery_ok = (msg[25] & 0x80) ? false : true;
Expand Down
7 changes: 7 additions & 0 deletions src/WeatherSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
// 20220815 Added support of multiple sensors
// Moved windspeed_ms_to_bft() to WeatherUtils.h/.cpp
// 20221207 Added SENSOR_TYPE_THERMO_HYGRO
// 20220110 Added WEATHER0_RAIN_OV/WEATHER1_RAIN_OV
//
// ToDo:
// -
Expand Down Expand Up @@ -80,11 +81,17 @@
#define SENSOR_TYPE_RAIN 9 // Professional Rain Gauge (from 5-in-1 decoder)


// Sensor specific rain gauge overflow threshold (mm)
#define WEATHER0_RAIN_OV 1000
#define WEATHER1_RAIN_OV 100000


// Flags for controlling completion of reception in getData()
#define DATA_COMPLETE 0x1 // only completed slots (as opposed to partially filled)
#define DATA_TYPE 0x2 // at least one slot with specific sensor type
#define DATA_ALL_SLOTS 0x8 // all slots completed


// Radio message decoding status
typedef enum DecodeStatus {
DECODE_INVALID, DECODE_OK, DECODE_PAR_ERR, DECODE_CHK_ERR, DECODE_DIG_ERR, DECODE_SKIP, DECODE_FULL
Expand Down

0 comments on commit 6d185e6

Please sign in to comment.