BresserWeatherSensorReceiver
Bresser 5-in-1/6-in-1/7-in-1 868 MHz Weather Sensor Radio Receiver for Arduino based on CC1101 or SX1276/RFM95W
Loading...
Searching...
No Matches
WeatherSensorCfg.h
1
2// WeatherSensorCfg.h
3//
4// Bresser 5-in-1/6-in-1/7-in-1 868 MHz Weather Sensor Radio Receiver
5// based on CC1101, SX1276/RFM95W, SX1262 or LR1121 and ESP32/ESP8266
6//
7// https://github.com/matthias-bs/BresserWeatherSensorReceiver
8//
9// NOTE: Application/hardware specific configurations should be made in this file!
10//
11// created: 05/2022
12//
13//
14// MIT License
15//
16// Copyright (c) 2026 Matthias Prinke
17//
18// Permission is hereby granted, free of charge, to any person obtaining a copy
19// of this software and associated documentation files (the "Software"), to deal
20// in the Software without restriction, including without limitation the rights
21// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22// copies of the Software, and to permit persons to whom the Software is
23// furnished to do so, subject to the following conditions:
24//
25// The above copyright notice and this permission notice shall be included in all
26// copies or substantial portions of the Software.
27//
28// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34// SOFTWARE.
35//
36// History:
37// 20230124 Added some default settings based on selected boards in Arduino IDE
38// 20230207 Added pin definitions for ARDUINO_TTGO_LoRa32_v21new
39// 20230208 Added pin definitions for ARDUINO_TTGO_LoRa32_V2
40// 20230301 Added pin definitions for Wireless_Stick (from Heltec)
41// 20230316 Added pin definitions for Adafruit Feather ESP32 with RFM95W "FeatherWing" ADA3232
42// 20230330 Added pin definitions and changes for Adafruit Feather 32u4 (AVR) RFM95 LoRa Radio
43// 20230412 Added workaround for Professional Wind Gauge / Anemometer, P/N 7002531
44// 20230420 Added pin definitions for DFRobot FireBeetle ESP32 with FireBeetle Cover LoRa
45// 20230607 Added pin definitions for Heltec WiFi LoRa 32(V2)
46// 20230624 Added Bresser Lightning Sensor decoder
47// 20230804 Added Bresser Water Leakage Sensor decoder
48// 20230926 Added pin definitions for Adafruit Feather RP2040 with RFM95W "FeatherWing" ADA3232
49// 20230927 Removed _DEBUG_MODE_ (log_d() is used instead)
50// 20231004 Added function names and line numbers to ESP8266/RP2040 debug logging
51// 20231101 Added USE_SX1262 for Heltec Wireless Stick V3
52// 20231121 Added Heltec WiFi LoRa32 V3
53// 20231130 Bresser 3-in-1 Professional Wind Gauge / Anemometer, PN 7002531: Replaced workaround
54// for negative temperatures by fix (6-in-1 decoder)
55// 20231227 Added RAINGAUGE_USE_PREFS and LIGHTNING_USE_PREFS
56// 20240122 Modified for unit testing
57// 20240204 Added separate ARDUINO_heltec_wireless_stick_v2/v3
58// 20240322 Added pin definitions for M5Stack Core2 with M5Stack Module LoRa868
59// 20240415 Added pin definitions for ESP32-S3 PowerFeather with with RFM95W "FeatherWing" ADA3232
60// 20240417 Modified SENSOR_IDS_INC
61// 20240425 Added define variant ARDUINO_heltec_wifi_lora_32_V3
62// 20240507 Renamed NUM_SENSORS to MAX_SENSORS_DEFAULT
63// NOTE: ARDUINO_ARCH_AVR no longer supported due to code size!!!
64// 20240508 Updated board definitions after changes in arduino-esp32 v3.0.0
65// 20240509 Fixed ARDUINO_HELTEC_WIRELESS_STICK_V3
66// 20240904 Added ARDUINO_ESP32S3_DEV
67// 20240910 Heltec: Fixed pin definitions
68// 20241030 Added pin definitions for Maker Go ESP32C3 Supermini with Heltec HT-RA62
69// 20241130 Added pin definitions for Heltec Vision Master T190
70// 20241205 Added pin definitions for Lilygo T3-S3 (SX1262/SX1276/LR1121)
71// 20241227 Improved maintainability of board definitions
72// 20260114 Added pin definitions for Seeed Studio XIAO ESP32S3 with Wio-SX1262
73// 20260611 Added pin definitions for Heltec Wireless Stick Lite V3 (SX1262)
74// 20260514 Added pin definitions for Heltec WiFi LoRa 32(V4)
75// 20260707 Added pin definitions for Heltec Wireless Paper (SX1262)
76//
77// ToDo:
78// -
79//
81
82#if !defined(WEATHER_SENSOR_CFG_H)
83#define WEATHER_SENSOR_CFG_H
84
85#include <Arduino.h>
86
87// ------------------------------------------------------------------------------------------------
88// --- Weather Sensors ---
89// ------------------------------------------------------------------------------------------------
90#define MAX_SENSORS_DEFAULT 1 // Maximum number of sensors to be received
91
92// List of sensor IDs to be excluded - can be empty
93#define SENSOR_IDS_EXC { 0x792882A2 }
94//#define SENSOR_IDS_EXC { 0x792882A2 }
95
96// List of sensor IDs to be included - if empty, handle all available sensors
97#define SENSOR_IDS_INC { }
98//#define SENSOR_IDS_INC { 0x83750871 }
99
100// Maximum number of sensor IDs in include/exclude list
101#define MAX_SENSOR_IDS 12
102
103// Disable data type which will not be used to save RAM
104#define WIND_DATA_FLOATINGPOINT
105#define WIND_DATA_FIXEDPOINT
106
107// Select appropriate sensor message format(s)
108// Comment out unused decoders to save operation time/power
109#define BRESSER_5_IN_1
110#define BRESSER_6_IN_1
111#define BRESSER_7_IN_1
112#define BRESSER_LIGHTNING
113#define BRESSER_LEAKAGE
114
115
116// ------------------------------------------------------------------------------------------------
117// --- Rain Gauge / Lightning sensor data retention during deep sleep ---
118// ------------------------------------------------------------------------------------------------
119
120#if !defined(INSIDE_UNITTEST)
121 #if defined(ESP32)
122 // Option: Comment out to save data in RTC RAM
123 // N.B.:
124 // ESP8266 has RTC RAM, too, but access is different from ESP32
125 // and currently not implemented here
126 #define RAINGAUGE_USE_PREFS
127 #define LIGHTNING_USE_PREFS
128 #else
129 // Using Preferences is mandatory on other architectures (e.g. RP2040)
130 #define RAINGAUGE_USE_PREFS
131 #define LIGHTNING_USE_PREFS
132 #endif
133#endif
134
135// ------------------------------------------------------------------------------------------------
136// --- Board ---
137// ------------------------------------------------------------------------------------------------
138
139// LILYGO TTGO LoRaP32 board with integrated RF transceiver (SX1276)
140// See pin definitions in
141// https://github.com/espressif/arduino-esp32/tree/master/variants/ttgo-lora32-*
142// and
143// https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-2/11973
144
145// This define is set by selecting "Board: TTGO LoRa32-OLED" / "Board Revision: TTGO LoRa32 V1 (No TFCard)"
146// in the Arduino IDE:
147//#define ARDUINO_TTGO_LoRa32_V1
148
149// This define is set by selecting "Board: TTGO LoRa32-OLED" / "Board Revision: TTGO LoRa32 V2"
150// in the Arduino IDE:
151//#define ARDUINO_TTGO_LoRa32_V2
152
153// This define is set by selecting "Board: TTGO LoRa32-OLED" / "Board Revision: TTGO LoRa32 V2.1 (1.6.1)"
154// in the Arduino IDE:
155//#define ARDUINO_TTGO_LoRa32_V21new
156
157// These defines are set by selecting
158// "Board: LilyGo T3-S3" / "Board Revision: Radio-SX1262|Radio-SX1276|Radio-LR1121" in the Arduino IDE:
159//#define ARDUINO_LILYGO_T3S3_SX1262
160//#define ARDUINO_LILYGO_T3S3_SX1276
161//#define ARDUINO_LILYGO_T3S3_LR1121
162
163// This define is set by selecting "Board: Heltec Wireless Stick" (SX1276) in the Arduino IDE:
164//#define ARDUINO_HELTEC_WIRELESS_STICK
165
166// This define is set by selecting "Board: Heltec Wireless Stick Lite(V3)" (SX1262, ESP32-S3) in the Arduino IDE.
167// See pin definitions in
168// https://github.com/espressif/arduino-esp32/blob/master/variants/heltec_wireless_stick_lite_v3/pins_arduino.h
169// and
170// https://github.com/meshtastic/firmware/blob/master/variants/esp32s3/heltec_wsl_v3/variant.h
171//#define HELTEC_WIRELESS_STICK_LITE_V3
172
173// This define is set by selecting "Board: Heltec Wireless Stick(V3)" (SX1262) in the Arduino IDE:
174//#define ARDUINO_HELTEC_WIRELESS_STICK_V3
175
176// This define is set by selecting "Board: Heltec Vision Master T190" in the Arduino IDE:
177//#define ARDUINO_HELTEC_VISION_MASTER_T190
178
179// This define is set by selecting "Board: Heltec WiFi LoRa 32(V2)" in the Arduino IDE:
180//#define ARDUINO_HELTEC_WIFI_LORA_32_V2
181
182// This define is set by selecting "Board: Heltec WiFi LoRa 32(V4)" in the Arduino IDE:
183//#define ARDUINO_HELTEC_WIFI_LORA_32_V4
184
185// Adafruit Feather ESP32S2 with RFM95W "FeatherWing" ADA3232
186// https://github.com/espressif/arduino-esp32/blob/master/variants/adafruit_feather_esp32s2/pins_arduino.h
187//
188// This define is set by selecting "Adafruit Feather ESP32-S2" in the Arduino IDE:
189//#define ARDUINO_ADAFRUIT_FEATHER_ESP32S2
190
191// Adafruit Feather ESP32 with RFM95W "FeatherWing" ADA3232
192// https://github.com/espressif/arduino-esp32/blob/master/variants/feather_esp32/pins_arduino.h
193//
194// This define is set by selecting "Adafruit ESP32 Feather" in the Arduino IDE:
195//#define ARDUINO_FEATHER_ESP32
196
197// Adafruit Feather RP2040 with RFM95W "FeatherWing" ADA3232
198// https://github.com/espressif/arduino-esp32/blob/master/variants/feather_esp32/pins_arduino.h
199//
200// This define is set by selecting "Adafruit Feather RP2040" in the Arduino IDE:
201//#define ARDUINO_ADAFRUIT_FEATHER_RP2040
202
203// DFRobot Firebeetle32
204// https://github.com/espressif/arduino-esp32/tree/master/variants/firebeetle32/pins_arduino.h
205//
206// This define is set by selecting "FireBeetle-ESP32" in the Arduino IDE:
207//#define ARDUINO_DFROBOT_FIREBEETLE_ESP32
208
209// M5Stack Core2
210// https://github.com/espressif/arduino-esp32/blob/master/variants/m5stack_core2/pins_arduino.h
211//
212// This define is set by selecting "M5Core2" in the Arduino IDE
213//#define ARDUINO_M5STACK_CORE2
214
215#if defined(ARDUINO_TTGO_LoRa32_V1)
216 #pragma message("ARDUINO_TTGO_LoRa32_V1 defined; using on-board transceiver")
217 #define USE_SX1276
218 // Use pinning for LILIGO TTGO LoRa32-OLED
219 #define PIN_RECEIVER_CS LORA_CS
220 #define PIN_RECEIVER_IRQ LORA_IRQ
221 // n.c. on v1/v2?, LORA_D1 on v21
222 #define PIN_RECEIVER_GPIO 33
223 #define PIN_RECEIVER_RST LORA_RST
224
225#elif defined(ARDUINO_TTGO_LoRa32_V2)
226 #pragma message("ARDUINO_TTGO_LoRa32_V2 defined; using on-board transceiver")
227 #define USE_SX1276
228 // Use pinning for LILIGO TTGO LoRa32-OLED
229 #define PIN_RECEIVER_CS LORA_CS
230 #define PIN_RECEIVER_IRQ LORA_IRQ
231 // n.c. on v1/v2?, LORA_D1 on v21
232 #define PIN_RECEIVER_GPIO 33
233 #define PIN_RECEIVER_RST LORA_RST
234
235#elif defined(ARDUINO_TTGO_LoRa32_v21new)
236 #pragma message("ARDUINO_TTGO_LoRa32_V21new defined; using on-board transceiver")
237 #define USE_SX1276
238 // Use pinning for LILIGO TTGO LoRa32-OLED V2.1 (1.6.1)
239 #define PIN_RECEIVER_CS LORA_CS
240 #define PIN_RECEIVER_IRQ LORA_IRQ
241 #define PIN_RECEIVER_GPIO LORA_D1
242 #define PIN_RECEIVER_RST LORA_RST
243
244#elif defined(ARDUINO_LILYGO_T3S3_SX1262)
245 // https://github.com/espressif/arduino-esp32/blob/master/variants/lilygo_t3_s3_sx1262/pins_arduino.h
246 #pragma message("ARDUINO_LILYGO_T3S3_SX1262 defined; using on-board transceiver")
247 #define USE_SX1262
248 #define PIN_RECEIVER_CS LORA_CS
249 #define PIN_RECEIVER_IRQ LORA_IRQ
250 #define PIN_RECEIVER_GPIO LORA_BUSY
251 #define PIN_RECEIVER_RST LORA_RST
252
253#elif defined(ARDUINO_LILYGO_T3S3_SX1276)
254 // https://github.com/espressif/arduino-esp32/blob/master/variants/lilygo_t3_s3_sx127x/pins_arduino.h
255 #pragma message("ARDUINO_LILYGO_T3S3_SX1276 defined; using on-board transceiver")
256 #define USE_SX1276
257 #define PIN_RECEIVER_CS LORA_CS
258 #define PIN_RECEIVER_IRQ LORA_IRQ
259 #define PIN_RECEIVER_GPIO LORA_BUSY
260 #define PIN_RECEIVER_RST LORA_RST
261
262#elif defined(ARDUINO_LILYGO_T3S3_LR1121)
263 // https://github.com/espressif/arduino-esp32/blob/master/variants/lilygo_t3_s3_lr1121/pins_arduino.h
264 #pragma message("ARDUINO_LILYGO_T3S3_LR1121 defined; using on-board transceiver")
265 #define USE_LR1121
266 #define PIN_RECEIVER_CS LORA_CS
267 #define PIN_RECEIVER_IRQ LORA_IRQ
268 #define PIN_RECEIVER_GPIO LORA_BUSY
269 #define PIN_RECEIVER_RST LORA_RST
270
271#elif defined(ARDUINO_HELTEC_WIRELESS_STICK)
272 // Heltec Wireless Stick V2
273 #pragma message("ARDUINO_HELTEC_WIRELESS_STICK defined; using on-board transceiver")
274 #define USE_SX1276
275 // Use pinning for Heltec Wireless Stick or WiFi LoRa32 V2, respectively
276 #define PIN_RECEIVER_CS SS
277 #define PIN_RECEIVER_IRQ DIO0
278 #define PIN_RECEIVER_GPIO DIO1
279 #define PIN_RECEIVER_RST RST_LoRa
280
281#elif defined(HELTEC_WIRELESS_STICK_LITE_V3)
282 // Heltec Wireless Stick Lite V3
283 #pragma message("HELTEC_WIRELESS_STICK_LITE_V3 defined; using on-board transceiver")
284 #define USE_SX1262
285 #define LORA_CS 8
286 #define LORA_SCK 9
287 #define LORA_MOSI 10
288 #define LORA_MISO 11
289 #define PIN_RECEIVER_CS LORA_CS
290 #define PIN_RECEIVER_IRQ DIO0
291 #define PIN_RECEIVER_GPIO BUSY_LoRa
292 #define PIN_RECEIVER_RST RST_LoRa
293
294#elif defined(ARDUINO_HELTEC_WIRELESS_STICK_V3)
295 #pragma message("ARDUINO_HELTEC_WIRELESS_STICK_V3 defined; using on-board transceiver")
296 #define USE_SX1276
297 #define PIN_RECEIVER_CS SS
298 #define PIN_RECEIVER_IRQ DIO0
299 #define PIN_RECEIVER_GPIO BUSY_LoRa
300 #define PIN_RECEIVER_RST RST_LoRa
301
302#elif defined(ARDUINO_HELTEC_WIRELESS_PAPER)
303 #pragma message("ARDUINO_HELTEC_WIRELESS_PAPER defined; using on-board transceiver")
304 #define USE_SX1262
305 #define PIN_RECEIVER_CS SS
306 #define PIN_RECEIVER_IRQ DIO1
307 #define PIN_RECEIVER_GPIO BUSY_LoRa
308 #define PIN_RECEIVER_RST RST_LoRa
309
310#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2)
311 #pragma message("ARDUINO_HELTEC_WIFI_LORA_32_V2 defined; using on-board transceiver")
312 #define USE_SX1276
313 // Use pinning for Heltec Wireless Stick or WiFi LoRa32 V2, respectively
314 #define PIN_RECEIVER_CS SS
315 #define PIN_RECEIVER_IRQ DIO0
316 #define PIN_RECEIVER_GPIO DIO1
317 #define PIN_RECEIVER_RST RST_LoRa
318
319#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V3) || defined(ARDUINO_HELTEC_VISION_MASTER_T190)
320 #pragma message("ARDUINO_HELTEC_WIFI_LORA_32_V3 / ARDUINO_HELTEC_VISION_MASTER_T190 defined; using on-board transceiver")
321 #define USE_SX1262
322 #define PIN_RECEIVER_CS SS
323 #define PIN_RECEIVER_IRQ DIO0
324 #define PIN_RECEIVER_GPIO BUSY_LoRa
325 #define PIN_RECEIVER_RST RST_LoRa
326
327#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V4)
328 // Heltec WiFi LoRa 32(V4)
329 #pragma message("ARDUINO_HELTEC_WIFI_LORA_32_V4 defined; using on-board transceiver")
330 #define USE_SX1262
331 #define PIN_RECEIVER_CS SS
332 #define PIN_RECEIVER_IRQ DIO0
333 #define PIN_RECEIVER_GPIO BUSY_LoRa
334 #define PIN_RECEIVER_RST RST_LoRa
335
336#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
337 #pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32S2 defined; assuming RFM95W FeatherWing will be used")
338 #define USE_SX1276
339 // Use pinning for Adafruit Feather ESP32S2 with RFM95W "FeatherWing" ADA3232
340 #define PIN_RECEIVER_CS 6
341 #define PIN_RECEIVER_IRQ 5
342 #define PIN_RECEIVER_GPIO 11
343 #define PIN_RECEIVER_RST 9
344
345#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
346 #pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32_V2 defined; assuming RFM95W FeatherWing will be used")
347 #define USE_SX1276
348 #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
349 // Use pinning for Adafruit Feather ESP32 with RFM95W "FeatherWing" ADA3232
350 #define PIN_RECEIVER_CS 14
351 #define PIN_RECEIVER_IRQ 32
352 #define PIN_RECEIVER_GPIO 33
353 #define PIN_RECEIVER_RST 27
354
355#elif defined(ARDUINO_FEATHER_ESP32) || defined(ARDUINO_THINGPULSE_EPULSE_FEATHER)
356 #pragma message("ARDUINO_FEATHER_ESP32/ARDUINO_THINGPULSE_EPULSE_FEATHER defined; assuming RFM95W FeatherWing will be used")
357 #define USE_SX1276
358 #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
359 // Use pinning for Adafruit Feather ESP32 with RFM95W "FeatherWing" ADA3232
360 #define PIN_RECEIVER_CS 14
361 #define PIN_RECEIVER_IRQ 32
362 #define PIN_RECEIVER_GPIO 33
363 #define PIN_RECEIVER_RST 27
364
365#elif defined(ARDUINO_M5STACK_CORE2)
366 #pragma message("ARDUINO_M5STACK_CORE2 defined; assuming M5Stack Module LoRa868 will be used")
367 #define USE_SX1276
368 #define PIN_RECEIVER_CS 33
369 #define PIN_RECEIVER_IRQ 36
370 #define PIN_RECEIVER_GPIO 35
371 #define PIN_RECEIVER_RST 26
372
373#elif defined(ARDUINO_ESP32S3_POWERFEATHER)
374 #pragma message("ARDUINO_ESP32S3_POWERFEATHER defined; assuming RFM95W FeatherWing will be used")
375 #define USE_SX1276
376 #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
377 // Use pinning for ESP32-S3 PowerFeather with RFM95W "FeatherWing" ADA3232
378 #define PIN_RECEIVER_CS 15
379 #define PIN_RECEIVER_IRQ 16
380 #define PIN_RECEIVER_GPIO 18
381 #define PIN_RECEIVER_RST 45
382
383#elif defined(ARDUINO_XIAO_ESP32S3)
384 #pragma message("ARDUINO_XIAO_ESP32S3 defined; assuming Wio-SX1262 will be used")
385 #define USE_SX1262
386 // Use pinning for Seeed XIAO ESP32S3 with Wio-SX1262
387 #define PIN_RECEIVER_CS 41
388 #define PIN_RECEIVER_IRQ 39
389 #define PIN_RECEIVER_GPIO 40
390 #define PIN_RECEIVER_RST 42
391
392#elif defined(ARDUINO_ESP32S3_DEV)
393 #pragma message("ARDUINO_ESP32S3_DEV defined; this is a generic (i.e. non-specific) target")
394 #define USE_SX1276
395 //#define USE_SX1262
396 //#define USE_CC1101
397 //#define USE_LR1121
398 #pragma message("Cross check if the selected GPIO pins are really available on your board.")
399 #pragma message("Connect a radio module with a supported chip.")
400 #pragma message("Select the chip by setting the appropriate define.")
401 // Use pinning for generic ESP32 S3 board with unspecified radio module
402 #define PIN_RECEIVER_CS 10
403 #define PIN_RECEIVER_IRQ 21
404 #define PIN_RECEIVER_GPIO 8
405 #define PIN_RECEIVER_RST 9
406
407#elif defined(ARDUINO_MAKERGO_C3_SUPERMINI)
408 // Maker Go ESP32C3 Supermini
409 #pragma message("ARDUINO_MAKERGO_C3_SUPERMINI defined; assuming Heltec HT-RA62 (SX1262) will be used")
410 #define USE_SX1262
411 // Use pinning for Maker Go ESP32C3 Supermini with Heltec HT-RA62
412 #define PIN_RECEIVER_CS 7
413 #define PIN_RECEIVER_IRQ 1
414 #define PIN_RECEIVER_GPIO 2
415 #define PIN_RECEIVER_RST 3
416
417#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
418 #pragma message("ARDUINO_ADAFRUIT_FEATHER_RP2040 defined; assuming RFM95W FeatherWing will be used")
419 #define USE_SX1276
420 #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
421 // Use pinning for Adafruit Feather RP2040 with RFM95W "FeatherWing" ADA3232
422 #define PIN_RECEIVER_CS 7
423 #define PIN_RECEIVER_IRQ 8
424 #define PIN_RECEIVER_GPIO 10
425 #define PIN_RECEIVER_RST 11
426
427#elif defined(ARDUINO_DFROBOT_FIREBEETLE_ESP32)
428 //#define LORAWAN_NODE
429 #define DFROBOT_COVER_LORA
430
431 #if defined(DFROBOT_COVER_LORA)
432 #pragma message("ARDUINO_DFROBOT_FIREBEETLE_ESP32 & DFROBOT_COVER_LORA defined; assuming this is a FireBeetle ESP32 with FireBeetle Cover LoRa")
433 #define USE_SX1276
434 #pragma message("Required wiring: D2 to RESET, D3 to DIO0, D4 to CS, D5 to DIO1")
435 #define PIN_RECEIVER_CS 27 // D4
436 #define PIN_RECEIVER_IRQ 26 // D3
437 #define PIN_RECEIVER_GPIO 9 // D5
438 #define PIN_RECEIVER_RST 25 // D2
439
440 #elif defined(LORAWAN_NODE)
441 #pragma message("ARDUINO_DFROBOT_FIREBEETLE_ESP32 & LORAWAN_NODE defined; assuming this is the LoRaWAN_Node board (DFRobot Firebeetle32 + Adafruit RFM95W LoRa Radio)")
442 #define USE_SX1276
443
444 // Use pinning for LoRaWAN_Node (https://github.com/matthias-bs/LoRaWAN_Node)
445 #define PIN_RECEIVER_CS 14
446 #define PIN_RECEIVER_IRQ 4
447 #define PIN_RECEIVER_GPIO 16
448 #define PIN_RECEIVER_RST 12
449
450 #else
451 #pragma message("ARDUINO_DFROBOT_FIREBEETLE_ESP32 defined; if you use one of those boards, select either LORAWAN_NODE or FIREBEETLE_ESP32_COVER_LORA manually!")
452
453 #endif
454#elif defined(ESP32)
455 #pragma message("ESP32 defined; this is a generic (i.e. non-specific) target")
456 #pragma message("Cross check if the selected GPIO pins are really available on your board.")
457 #pragma message("Connect a radio module with a supported chip.")
458 #pragma message("Select the chip by setting the appropriate define.")
459 #define USE_SX1276
460 //#define USE_SX1262
461 //#define USE_CC1101
462 //#define USE_LR1121
463 // Generic pinning for ESP32 development boards
464 #define PIN_RECEIVER_CS 27
465 #define PIN_RECEIVER_IRQ 21
466 #define PIN_RECEIVER_GPIO 33
467 #define PIN_RECEIVER_RST 32
468
469 // When using SPI bus other than FSPI, e.g. HSPI, define the following
470 //#define LORA_SPI_BUS HSPI
471 //#define LORA_CS 48
472 //#define LORA_SCK 45
473 //#define LORA_MISO 46
474 //#define LORA_MOSI 47
475#elif defined(ESP8266)
476 #pragma message("ESP8266 defined; this is a generic (i.e. non-specific) target")
477 #pragma message("Cross check if the selected GPIO pins are really available on your board.")
478 #pragma message("Connect a radio module with a supported chip.")
479 #pragma message("Select the chip by setting the appropriate define.")
480 //#define USE_SX1276
481 //#define USE_SX1262
482 #define USE_CC1101
483 //#define USE_LR1121
484
485 // Generic pinning for ESP8266 development boards (e.g. LOLIN/WEMOS D1 mini)
486 #define PIN_RECEIVER_CS 15
487 #define PIN_RECEIVER_IRQ 4
488 #define PIN_RECEIVER_GPIO 5
489 #define PIN_RECEIVER_RST 2
490#endif
491
492#if defined(USE_CC1101)
493#define RADIO_CHIP CC1101
494#elif defined(USE_SX1276)
495#define RADIO_CHIP SX1276
496#elif defined(USE_SX1262)
497#define RADIO_CHIP SX1262
498#elif defined(USE_LR1121)
499#define RADIO_CHIP LR1121
500#else
501#pragma message("No radio chip selected!")
502#endif
503
504
505// ------------------------------------------------------------------------------------------------
506// --- Debug Logging Output ---
507// ------------------------------------------------------------------------------------------------
508// - ESP32:
509// CORE_DEBUG_LEVEL is set in Adruino IDE:
510// Tools->Core Debug Level: "<None>|<Error>|<Warning>|<Info>|<Debug>|<Verbose>"
511// https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-log.h
512//
513// - ESP8266:
514// DEBUG_ESP_PORT is set in Arduino IDE:
515// Tools->Debug port: "<None>|<Serial>|<Serial1>"
516//
517// - RP2040:
518// DEBUG_RP2040_PORT is set in Arduino IDE:
519// Tools->Debug port: "<Disabled>|<Serial>|<Serial1>|<Serial2>"
520//
521// Replacement for
522// https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-log.h
523// on ESP8266 and RP2040:
524#if defined(ESP8266) || defined(ARDUINO_ARCH_RP2040)
525 #define ARDUHAL_LOG_LEVEL_NONE 0
526 #define ARDUHAL_LOG_LEVEL_ERROR 1
527 #define ARDUHAL_LOG_LEVEL_WARN 2
528 #define ARDUHAL_LOG_LEVEL_INFO 3
529 #define ARDUHAL_LOG_LEVEL_DEBUG 4
530 #define ARDUHAL_LOG_LEVEL_VERBOSE 5
531
532 #if defined(ARDUINO_ARCH_RP2040) && defined(DEBUG_RP2040_PORT)
533 #define DEBUG_PORT DEBUG_RP2040_PORT
534 #elif defined(DEBUG_ESP_PORT)
535 #define DEBUG_PORT DEBUG_ESP_PORT
536 #endif
537
538 // Set desired level here if not defined elsewhere!
539 #if !defined(CORE_DEBUG_LEVEL)
540 #define CORE_DEBUG_LEVEL ARDUHAL_LOG_LEVEL_INFO
541 #endif
542
543 #if defined(DEBUG_PORT) && CORE_DEBUG_LEVEL > ARDUHAL_LOG_LEVEL_NONE
544 #define log_e(...) { DEBUG_PORT.printf("%s(), l.%d: ",__func__, __LINE__); DEBUG_PORT.printf(__VA_ARGS__); DEBUG_PORT.println(); }
545 #else
546 #define log_e(...) {}
547 #endif
548 #if defined(DEBUG_PORT) && CORE_DEBUG_LEVEL > ARDUHAL_LOG_LEVEL_ERROR
549 #define log_w(...) { DEBUG_PORT.printf("%s(), l.%d: ", __func__, __LINE__); DEBUG_PORT.printf(__VA_ARGS__); DEBUG_PORT.println(); }
550 #else
551 #define log_w(...) {}
552 #endif
553 #if defined(DEBUG_PORT) && CORE_DEBUG_LEVEL > ARDUHAL_LOG_LEVEL_WARN
554 #define log_i(...) { DEBUG_PORT.printf("%s(), l.%d: ", __func__, __LINE__); DEBUG_PORT.printf(__VA_ARGS__); DEBUG_PORT.println(); }
555 #else
556 #define log_i(...) {}
557 #endif
558 #if defined(DEBUG_PORT) && CORE_DEBUG_LEVEL > ARDUHAL_LOG_LEVEL_INFO
559 #define log_d(...) { DEBUG_PORT.printf("%s(), l.%d: ", __func__, __LINE__); DEBUG_PORT.printf(__VA_ARGS__); DEBUG_PORT.println(); }
560 #else
561 #define log_d(...) {}
562 #endif
563 #if defined(DEBUG_PORT) && CORE_DEBUG_LEVEL > ARDUHAL_LOG_LEVEL_DEBUG
564 #define log_v(...) { DEBUG_PORT.printf("%s(), l.%d: ", __func__, __LINE__); DEBUG_PORT.printf(__VA_ARGS__); DEBUG_PORT.println(); }
565 #else
566 #define log_v(...) {}
567 #endif
568
569#endif
570
571#define STR_HELPER(x) #x
572#define STR(x) STR_HELPER(x)
573#define RECEIVER_CHIP "[" STR(RADIO_CHIP) "]"
574#pragma message("Receiver chip: " RECEIVER_CHIP)
575#pragma message("Pin config: RST->" STR(PIN_RECEIVER_RST) ", CS->" STR(PIN_RECEIVER_CS) ", GD0/G0/IRQ->" STR(PIN_RECEIVER_IRQ) ", GDO2/G1/GPIO->" STR(PIN_RECEIVER_GPIO) )
576
577#endif