diff --git a/_weather_sensor_8h_source.html b/_weather_sensor_8h_source.html index aa2bab74..59fac116 100644 --- a/_weather_sensor_8h_source.html +++ b/_weather_sensor_8h_source.html @@ -148,291 +148,294 @@
61 // 20230723 Added SENSOR_TYPE_WATER
62 // 20230804 Added Bresser Water Leakage Sensor decoder
63 // 20231006 Added crc16() from https://github.com/merbanan/rtl_433/blob/master/src/util.c
-
64 //
-
65 // ToDo:
-
66 // -
-
67 //
-
69 
-
70 #ifndef WeatherSensor_h
-
71 #define WeatherSensor_h
-
72 
-
73 #include <Arduino.h>
-
74 #include <RadioLib.h>
-
75 
+
64 // 20231024 Added SENSOR_TYPE_POOL_THERMO
+
65 //
+
66 // ToDo:
+
67 // -
+
68 //
+
70 
+
71 #ifndef WeatherSensor_h
+
72 #define WeatherSensor_h
+
73 
+
74 #include <Arduino.h>
+
75 #include <RadioLib.h>
76 
-
77 // Sensor Types
-
78 // 0 - Weather Station 5-in-1; PN 7002510..12/7902510..12
-
79 // 1 - Weather Station 6-in-1; PN 7002585
-
80 // - Professional Wind Gauge 6-in-1; PN 7002531
-
81 // 2 - Thermo-/Hygro-Sensor 6-in-1; PN 7009999
-
82 // 3 - Lightning Sensor PN 7009976
-
83 // 4 - Soil Moisture Sensor 6-in-1; PN 7009972
-
84 // 5 - Water Leakage Sensor 6-in-1; PN 7009975
-
85 // 9 - Professional Rain Gauge (5-in-1 decoder)
-
86 // 11 - Weather Sensor 7-in-1 7-in-1; PN 7003300
-
87 // ? - Air Quality Sensor PM2.5/PM10
-
88 // ? - CO2 Sensor
-
89 // ? - HCHO/VCO Sensor
-
90 // ? - Pool Thermometer
-
91 #define SENSOR_TYPE_WEATHER0 0 // Weather Station
-
92 #define SENSOR_TYPE_WEATHER1 1 // Weather Station
-
93 #define SENSOR_TYPE_THERMO_HYGRO 2 // Thermo-/Hygro-Sensor
-
94 #define SENSOR_TYPE_LIGHTNING 3 // Lightning Sensor
-
95 #define SENSOR_TYPE_SOIL 4 // Soil Temperature and Moisture (from 6-in-1 decoder)
-
96 #define SENSOR_TYPE_LEAKAGE 5 // Water Leakage
-
97 #define SENSOR_TYPE_RAIN 9 // Professional Rain Gauge (from 5-in-1 decoder)
-
98 #define SENSOR_TYPE_WEATHER_7IN1 11 // Weather Sensor 7-in-1
-
99 
-
100 
-
101 // Sensor specific rain gauge overflow threshold (mm)
-
102 #define WEATHER0_RAIN_OV 1000
-
103 #define WEATHER1_RAIN_OV 100000
-
104 
-
105 
-
106 // Flags for controlling completion of reception in getData()
-
107 #define DATA_COMPLETE 0x1 // only completed slots (as opposed to partially filled)
-
108 #define DATA_TYPE 0x2 // at least one slot with specific sensor type
-
109 #define DATA_ALL_SLOTS 0x8 // all slots completed
-
110 
-
111 // Message buffer size
-
112 #define MSG_BUF_SIZE 27
+
77 
+
78 // Sensor Types
+
79 // 0 - Weather Station 5-in-1; PN 7002510..12/7902510..12
+
80 // 1 - Weather Station 6-in-1; PN 7002585
+
81 // - Professional Wind Gauge 6-in-1; PN 7002531
+
82 // 2 - Thermo-/Hygro-Sensor 6-in-1; PN 7009999
+
83 // 3 - Lightning Sensor PN 7009976
+
84 // 3 - Pool / Spa Thermometer PN 7000073
+
85 // 4 - Soil Moisture Sensor 6-in-1; PN 7009972
+
86 // 5 - Water Leakage Sensor 6-in-1; PN 7009975
+
87 // 9 - Professional Rain Gauge (5-in-1 decoder)
+
88 // 11 - Weather Sensor 7-in-1 7-in-1; PN 7003300
+
89 // ? - Air Quality Sensor PM2.5/PM10
+
90 // ? - CO2 Sensor
+
91 // ? - HCHO/VCO Sensor
+
92 // ? - Pool Thermometer
+
93 #define SENSOR_TYPE_WEATHER0 0 // Weather Station
+
94 #define SENSOR_TYPE_WEATHER1 1 // Weather Station
+
95 #define SENSOR_TYPE_THERMO_HYGRO 2 // Thermo-/Hygro-Sensor
+
96 #define SENSOR_TYPE_LIGHTNING 3 // Lightning Sensor
+
97 #define SENSOR_TYPE_POOL_THERMO 3 // Pool / Spa Thermometer
+
98 #define SENSOR_TYPE_SOIL 4 // Soil Temperature and Moisture (from 6-in-1 decoder)
+
99 #define SENSOR_TYPE_LEAKAGE 5 // Water Leakage
+
100 #define SENSOR_TYPE_RAIN 9 // Professional Rain Gauge (from 5-in-1 decoder)
+
101 #define SENSOR_TYPE_WEATHER_7IN1 11 // Weather Sensor 7-in-1
+
102 
+
103 
+
104 // Sensor specific rain gauge overflow threshold (mm)
+
105 #define WEATHER0_RAIN_OV 1000
+
106 #define WEATHER1_RAIN_OV 100000
+
107 
+
108 
+
109 // Flags for controlling completion of reception in getData()
+
110 #define DATA_COMPLETE 0x1 // only completed slots (as opposed to partially filled)
+
111 #define DATA_TYPE 0x2 // at least one slot with specific sensor type
+
112 #define DATA_ALL_SLOTS 0x8 // all slots completed
113 
-
114 // Radio message decoding status
-
115 typedef enum DecodeStatus {
-
116  DECODE_INVALID, DECODE_OK, DECODE_PAR_ERR, DECODE_CHK_ERR, DECODE_DIG_ERR, DECODE_SKIP, DECODE_FULL
-
117 } DecodeStatus;
-
118 
-
119 
-
120 #if !defined(ARDUINO_ARCH_AVR)
-
121 #include <string>
+
114 // Message buffer size
+
115 #define MSG_BUF_SIZE 27
+
116 
+
117 // Radio message decoding status
+
118 typedef enum DecodeStatus {
+
119  DECODE_INVALID, DECODE_OK, DECODE_PAR_ERR, DECODE_CHK_ERR, DECODE_DIG_ERR, DECODE_SKIP, DECODE_FULL
+
120 } DecodeStatus;
+
121 
122 
-
128 typedef struct SensorMap {
-
129  uint32_t id;
-
130  std::string name;
-
131 } SensorMap;
-
132 #endif
-
133 
-
134 
-
141 class WeatherSensor {
-
142  public:
-
147  WeatherSensor()
-
148  {
-
149  };
-
150 
-
151 
-
157  int16_t begin(void);
-
158 
-
159 
-
176  bool getData(uint32_t timeout, uint8_t flags = 0, uint8_t type = 0, void (*func)() = NULL);
-
177 
-
178 
-
185  DecodeStatus getMessage(void);
-
186 
-
193  DecodeStatus decodeMessage(const uint8_t *msg, uint8_t msgSize);
-
194 
-
200  struct Sensor {
-
201  uint32_t sensor_id;
-
202  uint8_t s_type;
-
203  uint8_t chan;
-
204  bool startup = false;
-
205  bool valid;
-
206  bool complete;
-
207  bool temp_ok = false;
-
208  bool humidity_ok = false;
-
209  bool light_ok = false;
-
210  bool uv_ok = false;
-
211  bool wind_ok = false;
-
212  bool rain_ok = false;
-
213  bool battery_ok = false;
-
214  bool moisture_ok = false;
-
215  bool lightning_ok = false;
-
216  bool leakage_ok = false;
-
217  float temp_c;
-
218  float light_klx;
-
219  float light_lux;
-
220  float uv;
-
221  float rain_mm;
-
222  #ifdef WIND_DATA_FLOATINGPOINT
-
223  float wind_direction_deg;
-
224  float wind_gust_meter_sec;
-
225  float wind_avg_meter_sec;
-
226  #endif
-
227  #ifdef WIND_DATA_FIXEDPOINT
-
228  // For LoRa_Serialization:
-
229  // fixed point integer with 1 decimal -
-
230  // saves two bytes compared to "RawFloat"
-
231  uint16_t wind_direction_deg_fp1;
-
232  uint16_t wind_gust_meter_sec_fp1;
-
233  uint16_t wind_avg_meter_sec_fp1;
-
234  #endif
-
235  uint8_t humidity;
-
236  uint8_t moisture;
-
237  uint8_t lightning_distance_km;
-
238  uint8_t lightning_count;
-
239  uint16_t lightning_unknown1;
-
240  uint16_t lightning_unknown2;
-
241  bool water_leakage_alarm;
-
242  float rssi;
-
243  };
-
244 
-
245  typedef struct Sensor sensor_t;
-
246  sensor_t sensor[NUM_SENSORS];
-
247  float rssi;
-
248 
-
249 
-
255  bool genMessage(int i, uint32_t id = 0xff, uint8_t type = 1, uint8_t channel = 0);
-
256 
-
257 
-
266  void clearSlots(uint8_t type = 0xFF)
-
267  {
-
268  for (int i=0; i< NUM_SENSORS; i++) {
-
269  if ((type == 0xFF) || (sensor[i].s_type == type)) {
-
270  sensor[i].valid = false;
-
271  sensor[i].complete = false;
-
272  sensor[i].temp_ok = false;
-
273  sensor[i].humidity_ok = false;
-
274  sensor[i].light_ok = false;
-
275  sensor[i].uv_ok = false;
-
276  sensor[i].wind_ok = false;
-
277  sensor[i].rain_ok = false;
-
278  sensor[i].moisture_ok = false;
-
279  sensor[i].lightning_ok = false;
-
280  sensor[i].leakage_ok = false;
-
281  }
-
282  }
-
283  };
-
284 
-
292  int findId(uint32_t id);
-
293 
-
294 
-
303  int findType(uint8_t type, uint8_t channel = 0xFF);
-
304 
-
313  bool is_decode3in1(uint32_t id);
-
314 
-
315  private:
-
316  struct Sensor *pData;
-
317 
-
335  int findSlot(uint32_t id, DecodeStatus * status);
-
336 
-
337 
-
338  #ifdef BRESSER_5_IN_1
-
348  DecodeStatus decodeBresser5In1Payload(const uint8_t *msg, uint8_t msgSize);
-
349  #endif
-
350  #ifdef BRESSER_6_IN_1
-
362  DecodeStatus decodeBresser6In1Payload(const uint8_t *msg, uint8_t msgSize);
-
363  #endif
-
364  #ifdef BRESSER_7_IN_1
-
374  DecodeStatus decodeBresser7In1Payload(const uint8_t *msg, uint8_t msgSize);
-
375  #endif
-
376  #ifdef BRESSER_LIGHTNING
-
386  DecodeStatus decodeBresserLightningPayload(const uint8_t *msg, uint8_t msgSize);
-
387  #endif
-
388  #ifdef BRESSER_LEAKAGE
-
398  DecodeStatus decodeBresserLeakagePayload(const uint8_t *msg, uint8_t msgSize);
-
399  #endif
-
400 
-
401  protected:
-
405  uint16_t lfsr_digest16(uint8_t const message[], unsigned bytes, uint16_t gen, uint16_t key);
-
406 
-
415  int add_bytes(uint8_t const message[], unsigned num_bytes);
-
416 
-
427  uint16_t crc16(uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init);
-
428 
-
429  #if CORE_DEBUG_LEVEL == ARDUHAL_LOG_LEVEL_VERBOSE
-
441  void log_message(const char *descr, const uint8_t *msg, uint8_t msgSize) {
-
442  char buf[128];
-
443  const char txt[] = "Byte #: ";
-
444  int offs;
-
445  int len1 = strlen(txt);
-
446  int len2 = strlen(descr) + 2; // add colon and space
-
447  int prefix_len = max(len1, len2);
-
448 
-
449  memset(buf, ' ', prefix_len);
-
450  buf[prefix_len] = '\0';
-
451  offs = (len1 < len2) ? (len2 - len1) : 0;
-
452  strcpy(&buf[offs], txt);
-
453 
-
454  // Print byte index
-
455  for (size_t i = 0 ; i < msgSize; i++) {
-
456  sprintf(&buf[strlen(buf)], "%02d ", i);
-
457  }
-
458  log_v("%s", buf);
-
459 
-
460  memset(buf, ' ', prefix_len);
-
461  buf[prefix_len] ='\0';
-
462  offs = (len1 > len2) ? (len1 - len2) : 0;
-
463  sprintf(&buf[offs], "%s: ", descr);
-
464 
-
465  for (size_t i = 0 ; i < msgSize; i++) {
-
466  sprintf(&buf[strlen(buf)], "%02X ", msg[i]);
-
467  }
-
468  log_v("%s", buf);
-
469  }
-
470  #endif
-
471 
-
472  #ifdef _DEBUG_MODE_
-
476  void printRawdata(uint8_t *msg, uint8_t msgSize) {
-
477  DEBUG_PRINT(F("Raw Data: "));
-
478  for (uint8_t p = 0 ; p < msgSize ; p++) {
-
479  if (msg[p] < 16) {
-
480  DEBUG_PRINT("0");
-
481  }
-
482  DEBUG_PRINT(msg[p], HEX);
-
483  DEBUG_PRINT(" ");
-
484  }
-
485  DEBUG_PRINTLN();
-
486  };
-
487  #endif
-
488 
-
489 };
-
490 
-
491 #endif
-
WeatherSensor
Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receivin...
Definition: WeatherSensor.h:141
-
WeatherSensor::getMessage
DecodeStatus getMessage(void)
Tries to receive radio message (non-blocking) and to decode it. Timeout occurs after a multitude of e...
Definition: WeatherSensor.cpp:212
-
WeatherSensor::findId
int findId(uint32_t id)
Definition: WeatherSensor.cpp:404
-
WeatherSensor::is_decode3in1
bool is_decode3in1(uint32_t id)
Definition: WeatherSensor.cpp:430
-
WeatherSensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:247
-
WeatherSensor::getData
bool getData(uint32_t timeout, uint8_t flags=0, uint8_t type=0, void(*func)()=NULL)
Wait for reception of data or occurrance of timeout. With BRESSER_6_IN_1, data is distributed across ...
Definition: WeatherSensor.cpp:155
-
WeatherSensor::genMessage
bool genMessage(int i, uint32_t id=0xff, uint8_t type=1, uint8_t channel=0)
Generates data otherwise received and decoded from a radio message.
Definition: WeatherSensor.cpp:298
-
WeatherSensor::begin
int16_t begin(void)
Presence check and initialization of radio module.
Definition: WeatherSensor.cpp:97
-
WeatherSensor::WeatherSensor
WeatherSensor()
Constructor.
Definition: WeatherSensor.h:147
-
WeatherSensor::findType
int findType(uint8_t type, uint8_t channel=0xFF)
Definition: WeatherSensor.cpp:417
-
WeatherSensor::sensor
sensor_t sensor[NUM_SENSORS]
sensor data array
Definition: WeatherSensor.h:246
-
WeatherSensor::clearSlots
void clearSlots(uint8_t type=0xFF)
Clear sensor data.
Definition: WeatherSensor.h:266
-
WeatherSensor::decodeMessage
DecodeStatus decodeMessage(const uint8_t *msg, uint8_t msgSize)
Decode message Tries the available decoders until a decoding was successful.
Definition: WeatherSensor.cpp:254
-
SensorMap
Mapping of sensor IDs to names.
Definition: WeatherSensor.h:128
-
SensorMap::name
std::string name
Name of sensor (e.g. for MQTT topic)
Definition: WeatherSensor.h:130
-
SensorMap::id
uint32_t id
ID if sensor (as transmitted in radio message)
Definition: WeatherSensor.h:129
-
WeatherSensor::Sensor
sensor data and status flags
Definition: WeatherSensor.h:200
-
WeatherSensor::Sensor::lightning_unknown1
uint16_t lightning_unknown1
unknown part 1
Definition: WeatherSensor.h:239
-
WeatherSensor::Sensor::battery_ok
bool battery_ok
battery o.k.
Definition: WeatherSensor.h:213
-
WeatherSensor::Sensor::temp_ok
bool temp_ok
temperature o.k. (only 6-in-1)
Definition: WeatherSensor.h:207
-
WeatherSensor::Sensor::lightning_ok
bool lightning_ok
lightning o.k. (only lightning)
Definition: WeatherSensor.h:215
-
WeatherSensor::Sensor::humidity
uint8_t humidity
humidity in %
Definition: WeatherSensor.h:235
-
WeatherSensor::Sensor::water_leakage_alarm
bool water_leakage_alarm
water leakage alarm (only water leakage)
Definition: WeatherSensor.h:241
-
WeatherSensor::Sensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:242
-
WeatherSensor::Sensor::humidity_ok
bool humidity_ok
humidity o.k.
Definition: WeatherSensor.h:208
-
WeatherSensor::Sensor::lightning_count
uint8_t lightning_count
lightning strike counter (only lightning)
Definition: WeatherSensor.h:238
-
WeatherSensor::Sensor::lightning_distance_km
uint8_t lightning_distance_km
lightning distance in km (only lightning)
Definition: WeatherSensor.h:237
-
WeatherSensor::Sensor::moisture
uint8_t moisture
moisture in % (only 6-in-1)
Definition: WeatherSensor.h:236
-
WeatherSensor::Sensor::complete
bool complete
data is split into two separate messages is complete (only 6-in-1 WS)
Definition: WeatherSensor.h:206
-
WeatherSensor::Sensor::light_ok
bool light_ok
light o.k. (only 7-in-1)
Definition: WeatherSensor.h:209
-
WeatherSensor::Sensor::s_type
uint8_t s_type
sensor type (only 6-in-1)
Definition: WeatherSensor.h:202
-
WeatherSensor::Sensor::light_lux
float light_lux
Light lux (only 7-in-1)
Definition: WeatherSensor.h:219
-
WeatherSensor::Sensor::startup
bool startup
startup after reset / battery change
Definition: WeatherSensor.h:204
-
WeatherSensor::Sensor::lightning_unknown2
uint16_t lightning_unknown2
unknown part 2
Definition: WeatherSensor.h:240
-
WeatherSensor::Sensor::leakage_ok
bool leakage_ok
water leakage o.k. (only water leackage)
Definition: WeatherSensor.h:216
-
WeatherSensor::Sensor::sensor_id
uint32_t sensor_id
sensor ID (5-in-1: 1 byte / 6-in-1: 4 bytes / 7-in-1: 2 bytes)
Definition: WeatherSensor.h:201
-
WeatherSensor::Sensor::chan
uint8_t chan
channel (only 6-in-1)
Definition: WeatherSensor.h:203
-
WeatherSensor::Sensor::uv_ok
bool uv_ok
uv radiation o.k. (only 6-in-1)
Definition: WeatherSensor.h:210
-
WeatherSensor::Sensor::moisture_ok
bool moisture_ok
moisture o.k. (only 6-in-1)
Definition: WeatherSensor.h:214
-
WeatherSensor::Sensor::temp_c
float temp_c
temperature in degC
Definition: WeatherSensor.h:217
-
WeatherSensor::Sensor::valid
bool valid
data valid (but not necessarily complete)
Definition: WeatherSensor.h:205
-
WeatherSensor::Sensor::rain_ok
bool rain_ok
rain gauge level o.k.
Definition: WeatherSensor.h:212
-
WeatherSensor::Sensor::light_klx
float light_klx
Light KLux (only 7-in-1)
Definition: WeatherSensor.h:218
-
WeatherSensor::Sensor::rain_mm
float rain_mm
rain gauge level in mm
Definition: WeatherSensor.h:221
-
WeatherSensor::Sensor::uv
float uv
uv radiation (only 6-in-1)
Definition: WeatherSensor.h:220
-
WeatherSensor::Sensor::wind_ok
bool wind_ok
wind speed/direction o.k. (only 6-in-1)
Definition: WeatherSensor.h:211
+
123 #if !defined(ARDUINO_ARCH_AVR)
+
124 #include <string>
+
125 
+
131 typedef struct SensorMap {
+
132  uint32_t id;
+
133  std::string name;
+
134 } SensorMap;
+
135 #endif
+
136 
+
137 
+
144 class WeatherSensor {
+
145  public:
+
150  WeatherSensor()
+
151  {
+
152  };
+
153 
+
154 
+
160  int16_t begin(void);
+
161 
+
162 
+
179  bool getData(uint32_t timeout, uint8_t flags = 0, uint8_t type = 0, void (*func)() = NULL);
+
180 
+
181 
+
188  DecodeStatus getMessage(void);
+
189 
+
196  DecodeStatus decodeMessage(const uint8_t *msg, uint8_t msgSize);
+
197 
+
203  struct Sensor {
+
204  uint32_t sensor_id;
+
205  uint8_t s_type;
+
206  uint8_t chan;
+
207  bool startup = false;
+
208  bool valid;
+
209  bool complete;
+
210  bool temp_ok = false;
+
211  bool humidity_ok = false;
+
212  bool light_ok = false;
+
213  bool uv_ok = false;
+
214  bool wind_ok = false;
+
215  bool rain_ok = false;
+
216  bool battery_ok = false;
+
217  bool moisture_ok = false;
+
218  bool lightning_ok = false;
+
219  bool leakage_ok = false;
+
220  float temp_c;
+
221  float light_klx;
+
222  float light_lux;
+
223  float uv;
+
224  float rain_mm;
+
225  #ifdef WIND_DATA_FLOATINGPOINT
+
226  float wind_direction_deg;
+
227  float wind_gust_meter_sec;
+
228  float wind_avg_meter_sec;
+
229  #endif
+
230  #ifdef WIND_DATA_FIXEDPOINT
+
231  // For LoRa_Serialization:
+
232  // fixed point integer with 1 decimal -
+
233  // saves two bytes compared to "RawFloat"
+
234  uint16_t wind_direction_deg_fp1;
+
235  uint16_t wind_gust_meter_sec_fp1;
+
236  uint16_t wind_avg_meter_sec_fp1;
+
237  #endif
+
238  uint8_t humidity;
+
239  uint8_t moisture;
+
240  uint8_t lightning_distance_km;
+
241  uint8_t lightning_count;
+
242  uint16_t lightning_unknown1;
+
243  uint16_t lightning_unknown2;
+
244  bool water_leakage_alarm;
+
245  float rssi;
+
246  };
+
247 
+
248  typedef struct Sensor sensor_t;
+
249  sensor_t sensor[NUM_SENSORS];
+
250  float rssi;
+
251 
+
252 
+
258  bool genMessage(int i, uint32_t id = 0xff, uint8_t type = 1, uint8_t channel = 0);
+
259 
+
260 
+
269  void clearSlots(uint8_t type = 0xFF)
+
270  {
+
271  for (int i=0; i< NUM_SENSORS; i++) {
+
272  if ((type == 0xFF) || (sensor[i].s_type == type)) {
+
273  sensor[i].valid = false;
+
274  sensor[i].complete = false;
+
275  sensor[i].temp_ok = false;
+
276  sensor[i].humidity_ok = false;
+
277  sensor[i].light_ok = false;
+
278  sensor[i].uv_ok = false;
+
279  sensor[i].wind_ok = false;
+
280  sensor[i].rain_ok = false;
+
281  sensor[i].moisture_ok = false;
+
282  sensor[i].lightning_ok = false;
+
283  sensor[i].leakage_ok = false;
+
284  }
+
285  }
+
286  };
+
287 
+
295  int findId(uint32_t id);
+
296 
+
297 
+
306  int findType(uint8_t type, uint8_t channel = 0xFF);
+
307 
+
316  bool is_decode3in1(uint32_t id);
+
317 
+
318  private:
+
319  struct Sensor *pData;
+
320 
+
338  int findSlot(uint32_t id, DecodeStatus * status);
+
339 
+
340 
+
341  #ifdef BRESSER_5_IN_1
+
351  DecodeStatus decodeBresser5In1Payload(const uint8_t *msg, uint8_t msgSize);
+
352  #endif
+
353  #ifdef BRESSER_6_IN_1
+
365  DecodeStatus decodeBresser6In1Payload(const uint8_t *msg, uint8_t msgSize);
+
366  #endif
+
367  #ifdef BRESSER_7_IN_1
+
377  DecodeStatus decodeBresser7In1Payload(const uint8_t *msg, uint8_t msgSize);
+
378  #endif
+
379  #ifdef BRESSER_LIGHTNING
+
389  DecodeStatus decodeBresserLightningPayload(const uint8_t *msg, uint8_t msgSize);
+
390  #endif
+
391  #ifdef BRESSER_LEAKAGE
+
401  DecodeStatus decodeBresserLeakagePayload(const uint8_t *msg, uint8_t msgSize);
+
402  #endif
+
403 
+
404  protected:
+
408  uint16_t lfsr_digest16(uint8_t const message[], unsigned bytes, uint16_t gen, uint16_t key);
+
409 
+
418  int add_bytes(uint8_t const message[], unsigned num_bytes);
+
419 
+
430  uint16_t crc16(uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init);
+
431 
+
432  #if CORE_DEBUG_LEVEL == ARDUHAL_LOG_LEVEL_VERBOSE
+
444  void log_message(const char *descr, const uint8_t *msg, uint8_t msgSize) {
+
445  char buf[128];
+
446  const char txt[] = "Byte #: ";
+
447  int offs;
+
448  int len1 = strlen(txt);
+
449  int len2 = strlen(descr) + 2; // add colon and space
+
450  int prefix_len = max(len1, len2);
+
451 
+
452  memset(buf, ' ', prefix_len);
+
453  buf[prefix_len] = '\0';
+
454  offs = (len1 < len2) ? (len2 - len1) : 0;
+
455  strcpy(&buf[offs], txt);
+
456 
+
457  // Print byte index
+
458  for (size_t i = 0 ; i < msgSize; i++) {
+
459  sprintf(&buf[strlen(buf)], "%02d ", i);
+
460  }
+
461  log_v("%s", buf);
+
462 
+
463  memset(buf, ' ', prefix_len);
+
464  buf[prefix_len] ='\0';
+
465  offs = (len1 > len2) ? (len1 - len2) : 0;
+
466  sprintf(&buf[offs], "%s: ", descr);
+
467 
+
468  for (size_t i = 0 ; i < msgSize; i++) {
+
469  sprintf(&buf[strlen(buf)], "%02X ", msg[i]);
+
470  }
+
471  log_v("%s", buf);
+
472  }
+
473  #endif
+
474 
+
475  #ifdef _DEBUG_MODE_
+
479  void printRawdata(uint8_t *msg, uint8_t msgSize) {
+
480  DEBUG_PRINT(F("Raw Data: "));
+
481  for (uint8_t p = 0 ; p < msgSize ; p++) {
+
482  if (msg[p] < 16) {
+
483  DEBUG_PRINT("0");
+
484  }
+
485  DEBUG_PRINT(msg[p], HEX);
+
486  DEBUG_PRINT(" ");
+
487  }
+
488  DEBUG_PRINTLN();
+
489  };
+
490  #endif
+
491 
+
492 };
+
493 
+
494 #endif
+
WeatherSensor
Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receivin...
Definition: WeatherSensor.h:144
+
WeatherSensor::getMessage
DecodeStatus getMessage(void)
Tries to receive radio message (non-blocking) and to decode it. Timeout occurs after a multitude of e...
Definition: WeatherSensor.cpp:213
+
WeatherSensor::findId
int findId(uint32_t id)
Definition: WeatherSensor.cpp:405
+
WeatherSensor::is_decode3in1
bool is_decode3in1(uint32_t id)
Definition: WeatherSensor.cpp:431
+
WeatherSensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:250
+
WeatherSensor::getData
bool getData(uint32_t timeout, uint8_t flags=0, uint8_t type=0, void(*func)()=NULL)
Wait for reception of data or occurrance of timeout. With BRESSER_6_IN_1, data is distributed across ...
Definition: WeatherSensor.cpp:156
+
WeatherSensor::genMessage
bool genMessage(int i, uint32_t id=0xff, uint8_t type=1, uint8_t channel=0)
Generates data otherwise received and decoded from a radio message.
Definition: WeatherSensor.cpp:299
+
WeatherSensor::begin
int16_t begin(void)
Presence check and initialization of radio module.
Definition: WeatherSensor.cpp:98
+
WeatherSensor::WeatherSensor
WeatherSensor()
Constructor.
Definition: WeatherSensor.h:150
+
WeatherSensor::findType
int findType(uint8_t type, uint8_t channel=0xFF)
Definition: WeatherSensor.cpp:418
+
WeatherSensor::sensor
sensor_t sensor[NUM_SENSORS]
sensor data array
Definition: WeatherSensor.h:249
+
WeatherSensor::clearSlots
void clearSlots(uint8_t type=0xFF)
Clear sensor data.
Definition: WeatherSensor.h:269
+
WeatherSensor::decodeMessage
DecodeStatus decodeMessage(const uint8_t *msg, uint8_t msgSize)
Decode message Tries the available decoders until a decoding was successful.
Definition: WeatherSensor.cpp:255
+
SensorMap
Mapping of sensor IDs to names.
Definition: WeatherSensor.h:131
+
SensorMap::name
std::string name
Name of sensor (e.g. for MQTT topic)
Definition: WeatherSensor.h:133
+
SensorMap::id
uint32_t id
ID if sensor (as transmitted in radio message)
Definition: WeatherSensor.h:132
+
WeatherSensor::Sensor
sensor data and status flags
Definition: WeatherSensor.h:203
+
WeatherSensor::Sensor::lightning_unknown1
uint16_t lightning_unknown1
unknown part 1
Definition: WeatherSensor.h:242
+
WeatherSensor::Sensor::battery_ok
bool battery_ok
battery o.k.
Definition: WeatherSensor.h:216
+
WeatherSensor::Sensor::temp_ok
bool temp_ok
temperature o.k. (only 6-in-1)
Definition: WeatherSensor.h:210
+
WeatherSensor::Sensor::lightning_ok
bool lightning_ok
lightning o.k. (only lightning)
Definition: WeatherSensor.h:218
+
WeatherSensor::Sensor::humidity
uint8_t humidity
humidity in %
Definition: WeatherSensor.h:238
+
WeatherSensor::Sensor::water_leakage_alarm
bool water_leakage_alarm
water leakage alarm (only water leakage)
Definition: WeatherSensor.h:244
+
WeatherSensor::Sensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:245
+
WeatherSensor::Sensor::humidity_ok
bool humidity_ok
humidity o.k.
Definition: WeatherSensor.h:211
+
WeatherSensor::Sensor::lightning_count
uint8_t lightning_count
lightning strike counter (only lightning)
Definition: WeatherSensor.h:241
+
WeatherSensor::Sensor::lightning_distance_km
uint8_t lightning_distance_km
lightning distance in km (only lightning)
Definition: WeatherSensor.h:240
+
WeatherSensor::Sensor::moisture
uint8_t moisture
moisture in % (only 6-in-1)
Definition: WeatherSensor.h:239
+
WeatherSensor::Sensor::complete
bool complete
data is split into two separate messages is complete (only 6-in-1 WS)
Definition: WeatherSensor.h:209
+
WeatherSensor::Sensor::light_ok
bool light_ok
light o.k. (only 7-in-1)
Definition: WeatherSensor.h:212
+
WeatherSensor::Sensor::s_type
uint8_t s_type
sensor type (only 6-in-1)
Definition: WeatherSensor.h:205
+
WeatherSensor::Sensor::light_lux
float light_lux
Light lux (only 7-in-1)
Definition: WeatherSensor.h:222
+
WeatherSensor::Sensor::startup
bool startup
startup after reset / battery change
Definition: WeatherSensor.h:207
+
WeatherSensor::Sensor::lightning_unknown2
uint16_t lightning_unknown2
unknown part 2
Definition: WeatherSensor.h:243
+
WeatherSensor::Sensor::leakage_ok
bool leakage_ok
water leakage o.k. (only water leackage)
Definition: WeatherSensor.h:219
+
WeatherSensor::Sensor::sensor_id
uint32_t sensor_id
sensor ID (5-in-1: 1 byte / 6-in-1: 4 bytes / 7-in-1: 2 bytes)
Definition: WeatherSensor.h:204
+
WeatherSensor::Sensor::chan
uint8_t chan
channel (only 6-in-1)
Definition: WeatherSensor.h:206
+
WeatherSensor::Sensor::uv_ok
bool uv_ok
uv radiation o.k. (only 6-in-1)
Definition: WeatherSensor.h:213
+
WeatherSensor::Sensor::moisture_ok
bool moisture_ok
moisture o.k. (only 6-in-1)
Definition: WeatherSensor.h:217
+
WeatherSensor::Sensor::temp_c
float temp_c
temperature in degC
Definition: WeatherSensor.h:220
+
WeatherSensor::Sensor::valid
bool valid
data valid (but not necessarily complete)
Definition: WeatherSensor.h:208
+
WeatherSensor::Sensor::rain_ok
bool rain_ok
rain gauge level o.k.
Definition: WeatherSensor.h:215
+
WeatherSensor::Sensor::light_klx
float light_klx
Light KLux (only 7-in-1)
Definition: WeatherSensor.h:221
+
WeatherSensor::Sensor::rain_mm
float rain_mm
rain gauge level in mm
Definition: WeatherSensor.h:224
+
WeatherSensor::Sensor::uv
float uv
uv radiation (only 6-in-1)
Definition: WeatherSensor.h:223
+
WeatherSensor::Sensor::wind_ok
bool wind_ok
wind speed/direction o.k. (only 6-in-1)
Definition: WeatherSensor.h:214