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// 20260826 Added ARDUINO_ESP32S3_POWERFEATHER_V2
77//
78// ToDo:
79// -
80//
82
83#if !defined(WEATHER_SENSOR_CFG_H)
84#define WEATHER_SENSOR_CFG_H
85
86#include <Arduino.h>
87
88// ------------------------------------------------------------------------------------------------
89// --- Weather Sensors ---
90// ------------------------------------------------------------------------------------------------
91#define MAX_SENSORS_DEFAULT 1 // Maximum number of sensors to be received
92
93// List of sensor IDs to be excluded - can be empty
94#define SENSOR_IDS_EXC { 0x792882A2 }
95//#define SENSOR_IDS_EXC { 0x792882A2 }
96
97// List of sensor IDs to be included - if empty, handle all available sensors
98#define SENSOR_IDS_INC { }
99//#define SENSOR_IDS_INC { 0x83750871 }
100
101// Maximum number of sensor IDs in include/exclude list
102#define MAX_SENSOR_IDS 12
103
104// Disable data type which will not be used to save RAM
105#define WIND_DATA_FLOATINGPOINT
106#define WIND_DATA_FIXEDPOINT
107
108// Select appropriate sensor message format(s)
109// Comment out unused decoders to save operation time/power
110#define BRESSER_5_IN_1
111#define BRESSER_6_IN_1
112#define BRESSER_7_IN_1
113#define BRESSER_LIGHTNING
114#define BRESSER_LEAKAGE
115
116
117// ------------------------------------------------------------------------------------------------
118// --- Rain Gauge / Lightning sensor data retention during deep sleep ---
119// ------------------------------------------------------------------------------------------------
120
121#if !defined(INSIDE_UNITTEST)
122 #if defined(ESP32)
123 // Option: Comment out to save data in RTC RAM
124 // N.B.:
125 // ESP8266 has RTC RAM, too, but access is different from ESP32
126 // and currently not implemented here
127 #define RAINGAUGE_USE_PREFS
128 #define LIGHTNING_USE_PREFS
129 #else
130 // Using Preferences is mandatory on other architectures (e.g. RP2040)
131 #define RAINGAUGE_USE_PREFS
132 #define LIGHTNING_USE_PREFS
133 #endif
134#endif
135
136// ------------------------------------------------------------------------------------------------
137// --- Board ---
138// ------------------------------------------------------------------------------------------------
139
140// LILYGO TTGO LoRaP32 board with integrated RF transceiver (SX1276)
141// See pin definitions in
142// https://github.com/espressif/arduino-esp32/tree/master/variants/ttgo-lora32-*
143// and
144// https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-2/11973
145
146// This define is set by selecting "Board: TTGO LoRa32-OLED" / "Board Revision: TTGO LoRa32 V1 (No TFCard)"
147// in the Arduino IDE:
148//#define ARDUINO_TTGO_LoRa32_V1
149
150// This define is set by selecting "Board: TTGO LoRa32-OLED" / "Board Revision: TTGO LoRa32 V2"
151// in the Arduino IDE:
152//#define ARDUINO_TTGO_LoRa32_V2
153
154// This define is set by selecting "Board: TTGO LoRa32-OLED" / "Board Revision: TTGO LoRa32 V2.1 (1.6.1)"
155// in the Arduino IDE:
156//#define ARDUINO_TTGO_LoRa32_V21new
157
158// These defines are set by selecting
159// "Board: LilyGo T3-S3" / "Board Revision: Radio-SX1262|Radio-SX1276|Radio-LR1121" in the Arduino IDE:
160//#define ARDUINO_LILYGO_T3S3_SX1262
161//#define ARDUINO_LILYGO_T3S3_SX1276
162//#define ARDUINO_LILYGO_T3S3_LR1121
163
164// This define is set by selecting "Board: Heltec Wireless Stick" (SX1276) in the Arduino IDE:
165//#define ARDUINO_HELTEC_WIRELESS_STICK
166
167// This define is set by selecting "Board: Heltec Wireless Stick Lite(V3)" (SX1262, ESP32-S3) in the Arduino IDE.
168// See pin definitions in
169// https://github.com/espressif/arduino-esp32/blob/master/variants/heltec_wireless_stick_lite_v3/pins_arduino.h
170// and
171// https://github.com/meshtastic/firmware/blob/master/variants/esp32s3/heltec_wsl_v3/variant.h
172//#define HELTEC_WIRELESS_STICK_LITE_V3
173
174// This define is set by selecting "Board: Heltec Wireless Stick(V3)" (SX1262) in the Arduino IDE:
175//#define ARDUINO_HELTEC_WIRELESS_STICK_V3
176
177// This define is set by selecting "Board: Heltec Vision Master T190" in the Arduino IDE:
178//#define ARDUINO_HELTEC_VISION_MASTER_T190
179
180// This define is set by selecting "Board: Heltec WiFi LoRa 32(V2)" in the Arduino IDE:
181//#define ARDUINO_HELTEC_WIFI_LORA_32_V2
182
183// This define is set by selecting "Board: Heltec WiFi LoRa 32(V4)" in the Arduino IDE:
184//#define ARDUINO_HELTEC_WIFI_LORA_32_V4
185
186// Adafruit Feather ESP32S2 with RFM95W "FeatherWing" ADA3232
187// https://github.com/espressif/arduino-esp32/blob/master/variants/adafruit_feather_esp32s2/pins_arduino.h
188//
189// This define is set by selecting "Adafruit Feather ESP32-S2" in the Arduino IDE:
190//#define ARDUINO_ADAFRUIT_FEATHER_ESP32S2
191
192// Adafruit Feather ESP32 with RFM95W "FeatherWing" ADA3232
193// https://github.com/espressif/arduino-esp32/blob/master/variants/feather_esp32/pins_arduino.h
194//
195// This define is set by selecting "Adafruit ESP32 Feather" in the Arduino IDE:
196//#define ARDUINO_FEATHER_ESP32
197
198// Adafruit Feather RP2040 with RFM95W "FeatherWing" ADA3232
199// https://github.com/espressif/arduino-esp32/blob/master/variants/feather_esp32/pins_arduino.h
200//
201// This define is set by selecting "Adafruit Feather RP2040" in the Arduino IDE:
202//#define ARDUINO_ADAFRUIT_FEATHER_RP2040
203
204// DFRobot Firebeetle32
205// https://github.com/espressif/arduino-esp32/tree/master/variants/firebeetle32/pins_arduino.h
206//
207// This define is set by selecting "FireBeetle-ESP32" in the Arduino IDE:
208//#define ARDUINO_DFROBOT_FIREBEETLE_ESP32
209
210// M5Stack Core2
211// https://github.com/espressif/arduino-esp32/blob/master/variants/m5stack_core2/pins_arduino.h
212//
213// This define is set by selecting "M5Core2" in the Arduino IDE
214//#define ARDUINO_M5STACK_CORE2
215
216#if defined(ARDUINO_TTGO_LoRa32_V1)
217 #pragma message("ARDUINO_TTGO_LoRa32_V1 defined; using on-board transceiver")
218 #define USE_SX1276
219 // Use pinning for LILIGO TTGO LoRa32-OLED
220 #define PIN_RECEIVER_CS LORA_CS
221 #define PIN_RECEIVER_IRQ LORA_IRQ
222 // n.c. on v1/v2?, LORA_D1 on v21
223 #define PIN_RECEIVER_GPIO 33
224 #define PIN_RECEIVER_RST LORA_RST
225
226#elif defined(ARDUINO_TTGO_LoRa32_V2)
227 #pragma message("ARDUINO_TTGO_LoRa32_V2 defined; using on-board transceiver")
228 #define USE_SX1276
229 // Use pinning for LILIGO TTGO LoRa32-OLED
230 #define PIN_RECEIVER_CS LORA_CS
231 #define PIN_RECEIVER_IRQ LORA_IRQ
232 // n.c. on v1/v2?, LORA_D1 on v21
233 #define PIN_RECEIVER_GPIO 33
234 #define PIN_RECEIVER_RST LORA_RST
235
236#elif defined(ARDUINO_TTGO_LoRa32_v21new)
237 #pragma message("ARDUINO_TTGO_LoRa32_V21new defined; using on-board transceiver")
238 #define USE_SX1276
239 // Use pinning for LILIGO TTGO LoRa32-OLED V2.1 (1.6.1)
240 #define PIN_RECEIVER_CS LORA_CS
241 #define PIN_RECEIVER_IRQ LORA_IRQ
242 #define PIN_RECEIVER_GPIO LORA_D1
243 #define PIN_RECEIVER_RST LORA_RST
244
245#elif defined(ARDUINO_LILYGO_T3S3_SX1262)
246 // https://github.com/espressif/arduino-esp32/blob/master/variants/lilygo_t3_s3_sx1262/pins_arduino.h
247 #pragma message("ARDUINO_LILYGO_T3S3_SX1262 defined; using on-board transceiver")
248 #define USE_SX1262
249 #define PIN_RECEIVER_CS LORA_CS
250 #define PIN_RECEIVER_IRQ LORA_IRQ
251 #define PIN_RECEIVER_GPIO LORA_BUSY
252 #define PIN_RECEIVER_RST LORA_RST
253
254#elif defined(ARDUINO_LILYGO_T3S3_SX1276)
255 // https://github.com/espressif/arduino-esp32/blob/master/variants/lilygo_t3_s3_sx127x/pins_arduino.h
256 #pragma message("ARDUINO_LILYGO_T3S3_SX1276 defined; using on-board transceiver")
257 #define USE_SX1276
258 #define PIN_RECEIVER_CS LORA_CS
259 #define PIN_RECEIVER_IRQ LORA_IRQ
260 #define PIN_RECEIVER_GPIO LORA_BUSY
261 #define PIN_RECEIVER_RST LORA_RST
262
263#elif defined(ARDUINO_LILYGO_T3S3_LR1121)
264 // https://github.com/espressif/arduino-esp32/blob/master/variants/lilygo_t3_s3_lr1121/pins_arduino.h
265 #pragma message("ARDUINO_LILYGO_T3S3_LR1121 defined; using on-board transceiver")
266 #define USE_LR1121
267 #define PIN_RECEIVER_CS LORA_CS
268 #define PIN_RECEIVER_IRQ LORA_IRQ
269 #define PIN_RECEIVER_GPIO LORA_BUSY
270 #define PIN_RECEIVER_RST LORA_RST
271
272#elif defined(ARDUINO_HELTEC_WIRELESS_STICK)
273 // Heltec Wireless Stick V2
274 #pragma message("ARDUINO_HELTEC_WIRELESS_STICK defined; using on-board transceiver")
275 #define USE_SX1276
276 // Use pinning for Heltec Wireless Stick or WiFi LoRa32 V2, respectively
277 #define PIN_RECEIVER_CS SS
278 #define PIN_RECEIVER_IRQ DIO0
279 #define PIN_RECEIVER_GPIO DIO1
280 #define PIN_RECEIVER_RST RST_LoRa
281
282#elif defined(HELTEC_WIRELESS_STICK_LITE_V3)
283 // Heltec Wireless Stick Lite V3
284 #pragma message("HELTEC_WIRELESS_STICK_LITE_V3 defined; using on-board transceiver")
285 #define USE_SX1262
286 #define LORA_CS 8
287 #define LORA_SCK 9
288 #define LORA_MOSI 10
289 #define LORA_MISO 11
290 #define PIN_RECEIVER_CS LORA_CS
291 #define PIN_RECEIVER_IRQ DIO0
292 #define PIN_RECEIVER_GPIO BUSY_LoRa
293 #define PIN_RECEIVER_RST RST_LoRa
294
295#elif defined(ARDUINO_HELTEC_WIRELESS_STICK_V3)
296 #pragma message("ARDUINO_HELTEC_WIRELESS_STICK_V3 defined; using on-board transceiver")
297 #define USE_SX1276
298 #define PIN_RECEIVER_CS SS
299 #define PIN_RECEIVER_IRQ DIO0
300 #define PIN_RECEIVER_GPIO BUSY_LoRa
301 #define PIN_RECEIVER_RST RST_LoRa
302
303#elif defined(ARDUINO_HELTEC_WIRELESS_PAPER)
304 #pragma message("ARDUINO_HELTEC_WIRELESS_PAPER defined; using on-board transceiver")
305 #define USE_SX1262
306 #define PIN_RECEIVER_CS SS
307 #define PIN_RECEIVER_IRQ DIO1
308 #define PIN_RECEIVER_GPIO BUSY_LoRa
309 #define PIN_RECEIVER_RST RST_LoRa
310
311#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2)
312 #pragma message("ARDUINO_HELTEC_WIFI_LORA_32_V2 defined; using on-board transceiver")
313 #define USE_SX1276
314 // Use pinning for Heltec Wireless Stick or WiFi LoRa32 V2, respectively
315 #define PIN_RECEIVER_CS SS
316 #define PIN_RECEIVER_IRQ DIO0
317 #define PIN_RECEIVER_GPIO DIO1
318 #define PIN_RECEIVER_RST RST_LoRa
319
320#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V3) || defined(ARDUINO_HELTEC_VISION_MASTER_T190)
321 #pragma message("ARDUINO_HELTEC_WIFI_LORA_32_V3 / ARDUINO_HELTEC_VISION_MASTER_T190 defined; using on-board transceiver")
322 #define USE_SX1262
323 #define PIN_RECEIVER_CS SS
324 #define PIN_RECEIVER_IRQ DIO0
325 #define PIN_RECEIVER_GPIO BUSY_LoRa
326 #define PIN_RECEIVER_RST RST_LoRa
327
328#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V4)
329 // Heltec WiFi LoRa 32(V4)
330 #pragma message("ARDUINO_HELTEC_WIFI_LORA_32_V4 defined; using on-board transceiver")
331 #define USE_SX1262
332 #define PIN_RECEIVER_CS SS
333 #define PIN_RECEIVER_IRQ DIO0
334 #define PIN_RECEIVER_GPIO BUSY_LoRa
335 #define PIN_RECEIVER_RST RST_LoRa
336
337#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
338 #pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32S2 defined; assuming RFM95W FeatherWing will be used")
339 #define USE_SX1276
340 // Use pinning for Adafruit Feather ESP32S2 with RFM95W "FeatherWing" ADA3232
341 #define PIN_RECEIVER_CS 6
342 #define PIN_RECEIVER_IRQ 5
343 #define PIN_RECEIVER_GPIO 11
344 #define PIN_RECEIVER_RST 9
345
346#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32_V2)
347 #pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32_V2 defined; assuming RFM95W FeatherWing will be used")
348 #define USE_SX1276
349 #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
350 // Use pinning for Adafruit Feather ESP32 with RFM95W "FeatherWing" ADA3232
351 #define PIN_RECEIVER_CS 14
352 #define PIN_RECEIVER_IRQ 32
353 #define PIN_RECEIVER_GPIO 33
354 #define PIN_RECEIVER_RST 27
355
356#elif defined(ARDUINO_FEATHER_ESP32) || defined(ARDUINO_THINGPULSE_EPULSE_FEATHER)
357 #pragma message("ARDUINO_FEATHER_ESP32/ARDUINO_THINGPULSE_EPULSE_FEATHER defined; assuming RFM95W FeatherWing will be used")
358 #define USE_SX1276
359 #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
360 // Use pinning for Adafruit Feather ESP32 with RFM95W "FeatherWing" ADA3232
361 #define PIN_RECEIVER_CS 14
362 #define PIN_RECEIVER_IRQ 32
363 #define PIN_RECEIVER_GPIO 33
364 #define PIN_RECEIVER_RST 27
365
366#elif defined(ARDUINO_M5STACK_CORE2)
367 #pragma message("ARDUINO_M5STACK_CORE2 defined; assuming M5Stack Module LoRa868 will be used")
368 #define USE_SX1276
369 #define PIN_RECEIVER_CS 33
370 #define PIN_RECEIVER_IRQ 36
371 #define PIN_RECEIVER_GPIO 35
372 #define PIN_RECEIVER_RST 26
373
374#elif defined(ARDUINO_ESP32S3_POWERFEATHER) || defined(ARDUINO_ESP32S3_POWERFEATHER_V2)
375 #pragma message("ARDUINO_ESP32S3_POWERFEATHER or ARDUINO_ESP32S3_POWERFEATHER_V2 defined; assuming RFM95W FeatherWing will be used")
376 #define USE_SX1276
377 #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
378 // Use pinning for ESP32-S3 PowerFeather with RFM95W "FeatherWing" ADA3232
379 #define PIN_RECEIVER_CS 15
380 #define PIN_RECEIVER_IRQ 16
381 #define PIN_RECEIVER_GPIO 18
382 #define PIN_RECEIVER_RST 45
383
384#elif defined(ARDUINO_XIAO_ESP32S3)
385 #pragma message("ARDUINO_XIAO_ESP32S3 defined; assuming Wio-SX1262 will be used")
386 #define USE_SX1262
387 // Use pinning for Seeed XIAO ESP32S3 with Wio-SX1262
388 #define PIN_RECEIVER_CS 41
389 #define PIN_RECEIVER_IRQ 39
390 #define PIN_RECEIVER_GPIO 40
391 #define PIN_RECEIVER_RST 42
392
393#elif defined(ARDUINO_ESP32S3_DEV)
394 #pragma message("ARDUINO_ESP32S3_DEV defined; this is a generic (i.e. non-specific) target")
395 #define USE_SX1276
396 //#define USE_SX1262
397 //#define USE_CC1101
398 //#define USE_LR1121
399 #pragma message("Cross check if the selected GPIO pins are really available on your board.")
400 #pragma message("Connect a radio module with a supported chip.")
401 #pragma message("Select the chip by setting the appropriate define.")
402 // Use pinning for generic ESP32 S3 board with unspecified radio module
403 #define PIN_RECEIVER_CS 10
404 #define PIN_RECEIVER_IRQ 21
405 #define PIN_RECEIVER_GPIO 8
406 #define PIN_RECEIVER_RST 9
407
408#elif defined(ARDUINO_MAKERGO_C3_SUPERMINI)
409 // Maker Go ESP32C3 Supermini
410 #pragma message("ARDUINO_MAKERGO_C3_SUPERMINI defined; assuming Heltec HT-RA62 (SX1262) will be used")
411 #define USE_SX1262
412 // Use pinning for Maker Go ESP32C3 Supermini with Heltec HT-RA62
413 #define PIN_RECEIVER_CS 7
414 #define PIN_RECEIVER_IRQ 1
415 #define PIN_RECEIVER_GPIO 2
416 #define PIN_RECEIVER_RST 3
417
418#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
419 #pragma message("ARDUINO_ADAFRUIT_FEATHER_RP2040 defined; assuming RFM95W FeatherWing will be used")
420 #define USE_SX1276
421 #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
422 // Use pinning for Adafruit Feather RP2040 with RFM95W "FeatherWing" ADA3232
423 #define PIN_RECEIVER_CS 7
424 #define PIN_RECEIVER_IRQ 8
425 #define PIN_RECEIVER_GPIO 10
426 #define PIN_RECEIVER_RST 11
427
428#elif defined(ARDUINO_DFROBOT_FIREBEETLE_ESP32)
429 //#define LORAWAN_NODE
430 #define DFROBOT_COVER_LORA
431
432 #if defined(DFROBOT_COVER_LORA)
433 #pragma message("ARDUINO_DFROBOT_FIREBEETLE_ESP32 & DFROBOT_COVER_LORA defined; assuming this is a FireBeetle ESP32 with FireBeetle Cover LoRa")
434 #define USE_SX1276
435 #pragma message("Required wiring: D2 to RESET, D3 to DIO0, D4 to CS, D5 to DIO1")
436 #define PIN_RECEIVER_CS 27 // D4
437 #define PIN_RECEIVER_IRQ 26 // D3
438 #define PIN_RECEIVER_GPIO 9 // D5
439 #define PIN_RECEIVER_RST 25 // D2
440
441 #elif defined(LORAWAN_NODE)
442 #pragma message("ARDUINO_DFROBOT_FIREBEETLE_ESP32 & LORAWAN_NODE defined; assuming this is the LoRaWAN_Node board (DFRobot Firebeetle32 + Adafruit RFM95W LoRa Radio)")
443 #define USE_SX1276
444
445 // Use pinning for LoRaWAN_Node (https://github.com/matthias-bs/LoRaWAN_Node)
446 #define PIN_RECEIVER_CS 14
447 #define PIN_RECEIVER_IRQ 4
448 #define PIN_RECEIVER_GPIO 16
449 #define PIN_RECEIVER_RST 12
450
451 #else
452 #pragma message("ARDUINO_DFROBOT_FIREBEETLE_ESP32 defined; if you use one of those boards, select either LORAWAN_NODE or FIREBEETLE_ESP32_COVER_LORA manually!")
453
454 #endif
455#elif defined(ESP32)
456 #pragma message("ESP32 defined; this is a generic (i.e. non-specific) target")
457 #pragma message("Cross check if the selected GPIO pins are really available on your board.")
458 #pragma message("Connect a radio module with a supported chip.")
459 #pragma message("Select the chip by setting the appropriate define.")
460 #define USE_SX1276
461 //#define USE_SX1262
462 //#define USE_CC1101
463 //#define USE_LR1121
464 // Generic pinning for ESP32 development boards
465 #define PIN_RECEIVER_CS 27
466 #define PIN_RECEIVER_IRQ 21
467 #define PIN_RECEIVER_GPIO 33
468 #define PIN_RECEIVER_RST 32
469
470 // When using SPI bus other than FSPI, e.g. HSPI, define the following
471 //#define LORA_SPI_BUS HSPI
472 //#define LORA_CS 48
473 //#define LORA_SCK 45
474 //#define LORA_MISO 46
475 //#define LORA_MOSI 47
476#elif defined(ESP8266)
477 #pragma message("ESP8266 defined; this is a generic (i.e. non-specific) target")
478 #pragma message("Cross check if the selected GPIO pins are really available on your board.")
479 #pragma message("Connect a radio module with a supported chip.")
480 #pragma message("Select the chip by setting the appropriate define.")
481 //#define USE_SX1276
482 //#define USE_SX1262
483 #define USE_CC1101
484 //#define USE_LR1121
485
486 // Generic pinning for ESP8266 development boards (e.g. LOLIN/WEMOS D1 mini)
487 #define PIN_RECEIVER_CS 15
488 #define PIN_RECEIVER_IRQ 4
489 #define PIN_RECEIVER_GPIO 5
490 #define PIN_RECEIVER_RST 2
491#endif
492
493#if defined(USE_CC1101)
494#define RADIO_CHIP CC1101
495#elif defined(USE_SX1276)
496#define RADIO_CHIP SX1276
497#elif defined(USE_SX1262)
498#define RADIO_CHIP SX1262
499#elif defined(USE_LR1121)
500#define RADIO_CHIP LR1121
501#else
502#pragma message("No radio chip selected!")
503#endif
504
505
506// ------------------------------------------------------------------------------------------------
507// --- Debug Logging Output ---
508// ------------------------------------------------------------------------------------------------
509// - ESP32:
510// CORE_DEBUG_LEVEL is set in Adruino IDE:
511// Tools->Core Debug Level: "<None>|<Error>|<Warning>|<Info>|<Debug>|<Verbose>"
512// https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-log.h
513//
514// - ESP8266:
515// DEBUG_ESP_PORT is set in Arduino IDE:
516// Tools->Debug port: "<None>|<Serial>|<Serial1>"
517//
518// - RP2040:
519// DEBUG_RP2040_PORT is set in Arduino IDE:
520// Tools->Debug port: "<Disabled>|<Serial>|<Serial1>|<Serial2>"
521//
522// Replacement for
523// https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-log.h
524// on ESP8266 and RP2040:
525#if defined(ESP8266) || defined(ARDUINO_ARCH_RP2040)
526 #define ARDUHAL_LOG_LEVEL_NONE 0
527 #define ARDUHAL_LOG_LEVEL_ERROR 1
528 #define ARDUHAL_LOG_LEVEL_WARN 2
529 #define ARDUHAL_LOG_LEVEL_INFO 3
530 #define ARDUHAL_LOG_LEVEL_DEBUG 4
531 #define ARDUHAL_LOG_LEVEL_VERBOSE 5
532
533 #if defined(ARDUINO_ARCH_RP2040) && defined(DEBUG_RP2040_PORT)
534 #define DEBUG_PORT DEBUG_RP2040_PORT
535 #elif defined(DEBUG_ESP_PORT)
536 #define DEBUG_PORT DEBUG_ESP_PORT
537 #endif
538
539 // Set desired level here if not defined elsewhere!
540 #if !defined(CORE_DEBUG_LEVEL)
541 #define CORE_DEBUG_LEVEL ARDUHAL_LOG_LEVEL_INFO
542 #endif
543
544 #if defined(DEBUG_PORT) && CORE_DEBUG_LEVEL > ARDUHAL_LOG_LEVEL_NONE
545 #define log_e(...) { DEBUG_PORT.printf("%s(), l.%d: ",__func__, __LINE__); DEBUG_PORT.printf(__VA_ARGS__); DEBUG_PORT.println(); }
546 #else
547 #define log_e(...) {}
548 #endif
549 #if defined(DEBUG_PORT) && CORE_DEBUG_LEVEL > ARDUHAL_LOG_LEVEL_ERROR
550 #define log_w(...) { DEBUG_PORT.printf("%s(), l.%d: ", __func__, __LINE__); DEBUG_PORT.printf(__VA_ARGS__); DEBUG_PORT.println(); }
551 #else
552 #define log_w(...) {}
553 #endif
554 #if defined(DEBUG_PORT) && CORE_DEBUG_LEVEL > ARDUHAL_LOG_LEVEL_WARN
555 #define log_i(...) { DEBUG_PORT.printf("%s(), l.%d: ", __func__, __LINE__); DEBUG_PORT.printf(__VA_ARGS__); DEBUG_PORT.println(); }
556 #else
557 #define log_i(...) {}
558 #endif
559 #if defined(DEBUG_PORT) && CORE_DEBUG_LEVEL > ARDUHAL_LOG_LEVEL_INFO
560 #define log_d(...) { DEBUG_PORT.printf("%s(), l.%d: ", __func__, __LINE__); DEBUG_PORT.printf(__VA_ARGS__); DEBUG_PORT.println(); }
561 #else
562 #define log_d(...) {}
563 #endif
564 #if defined(DEBUG_PORT) && CORE_DEBUG_LEVEL > ARDUHAL_LOG_LEVEL_DEBUG
565 #define log_v(...) { DEBUG_PORT.printf("%s(), l.%d: ", __func__, __LINE__); DEBUG_PORT.printf(__VA_ARGS__); DEBUG_PORT.println(); }
566 #else
567 #define log_v(...) {}
568 #endif
569
570#endif
571
572#define STR_HELPER(x) #x
573#define STR(x) STR_HELPER(x)
574#define RECEIVER_CHIP "[" STR(RADIO_CHIP) "]"
575#pragma message("Receiver chip: " RECEIVER_CHIP)
576#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) )
577
578#endif