diff --git a/_weather_sensor_8h_source.html b/_weather_sensor_8h_source.html index 673c5220..adcb8498 100644 --- a/_weather_sensor_8h_source.html +++ b/_weather_sensor_8h_source.html @@ -150,286 +150,316 @@
63 // 20231006 Added crc16() from https://github.com/merbanan/rtl_433/blob/master/src/util.c
64 // 20231024 Added SENSOR_TYPE_POOL_THERMO
65 // 20231025 Added Bresser Air Quality (Particulate Matter) Sensor, P/N 7009970
-
66 // Modified device type definitions
-
67 //
-
68 // ToDo:
-
69 // -
-
70 //
-
72 
-
73 #ifndef WeatherSensor_h
-
74 #define WeatherSensor_h
-
75 
-
76 #include <Arduino.h>
-
77 #include <RadioLib.h>
-
78 
+
66 // Modified device type definitions
+
67 // 20231030 Refactored sensor data using a union to save memory
+
68 //
+
69 // ToDo:
+
70 // -
+
71 //
+
73 
+
74 #ifndef WeatherSensor_h
+
75 #define WeatherSensor_h
+
76 
+
77 #include <Arduino.h>
+
78 #include <RadioLib.h>
79 
-
80 // Sensor Types
-
81 // 0 - Weather Station 5-in-1; PN 7002510..12/7902510..12
-
82 // 1 - Weather Station 6-in-1; PN 7002585
-
83 // - Professional Wind Gauge 6-in-1; PN 7002531
-
84 // - Weather Station 7-in-1; PN 7003300
-
85 // 2 - Thermo-/Hygro-Sensor 6-in-1; PN 7009999
-
86 // 3 - Pool / Spa Thermometer PN 7000073
-
87 // 4 - Soil Moisture Sensor 6-in-1; PN 7009972
-
88 // 5 - Water Leakage Sensor 6-in-1; PN 7009975
-
89 // 8 - Air Quality Sensor PM2.5/PM10
-
90 // 9 - Professional Rain Gauge (5-in-1 decoder)
-
91 // 9 - Lightning Sensor PN 7009976
-
92 // ? - CO2 Sensor
-
93 // ? - HCHO/VCO Sensor
-
94 #define SENSOR_TYPE_WEATHER0 0 // Weather Station
-
95 #define SENSOR_TYPE_WEATHER1 1 // Weather Station
-
96 #define SENSOR_TYPE_THERMO_HYGRO 2 // Thermo-/Hygro-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_AIR_PM 8 // Air Quality Sensor (Particle Matter)
-
101 #define SENSOR_TYPE_RAIN 9 // Professional Rain Gauge (from 5-in-1 decoder)
-
102 #define SENSOR_TYPE_LIGHTNING 9 // Lightning Sensor
-
103 
+
80 
+
81 // Sensor Types
+
82 // 0 - Weather Station 5-in-1; PN 7002510..12/7902510..12
+
83 // 1 - Weather Station 6-in-1; PN 7002585
+
84 // - Professional Wind Gauge 6-in-1; PN 7002531
+
85 // - Weather Station 7-in-1; PN 7003300
+
86 // 2 - Thermo-/Hygro-Sensor 6-in-1; PN 7009999
+
87 // 3 - Pool / Spa Thermometer PN 7000073
+
88 // 4 - Soil Moisture Sensor 6-in-1; PN 7009972
+
89 // 5 - Water Leakage Sensor 6-in-1; PN 7009975
+
90 // 8 - Air Quality Sensor PM2.5/PM10
+
91 // 9 - Professional Rain Gauge (5-in-1 decoder)
+
92 // 9 - Lightning Sensor PN 7009976
+
93 // ? - CO2 Sensor
+
94 // ? - HCHO/VCO Sensor
+
95 #define SENSOR_TYPE_WEATHER0 0 // Weather Station
+
96 #define SENSOR_TYPE_WEATHER1 1 // Weather Station
+
97 #define SENSOR_TYPE_THERMO_HYGRO 2 // Thermo-/Hygro-Sensor
+
98 #define SENSOR_TYPE_POOL_THERMO 3 // Pool / Spa Thermometer
+
99 #define SENSOR_TYPE_SOIL 4 // Soil Temperature and Moisture (from 6-in-1 decoder)
+
100 #define SENSOR_TYPE_LEAKAGE 5 // Water Leakage
+
101 #define SENSOR_TYPE_AIR_PM 8 // Air Quality Sensor (Particle Matter)
+
102 #define SENSOR_TYPE_RAIN 9 // Professional Rain Gauge (from 5-in-1 decoder)
+
103 #define SENSOR_TYPE_LIGHTNING 9 // Lightning Sensor
104 
-
105 // Sensor specific rain gauge overflow threshold (mm)
-
106 #define WEATHER0_RAIN_OV 1000
-
107 #define WEATHER1_RAIN_OV 100000
-
108 
+
105 
+
106 // Sensor specific rain gauge overflow threshold (mm)
+
107 #define WEATHER0_RAIN_OV 1000
+
108 #define WEATHER1_RAIN_OV 100000
109 
-
110 // Flags for controlling completion of reception in getData()
-
111 #define DATA_COMPLETE 0x1 // only completed slots (as opposed to partially filled)
-
112 #define DATA_TYPE 0x2 // at least one slot with specific sensor type
-
113 #define DATA_ALL_SLOTS 0x8 // all slots completed
-
114 
-
115 // Message buffer size
-
116 #define MSG_BUF_SIZE 27
-
117 
-
118 // Radio message decoding status
-
119 typedef enum DecodeStatus {
-
120  DECODE_INVALID, DECODE_OK, DECODE_PAR_ERR, DECODE_CHK_ERR, DECODE_DIG_ERR, DECODE_SKIP, DECODE_FULL
-
121 } DecodeStatus;
-
122 
+
110 
+
111 // Flags for controlling completion of reception in getData()
+
112 #define DATA_COMPLETE 0x1 // only completed slots (as opposed to partially filled)
+
113 #define DATA_TYPE 0x2 // at least one slot with specific sensor type
+
114 #define DATA_ALL_SLOTS 0x8 // all slots completed
+
115 
+
116 // Message buffer size
+
117 #define MSG_BUF_SIZE 27
+
118 
+
119 // Radio message decoding status
+
120 typedef enum DecodeStatus {
+
121  DECODE_INVALID, DECODE_OK, DECODE_PAR_ERR, DECODE_CHK_ERR, DECODE_DIG_ERR, DECODE_SKIP, DECODE_FULL
+
122 } DecodeStatus;
123 
-
124 #if !defined(ARDUINO_ARCH_AVR)
-
125 #include <string>
-
126 
-
132 typedef struct SensorMap {
-
133  uint32_t id;
-
134  std::string name;
-
135 } SensorMap;
-
136 #endif
-
137 
+
124 
+
125 #if !defined(ARDUINO_ARCH_AVR)
+
126 #include <string>
+
127 
+
133 typedef struct SensorMap {
+
134  uint32_t id;
+
135  std::string name;
+
136 } SensorMap;
+
137 #endif
138 
-
145 class WeatherSensor {
-
146  public:
-
151  WeatherSensor()
-
152  {
-
153  };
-
154 
-
155 
-
161  int16_t begin(void);
-
162 
-
163 
-
180  bool getData(uint32_t timeout, uint8_t flags = 0, uint8_t type = 0, void (*func)() = NULL);
-
181 
-
182 
-
189  DecodeStatus getMessage(void);
-
190 
-
197  DecodeStatus decodeMessage(const uint8_t *msg, uint8_t msgSize);
-
198 
-
204  struct Sensor {
-
205  uint32_t sensor_id;
-
206  uint8_t s_type;
-
207  uint8_t chan;
-
208  bool startup = false;
-
209  bool valid;
-
210  bool complete;
-
211  bool temp_ok = false;
-
212  bool humidity_ok = false;
-
213  bool light_ok = false;
-
214  bool uv_ok = false;
-
215  bool wind_ok = false;
-
216  bool rain_ok = false;
-
217  bool battery_ok = false;
-
218  bool moisture_ok = false;
-
219  bool lightning_ok = false;
-
220  bool leakage_ok = false;
-
221  bool pm_ok = false;
-
222  float temp_c;
-
223  float light_klx;
-
224  float light_lux;
-
225  float uv;
-
226  float rain_mm;
-
227  #ifdef WIND_DATA_FLOATINGPOINT
-
228  float wind_direction_deg;
-
229  float wind_gust_meter_sec;
-
230  float wind_avg_meter_sec;
-
231  #endif
-
232  #ifdef WIND_DATA_FIXEDPOINT
-
233  // For LoRa_Serialization:
-
234  // fixed point integer with 1 decimal -
-
235  // saves two bytes compared to "RawFloat"
-
236  uint16_t wind_direction_deg_fp1;
-
237  uint16_t wind_gust_meter_sec_fp1;
-
238  uint16_t wind_avg_meter_sec_fp1;
-
239  #endif
-
240  uint8_t humidity;
-
241  uint8_t moisture;
-
242  uint8_t lightning_distance_km;
-
243  uint8_t lightning_count;
-
244  uint16_t lightning_unknown1;
-
245  uint16_t lightning_unknown2;
-
246  bool water_leakage_alarm;
-
247  uint16_t aqs_pm_2_5;
-
248  uint16_t aqs_pm_10;
-
249  float rssi;
-
250  };
-
251 
-
252  typedef struct Sensor sensor_t;
-
253  sensor_t sensor[NUM_SENSORS];
-
254  float rssi;
+
139 
+
146 class WeatherSensor {
+
147  public:
+
152  /*
+
153  WeatherSensor()
+
154  {
+
155  memset(this, 0, sizeof(*this));
+
156  };
+
157  */
+
163  int16_t begin(void);
+
164 
+
165 
+
182  bool getData(uint32_t timeout, uint8_t flags = 0, uint8_t type = 0, void (*func)() = NULL);
+
183 
+
184 
+
191  DecodeStatus getMessage(void);
+
192 
+
199  DecodeStatus decodeMessage(const uint8_t *msg, uint8_t msgSize);
+
200 
+
201  struct Weather {
+
202  bool temp_ok = false;
+
203  bool humidity_ok = false;
+
204  bool light_ok = false;
+
205  bool uv_ok = false;
+
206  bool wind_ok = false;
+
207  bool rain_ok = false;
+
208  float temp_c;
+
209  float light_klx;
+
210  float light_lux;
+
211  float uv;
+
212  float rain_mm;
+
213  #ifdef WIND_DATA_FLOATINGPOINT
+
214  float wind_direction_deg;
+
215  float wind_gust_meter_sec;
+
216  float wind_avg_meter_sec;
+
217  #endif
+
218  #ifdef WIND_DATA_FIXEDPOINT
+
219  // For LoRa_Serialization:
+
220  // fixed point integer with 1 decimal -
+
221  // saves two bytes compared to "RawFloat"
+
222  uint16_t wind_direction_deg_fp1;
+
223  uint16_t wind_gust_meter_sec_fp1;
+
224  uint16_t wind_avg_meter_sec_fp1;
+
225  #endif
+
226  uint8_t humidity;
+
227 
+
228  Weather() {
+
229  memset(this, 0, sizeof(*this));
+
230  };
+
231 
+
232  };
+
233 
+
234  struct Soil {
+
235  // TODO needed?
+
236  //bool temp_ok = false; //!< temperature o.k. (only 6-in-1)
+
237  //bool moisture_ok = false; //!< moisture o.k. (only 6-in-1)
+
238  float temp_c;
+
239  uint8_t moisture;
+
240  };
+
241 
+
242  struct Lightning {
+
243  //bool lightning_ok = false; //!< lightning o.k. (only lightning)
+
244  uint8_t distance_km;
+
245  uint8_t strike_count;
+
246  uint16_t unknown1;
+
247  uint16_t unknown2;
+
248 
+
249  };
+
250 
+
251  struct Leakage {
+
252  //bool leakage_ok = false; //!< water leakage o.k. (only water leackage)
+
253  bool alarm;
+
254  };
255 
-
256 
-
262  bool genMessage(int i, uint32_t id = 0xff, uint8_t type = 1, uint8_t channel = 0);
-
263 
-
264 
-
273  void clearSlots(uint8_t type = 0xFF)
-
274  {
-
275  for (int i=0; i< NUM_SENSORS; i++) {
-
276  if ((type == 0xFF) || (sensor[i].s_type == type)) {
-
277  sensor[i].valid = false;
-
278  sensor[i].complete = false;
-
279  sensor[i].temp_ok = false;
-
280  sensor[i].humidity_ok = false;
-
281  sensor[i].light_ok = false;
-
282  sensor[i].uv_ok = false;
-
283  sensor[i].wind_ok = false;
-
284  sensor[i].rain_ok = false;
-
285  sensor[i].moisture_ok = false;
-
286  sensor[i].lightning_ok = false;
-
287  sensor[i].leakage_ok = false;
-
288  sensor[i].pm_ok = false;
-
289  }
-
290  }
-
291  };
-
292 
-
300  int findId(uint32_t id);
+
256  struct AirPM {
+
257  //bool pm_ok = false; //!< air quality (particle matter) o.k. (only 7-in-1)
+
258  uint16_t pm_2_5;
+
259  uint16_t pm_10;
+
260  };
+
261 
+
267  struct Sensor {
+
268  uint32_t sensor_id;
+
269  float rssi;
+
270  uint8_t s_type;
+
271  uint8_t chan;
+
272  bool startup = false;
+
273  bool battery_ok = false;
+
274  bool valid;
+
275  bool complete;
+
276  union {
+
277  struct Weather w;
+
278  struct Soil soil;
+
279  struct Lightning lgt;
+
280  struct Leakage leak;
+
281  struct AirPM pm;
+
282  };
+
283 
+
284  Sensor ()
+
285  {
+
286  memset(this, 0, sizeof(*this));
+
287  }
+
288  };
+
289 
+
290  typedef struct Sensor sensor_t;
+
291  sensor_t sensor[NUM_SENSORS];
+
292  float rssi;
+
293 
+
294 
+
300  bool genMessage(int i, uint32_t id = 0xff, uint8_t s_type = 1, uint8_t channel = 0, uint8_t startup = 0);
301 
302 
-
311  int findType(uint8_t type, uint8_t channel = 0xFF);
-
312 
-
321  bool is_decode3in1(uint32_t id);
-
322 
-
323  private:
-
324  struct Sensor *pData;
-
325 
-
343  int findSlot(uint32_t id, DecodeStatus * status);
-
344 
-
345 
-
346  #ifdef BRESSER_5_IN_1
-
356  DecodeStatus decodeBresser5In1Payload(const uint8_t *msg, uint8_t msgSize);
-
357  #endif
-
358  #ifdef BRESSER_6_IN_1
-
370  DecodeStatus decodeBresser6In1Payload(const uint8_t *msg, uint8_t msgSize);
-
371  #endif
-
372  #ifdef BRESSER_7_IN_1
-
382  DecodeStatus decodeBresser7In1Payload(const uint8_t *msg, uint8_t msgSize);
-
383  #endif
-
384  #ifdef BRESSER_LIGHTNING
-
394  DecodeStatus decodeBresserLightningPayload(const uint8_t *msg, uint8_t msgSize);
-
395  #endif
-
396  #ifdef BRESSER_LEAKAGE
-
406  DecodeStatus decodeBresserLeakagePayload(const uint8_t *msg, uint8_t msgSize);
-
407  #endif
-
408 
-
409  protected:
-
413  uint16_t lfsr_digest16(uint8_t const message[], unsigned bytes, uint16_t gen, uint16_t key);
-
414 
-
423  int add_bytes(uint8_t const message[], unsigned num_bytes);
-
424 
-
435  uint16_t crc16(uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init);
+
311  void clearSlots(uint8_t type = 0xFF)
+
312  {
+
313  for (int i=0; i< NUM_SENSORS; i++) {
+
314  if ((type == 0xFF) || (sensor[i].s_type == type)) {
+
315  sensor[i].valid = false;
+
316  sensor[i].complete = false;
+
317  }
+
318  }
+
319  };
+
320 
+
328  int findId(uint32_t id);
+
329 
+
330 
+
339  int findType(uint8_t type, uint8_t channel = 0xFF);
+
340 
+
349  bool is_decode3in1(uint32_t id);
+
350 
+
351  private:
+
352  struct Sensor *pData;
+
353 
+
371  int findSlot(uint32_t id, DecodeStatus * status);
+
372 
+
373 
+
374  #ifdef BRESSER_5_IN_1
+
384  DecodeStatus decodeBresser5In1Payload(const uint8_t *msg, uint8_t msgSize);
+
385  #endif
+
386  #ifdef BRESSER_6_IN_1
+
398  DecodeStatus decodeBresser6In1Payload(const uint8_t *msg, uint8_t msgSize);
+
399  #endif
+
400  #ifdef BRESSER_7_IN_1
+
410  DecodeStatus decodeBresser7In1Payload(const uint8_t *msg, uint8_t msgSize);
+
411  #endif
+
412  #ifdef BRESSER_LIGHTNING
+
422  DecodeStatus decodeBresserLightningPayload(const uint8_t *msg, uint8_t msgSize);
+
423  #endif
+
424  #ifdef BRESSER_LEAKAGE
+
434  DecodeStatus decodeBresserLeakagePayload(const uint8_t *msg, uint8_t msgSize);
+
435  #endif
436 
-
437  #if CORE_DEBUG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
-
449  void log_message(const char *descr, const uint8_t *msg, uint8_t msgSize) {
-
450  char buf[128];
-
451  const char txt[] = "Byte #: ";
-
452  int offs;
-
453  int len1 = strlen(txt);
-
454  int len2 = strlen(descr) + 2; // add colon and space
-
455  int prefix_len = max(len1, len2);
-
456 
-
457  memset(buf, ' ', prefix_len);
-
458  buf[prefix_len] = '\0';
-
459  offs = (len1 < len2) ? (len2 - len1) : 0;
-
460  strcpy(&buf[offs], txt);
-
461 
-
462  // Print byte index
-
463  for (size_t i = 0 ; i < msgSize; i++) {
-
464  sprintf(&buf[strlen(buf)], "%02d ", i);
-
465  }
-
466  log_d("%s", buf);
-
467 
-
468  memset(buf, ' ', prefix_len);
-
469  buf[prefix_len] ='\0';
-
470  offs = (len1 > len2) ? (len1 - len2) : 0;
-
471  sprintf(&buf[offs], "%s: ", descr);
-
472 
-
473  for (size_t i = 0 ; i < msgSize; i++) {
-
474  sprintf(&buf[strlen(buf)], "%02X ", msg[i]);
-
475  }
-
476  log_d("%s", buf);
-
477  }
-
478  #endif
-
479 
-
480 };
-
481 
-
482 #endif
-
WeatherSensor
Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receivin...
Definition: WeatherSensor.h:145
-
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:216
-
WeatherSensor::findId
int findId(uint32_t id)
Definition: WeatherSensor.cpp:408
-
WeatherSensor::is_decode3in1
bool is_decode3in1(uint32_t id)
Definition: WeatherSensor.cpp:434
-
WeatherSensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:254
-
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:159
-
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:302
-
WeatherSensor::begin
int16_t begin(void)
Presence check and initialization of radio module.
Definition: WeatherSensor.cpp:101
-
WeatherSensor::WeatherSensor
WeatherSensor()
Constructor.
Definition: WeatherSensor.h:151
-
WeatherSensor::findType
int findType(uint8_t type, uint8_t channel=0xFF)
Definition: WeatherSensor.cpp:421
-
WeatherSensor::sensor
sensor_t sensor[NUM_SENSORS]
sensor data array
Definition: WeatherSensor.h:253
-
WeatherSensor::clearSlots
void clearSlots(uint8_t type=0xFF)
Clear sensor data.
Definition: WeatherSensor.h:273
-
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:258
-
SensorMap
Mapping of sensor IDs to names.
Definition: WeatherSensor.h:132
-
SensorMap::name
std::string name
Name of sensor (e.g. for MQTT topic)
Definition: WeatherSensor.h:134
-
SensorMap::id
uint32_t id
ID if sensor (as transmitted in radio message)
Definition: WeatherSensor.h:133
-
WeatherSensor::Sensor
sensor data and status flags
Definition: WeatherSensor.h:204
-
WeatherSensor::Sensor::lightning_unknown1
uint16_t lightning_unknown1
unknown part 1
Definition: WeatherSensor.h:244
-
WeatherSensor::Sensor::battery_ok
bool battery_ok
battery o.k.
Definition: WeatherSensor.h:217
-
WeatherSensor::Sensor::temp_ok
bool temp_ok
temperature o.k. (only 6-in-1)
Definition: WeatherSensor.h:211
-
WeatherSensor::Sensor::lightning_ok
bool lightning_ok
lightning o.k. (only lightning)
Definition: WeatherSensor.h:219
-
WeatherSensor::Sensor::aqs_pm_2_5
uint16_t aqs_pm_2_5
air quality PM2.5 in µg/m³
Definition: WeatherSensor.h:247
-
WeatherSensor::Sensor::humidity
uint8_t humidity
humidity in %
Definition: WeatherSensor.h:240
-
WeatherSensor::Sensor::water_leakage_alarm
bool water_leakage_alarm
water leakage alarm (only water leakage)
Definition: WeatherSensor.h:246
-
WeatherSensor::Sensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:249
-
WeatherSensor::Sensor::humidity_ok
bool humidity_ok
humidity o.k.
Definition: WeatherSensor.h:212
-
WeatherSensor::Sensor::lightning_count
uint8_t lightning_count
lightning strike counter (only lightning)
Definition: WeatherSensor.h:243
-
WeatherSensor::Sensor::lightning_distance_km
uint8_t lightning_distance_km
lightning distance in km (only lightning)
Definition: WeatherSensor.h:242
-
WeatherSensor::Sensor::moisture
uint8_t moisture
moisture in % (only 6-in-1)
Definition: WeatherSensor.h:241
-
WeatherSensor::Sensor::pm_ok
bool pm_ok
air quality (particle matter) o.k. (only 7-in-1)
Definition: WeatherSensor.h:221
-
WeatherSensor::Sensor::complete
bool complete
data is split into two separate messages is complete (only 6-in-1 WS)
Definition: WeatherSensor.h:210
-
WeatherSensor::Sensor::light_ok
bool light_ok
light o.k. (only 7-in-1)
Definition: WeatherSensor.h:213
-
WeatherSensor::Sensor::aqs_pm_10
uint16_t aqs_pm_10
air quality PM10 in µg/m³
Definition: WeatherSensor.h:248
-
WeatherSensor::Sensor::s_type
uint8_t s_type
sensor type
Definition: WeatherSensor.h:206
-
WeatherSensor::Sensor::light_lux
float light_lux
Light lux (only 7-in-1)
Definition: WeatherSensor.h:224
-
WeatherSensor::Sensor::startup
bool startup
startup after reset / battery change
Definition: WeatherSensor.h:208
-
WeatherSensor::Sensor::lightning_unknown2
uint16_t lightning_unknown2
unknown part 2
Definition: WeatherSensor.h:245
-
WeatherSensor::Sensor::leakage_ok
bool leakage_ok
water leakage o.k. (only water leackage)
Definition: WeatherSensor.h:220
-
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:205
-
WeatherSensor::Sensor::chan
uint8_t chan
channel
Definition: WeatherSensor.h:207
-
WeatherSensor::Sensor::uv_ok
bool uv_ok
uv radiation o.k. (only 6-in-1)
Definition: WeatherSensor.h:214
-
WeatherSensor::Sensor::moisture_ok
bool moisture_ok
moisture o.k. (only 6-in-1)
Definition: WeatherSensor.h:218
-
WeatherSensor::Sensor::temp_c
float temp_c
temperature in degC
Definition: WeatherSensor.h:222
-
WeatherSensor::Sensor::valid
bool valid
data valid (but not necessarily complete)
Definition: WeatherSensor.h:209
-
WeatherSensor::Sensor::rain_ok
bool rain_ok
rain gauge level o.k.
Definition: WeatherSensor.h:216
-
WeatherSensor::Sensor::light_klx
float light_klx
Light KLux (only 7-in-1)
Definition: WeatherSensor.h:223
-
WeatherSensor::Sensor::rain_mm
float rain_mm
rain gauge level in mm
Definition: WeatherSensor.h:226
-
WeatherSensor::Sensor::uv
float uv
uv radiation (only 6-in-1)
Definition: WeatherSensor.h:225
-
WeatherSensor::Sensor::wind_ok
bool wind_ok
wind speed/direction o.k. (only 6-in-1)
Definition: WeatherSensor.h:215
+
437  protected:
+
441  uint16_t lfsr_digest16(uint8_t const message[], unsigned bytes, uint16_t gen, uint16_t key);
+
442 
+
451  int add_bytes(uint8_t const message[], unsigned num_bytes);
+
452 
+
463  uint16_t crc16(uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init);
+
464 
+
465  #if CORE_DEBUG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
+
477  void log_message(const char *descr, const uint8_t *msg, uint8_t msgSize) {
+
478  char buf[128];
+
479  const char txt[] = "Byte #: ";
+
480  int offs;
+
481  int len1 = strlen(txt);
+
482  int len2 = strlen(descr) + 2; // add colon and space
+
483  int prefix_len = max(len1, len2);
+
484 
+
485  memset(buf, ' ', prefix_len);
+
486  buf[prefix_len] = '\0';
+
487  offs = (len1 < len2) ? (len2 - len1) : 0;
+
488  strcpy(&buf[offs], txt);
+
489 
+
490  // Print byte index
+
491  for (size_t i = 0 ; i < msgSize; i++) {
+
492  sprintf(&buf[strlen(buf)], "%02d ", i);
+
493  }
+
494  log_d("%s", buf);
+
495 
+
496  memset(buf, ' ', prefix_len);
+
497  buf[prefix_len] ='\0';
+
498  offs = (len1 > len2) ? (len1 - len2) : 0;
+
499  sprintf(&buf[offs], "%s: ", descr);
+
500 
+
501  for (size_t i = 0 ; i < msgSize; i++) {
+
502  sprintf(&buf[strlen(buf)], "%02X ", msg[i]);
+
503  }
+
504  log_d("%s", buf);
+
505  }
+
506  #endif
+
507 
+
508 };
+
509 
+
510 #endif
+
WeatherSensor
Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receivin...
Definition: WeatherSensor.h:146
+
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:217
+
WeatherSensor::findId
int findId(uint32_t id)
Definition: WeatherSensor.cpp:431
+
WeatherSensor::is_decode3in1
bool is_decode3in1(uint32_t id)
Definition: WeatherSensor.cpp:457
+
WeatherSensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:292
+
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:160
+
WeatherSensor::begin
int16_t begin(void)
Constructor.
Definition: WeatherSensor.cpp:102
+
WeatherSensor::findType
int findType(uint8_t type, uint8_t channel=0xFF)
Definition: WeatherSensor.cpp:444
+
WeatherSensor::sensor
sensor_t sensor[NUM_SENSORS]
sensor data array
Definition: WeatherSensor.h:291
+
WeatherSensor::genMessage
bool genMessage(int i, uint32_t id=0xff, uint8_t s_type=1, uint8_t channel=0, uint8_t startup=0)
Generates data otherwise received and decoded from a radio message.
Definition: WeatherSensor.cpp:303
+
WeatherSensor::sensor_t
struct Sensor sensor_t
Shortcut for struct Sensor.
Definition: WeatherSensor.h:290
+
WeatherSensor::clearSlots
void clearSlots(uint8_t type=0xFF)
Clear sensor data.
Definition: WeatherSensor.h:311
+
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:259
+
SensorMap
Mapping of sensor IDs to names.
Definition: WeatherSensor.h:133
+
SensorMap::name
std::string name
Name of sensor (e.g. for MQTT topic)
Definition: WeatherSensor.h:135
+
SensorMap::id
uint32_t id
ID if sensor (as transmitted in radio message)
Definition: WeatherSensor.h:134
+
WeatherSensor::AirPM
Definition: WeatherSensor.h:256
+
WeatherSensor::AirPM::pm_2_5
uint16_t pm_2_5
air quality PM2.5 in µg/m³
Definition: WeatherSensor.h:258
+
WeatherSensor::AirPM::pm_10
uint16_t pm_10
air quality PM10 in µg/m³
Definition: WeatherSensor.h:259
+
WeatherSensor::Leakage
Definition: WeatherSensor.h:251
+
WeatherSensor::Leakage::alarm
bool alarm
water leakage alarm (only water leakage)
Definition: WeatherSensor.h:253
+
WeatherSensor::Lightning
Definition: WeatherSensor.h:242
+
WeatherSensor::Lightning::unknown1
uint16_t unknown1
unknown part 1
Definition: WeatherSensor.h:246
+
WeatherSensor::Lightning::strike_count
uint8_t strike_count
lightning strike counter (only lightning)
Definition: WeatherSensor.h:245
+
WeatherSensor::Lightning::distance_km
uint8_t distance_km
lightning distance in km (only lightning)
Definition: WeatherSensor.h:244
+
WeatherSensor::Lightning::unknown2
uint16_t unknown2
unknown part 2
Definition: WeatherSensor.h:247
+
WeatherSensor::Sensor
sensor data and status flags
Definition: WeatherSensor.h:267
+
WeatherSensor::Sensor::battery_ok
bool battery_ok
battery o.k.
Definition: WeatherSensor.h:273
+
WeatherSensor::Sensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:269
+
WeatherSensor::Sensor::complete
bool complete
data is split into two separate messages is complete (only 6-in-1 WS)
Definition: WeatherSensor.h:275
+
WeatherSensor::Sensor::s_type
uint8_t s_type
sensor type
Definition: WeatherSensor.h:270
+
WeatherSensor::Sensor::startup
bool startup
startup after reset / battery change
Definition: WeatherSensor.h:272
+
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:268
+
WeatherSensor::Sensor::chan
uint8_t chan
channel
Definition: WeatherSensor.h:271
+
WeatherSensor::Sensor::valid
bool valid
data valid (but not necessarily complete)
Definition: WeatherSensor.h:274
+
WeatherSensor::Soil
Definition: WeatherSensor.h:234
+
WeatherSensor::Soil::temp_c
float temp_c
temperature in degC
Definition: WeatherSensor.h:238
+
WeatherSensor::Soil::moisture
uint8_t moisture
moisture in % (only 6-in-1)
Definition: WeatherSensor.h:239
+
WeatherSensor::Weather
Definition: WeatherSensor.h:201
+
WeatherSensor::Weather::light_klx
float light_klx
Light KLux (only 7-in-1)
Definition: WeatherSensor.h:209
+
WeatherSensor::Weather::light_ok
bool light_ok
light o.k. (only 7-in-1)
Definition: WeatherSensor.h:204
+
WeatherSensor::Weather::light_lux
float light_lux
Light lux (only 7-in-1)
Definition: WeatherSensor.h:210
+
WeatherSensor::Weather::temp_ok
bool temp_ok
temperature o.k. (only 6-in-1)
Definition: WeatherSensor.h:202
+
WeatherSensor::Weather::temp_c
float temp_c
temperature in degC
Definition: WeatherSensor.h:208
+
WeatherSensor::Weather::humidity
uint8_t humidity
humidity in %
Definition: WeatherSensor.h:226
+
WeatherSensor::Weather::uv
float uv
uv radiation (only 6-in-1)
Definition: WeatherSensor.h:211
+
WeatherSensor::Weather::humidity_ok
bool humidity_ok
humidity o.k.
Definition: WeatherSensor.h:203
+
WeatherSensor::Weather::wind_ok
bool wind_ok
wind speed/direction o.k. (only 6-in-1)
Definition: WeatherSensor.h:206
+
WeatherSensor::Weather::uv_ok
bool uv_ok
uv radiation o.k. (only 6-in-1)
Definition: WeatherSensor.h:205
+
WeatherSensor::Weather::rain_mm
float rain_mm
rain gauge level in mm
Definition: WeatherSensor.h:212
+
WeatherSensor::Weather::rain_ok
bool rain_ok
rain gauge level o.k.
Definition: WeatherSensor.h:207
diff --git a/annotated.html b/annotated.html index 1a74e703..a9368f3e 100644 --- a/annotated.html +++ b/annotated.html @@ -93,8 +93,13 @@  CnvLightning_t  CRainGaugeCalculation of hourly (past 60 minutes), daily, weekly and monthly rainfall  CSensorMapMapping of sensor IDs to names - CWeatherSensorReceive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receiving FSK modulated signal at 868 MHz - CSensorSensor data and status flags + CWeatherSensorReceive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receiving FSK modulated signal at 868 MHz + CAirPM + CLeakage + CLightning + CSensorSensor data and status flags + CSoil + CWeather diff --git a/class_weather_sensor-members.html b/class_weather_sensor-members.html index 1bcc24a3..d690d178 100644 --- a/class_weather_sensor-members.html +++ b/class_weather_sensor-members.html @@ -94,14 +94,13 @@ decodeMessage(const uint8_t *msg, uint8_t msgSize)WeatherSensor findId(uint32_t id)WeatherSensor findType(uint8_t type, uint8_t channel=0xFF)WeatherSensor - genMessage(int i, uint32_t id=0xff, uint8_t type=1, uint8_t channel=0)WeatherSensor + genMessage(int i, uint32_t id=0xff, uint8_t s_type=1, uint8_t channel=0, uint8_t startup=0)WeatherSensor getData(uint32_t timeout, uint8_t flags=0, uint8_t type=0, void(*func)()=NULL)WeatherSensor getMessage(void)WeatherSensor is_decode3in1(uint32_t id)WeatherSensor rssiWeatherSensor sensorWeatherSensor sensor_t typedefWeatherSensor - WeatherSensor()WeatherSensorinline diff --git a/class_weather_sensor.html b/class_weather_sensor.html index eef6d98a..10a9f594 100644 --- a/class_weather_sensor.html +++ b/class_weather_sensor.html @@ -93,16 +93,26 @@
-

Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receiving FSK modulated signal at 868 MHz. +

Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receiving FSK modulated signal at 868 MHz. More...

#include <WeatherSensor.h>

+ + + + + + + + + +

Classes

struct  AirPM
 
struct  Leakage
 
struct  Lightning
 
struct  Sensor
 sensor data and status flags More...
 
struct  Soil
 
struct  Weather
 
@@ -113,12 +123,8 @@

Public Types

- - - - + @@ -129,9 +135,9 @@ - - - + + + @@ -154,7 +160,7 @@

Public Member Functions

WeatherSensor ()
 Constructor.
 
int16_t begin (void)
 Presence check and initialization of radio module. More...
 Constructor. More...
 
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 two different messages. Reception of entire data is tried if 'complete' is set. More...
DecodeStatus decodeMessage (const uint8_t *msg, uint8_t msgSize)
 Decode message Tries the available decoders until a decoding was successful. More...
 
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. More...
 
bool genMessage (int i, uint32_t id=0xff, uint8_t s_type=1, uint8_t channel=0, uint8_t startup=0)
 Generates data otherwise received and decoded from a radio message. More...
 
void clearSlots (uint8_t type=0xFF)
 Clear sensor data. More...
 
 

Detailed Description

-

Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receiving FSK modulated signal at 868 MHz.

+

Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receiving FSK modulated signal at 868 MHz.

Member Function Documentation

◆ begin()

@@ -172,7 +178,8 @@

-

Presence check and initialization of radio module.

+

Constructor.

+

Presence check and initialization of radio module.

Returns
RADIOLIB_ERR_NONE on success (otherwise does never return).

@@ -306,8 +313,8 @@

-

◆ genMessage()

+ +

◆ genMessage()

@@ -328,13 +335,19 @@

uint8_t  - type = 1, + s_type = 1, + + + + + uint8_t  + channel = 0, uint8_t  - channel = 0  + startup = 0  diff --git a/class_weather_sensor.js b/class_weather_sensor.js index 675a0733..b56c2ee7 100644 --- a/class_weather_sensor.js +++ b/class_weather_sensor.js @@ -1,14 +1,18 @@ var class_weather_sensor = [ + [ "AirPM", "struct_weather_sensor_1_1_air_p_m.html", "struct_weather_sensor_1_1_air_p_m" ], + [ "Leakage", "struct_weather_sensor_1_1_leakage.html", "struct_weather_sensor_1_1_leakage" ], + [ "Lightning", "struct_weather_sensor_1_1_lightning.html", "struct_weather_sensor_1_1_lightning" ], [ "Sensor", "struct_weather_sensor_1_1_sensor.html", "struct_weather_sensor_1_1_sensor" ], + [ "Soil", "struct_weather_sensor_1_1_soil.html", "struct_weather_sensor_1_1_soil" ], + [ "Weather", "struct_weather_sensor_1_1_weather.html", "struct_weather_sensor_1_1_weather" ], [ "sensor_t", "class_weather_sensor.html#ae38bcb7791c9c49d5f23c150d4517dc4", null ], - [ "WeatherSensor", "class_weather_sensor.html#aa72d395844ee645e779a3b005fbd5dfd", null ], [ "begin", "class_weather_sensor.html#a9b84d8518edf33a2f796288bb482eb8b", null ], [ "clearSlots", "class_weather_sensor.html#af7d1085b72f2f41e8b349e63d2628b0c", null ], [ "decodeMessage", "class_weather_sensor.html#af964b214e398132f25d4e783dffe708a", null ], [ "findId", "class_weather_sensor.html#a0adf85658be20d05e43e34c6b728b989", null ], [ "findType", "class_weather_sensor.html#ac0d3ac40d2ac605badcbb8e1631d64fa", null ], - [ "genMessage", "class_weather_sensor.html#a643dd64dab119203c14883e712d76aea", null ], + [ "genMessage", "class_weather_sensor.html#adffc6603766560fe6aa0cdd1200fc2a0", null ], [ "getData", "class_weather_sensor.html#a558191760f9d9b9bf12f79f6f3e5370a", null ], [ "getMessage", "class_weather_sensor.html#a05fbfc16fb2e13543591cb0b3cd8baaf", null ], [ "is_decode3in1", "class_weather_sensor.html#a3fe7bfad520c8834c5f85f7b0ed9eaad", null ], diff --git a/classes.html b/classes.html index 314b940e..f3a31b8f 100644 --- a/classes.html +++ b/classes.html @@ -86,23 +86,26 @@
Class Index

-
L | N | R | S | W
+
A | L | N | R | S | W
diff --git a/functions.html b/functions.html index f1812dcb..458b43c6 100644 --- a/functions.html +++ b/functions.html @@ -85,11 +85,8 @@
Here is a list of all documented class members with links to the class documentation for each member:

- a -

@@ -130,6 +127,9 @@

- d -

@@ -145,7 +145,7 @@

- f -