From 5c49c5d608a7b88f1b5d5a02c7ed7e58d6536f92 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Tue, 7 Mar 2023 22:32:31 +0100 Subject: [PATCH 1/6] Pin mappings for some common ESP32 LoRaWAN boards --- .../arduino_lorawan_esp32_example.ino | 68 ++++++++++++++++--- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 1b16639..463a970 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -60,7 +60,7 @@ // 20220729 Created // 20230307 Changed cMyLoRaWAN to inherit from Arduino_LoRaWAN_network // instead of Arduino_LoRaWAN_ttn -// +// Added Pin mappings for some common ESP32 LoRaWAN boards // // Notes: // - After a successful transmission, the controller can go into deep sleep @@ -120,14 +120,64 @@ // LoRa_Serialization #include -// Pin mapping for ESP32 -// SPI2 is used on ESP32 per default! (e.g. see https://github.com/espressif/arduino-esp32/tree/master/variants/doitESP32devkitV1) -#define PIN_LMIC_NSS 14 -#define PIN_LMIC_RST 12 -#define PIN_LMIC_DIO0 4 -#define PIN_LMIC_DIO1 16 -#define PIN_LMIC_DIO2 17 - +// Pin mappings for some common ESP32 LoRaWAN boards. +// The ARDUINO_* defines are set by selecting the appropriate board (and borad variant, if applicable) in the Arduino IDE. +// The default SPI port of the specific board will be used. +#if defined(ARDUINO_TTGO_LoRa32_V1) + // https://github.com/espressif/arduino-esp32/blob/master/variants/ttgo-lora32-v1/pins_arduino.h + // http://www.lilygo.cn/prod_view.aspx?TypeId=50003&Id=1130&FId=t3:50003:3 + // https://github.com/Xinyuan-LilyGo/TTGO-LoRa-Series + // https://github.com/LilyGO/TTGO-LORA32/blob/master/schematic1in6.pdf + #define PIN_LMIC_NSS LORA_CS + #define PIN_LMIC_RST LORA_RST + #define PIN_LMIC_DIO0 LORA_IRQ + #define PIN_LMIC_DIO1 33 + #define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN + +#elif defined(ARDUINO_TTGO_LoRa32_V2) + // https://github.com/espressif/arduino-esp32/blob/master/variants/ttgo-lora32-v2/pins_arduino.h + #define PIN_LMIC_NSS LORA_CS + #define PIN_LMIC_RST LORA_RST + #define PIN_LMIC_DIO0 LORA_IRQ + #define PIN_LMIC_DIO1 33 + #define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN + #pragma message("LoRa DIO1 must be wired to GPIO33 manually!") + +#elif defined(ARDUINO_TTGO_LoRa32_v21new) + // https://github.com/espressif/arduino-esp32/blob/master/variants/ttgo-lora32-v21new/pins_arduino.h + #define PIN_LMIC_NSS LORA_CS + #define PIN_LMIC_RST LORA_RST + #define PIN_LMIC_DIO0 LORA_IRQ + #define PIN_LMIC_DIO1 LORA_D1 + #define PIN_LMIC_DIO2 LORA_D2 + +#elif defined(ARDUINO_heltec_wireless_stick) + // https://github.com/espressif/arduino-esp32/blob/master/variants/heltec_wireless_stick/pins_arduino.h + #define PIN_LMIC_NSS SS + #define PIN_LMIC_RST RST_LoRa + #define PIN_LMIC_DIO0 DIO0 + #define PIN_LMIC_DIO1 DIO1 + #define PIN_LMIC_DIO2 DIO2 + +#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) + #define PIN_LMIC_NSS 6 + #define PIN_LMIC_RST 9 + #define PIN_LMIC_DIO0 5 + #define PIN_LMIC_DIO1 11 + #define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN + #pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32S2 defined; assuming RFM95W FeatherWing will be used") + #pragma message("Required wiring: E to IRQ, D to CS, C to RST, A to DI01") + #pragma message("BLE is not available!") + +#elif defined(ARDUINO_FEATHER_ESP32) + #define PIN_LMIC_NSS 14 + #define PIN_LMIC_RST 27 + #define PIN_LMIC_DIO0 32 + #define PIN_LMIC_DIO1 33 + #define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN + #pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32 defined; assuming RFM95W FeatherWing will be used") + #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS") +#endif // Uplink message payload size (calculate from assignments to 'encoder' object) const uint8_t PAYLOAD_SIZE = 8; From 3e0effe8ecc5ee291fa40e1076e0307399cf1d4a Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Wed, 8 Mar 2023 17:22:38 +0100 Subject: [PATCH 2/6] Update arduino_lorawan_esp32_example.ino --- .../arduino_lorawan_esp32_example.ino | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index 463a970..a70db96 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -177,6 +177,17 @@ #define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN #pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32 defined; assuming RFM95W FeatherWing will be used") #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS") + +#else + // LoRaWAN_Node board + // https://github.com/matthias-bs/LoRaWAN_Node + // (or anything else) + #define PIN_LMIC_NSS 14 + #define PIN_LMIC_RST 12 + #define PIN_LMIC_DIO0 4 + #define PIN_LMIC_DIO1 16 + #define PIN_LMIC_DIO2 17 + #endif // Uplink message payload size (calculate from assignments to 'encoder' object) From abf084d478822604b88519fd9b97c6a368b9b3d0 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 08:00:33 +0100 Subject: [PATCH 3/6] Fixed debug output --- .../arduino_lorawan_esp32_example.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino index a70db96..1f78803 100644 --- a/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino +++ b/examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino @@ -840,10 +840,10 @@ cSensor::doUplink(void) { battery_ok = true; // sensor battery status DEBUG_PRINTF("--- Uplink Data ---\n"); - DEBUG_PRINTF("Air Temperature: % 3.1f °C\n", weatherSensor.temp_c); - DEBUG_PRINTF("Humidity: %2d %%\n", weatherSensor.humidity); - DEBUG_PRINTF("Supply Voltage: %4d mV\n", supply_voltage); - DEBUG_PRINTF("Battery Voltage: %4d mV\n", battery_voltage); + DEBUG_PRINTF("Air Temperature: % 3.1f °C\n", temperature_deg_c); + DEBUG_PRINTF("Humidity: %2d %%\n", humidity_percent); + DEBUG_PRINTF("Supply Voltage: %4d mV\n", supply_voltage_v); + DEBUG_PRINTF("Battery Voltage: %4d mV\n", battery_voltage_v); DEBUG_PRINTF("Status:\n"); DEBUG_PRINTF(" battery_ok: %d\n", battery_ok); DEBUG_PRINTF(" data_ok: %d\n", data_ok); From d4c1faf6df386eeb2caffd55cd9a85836cd80377 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 17:45:40 +0100 Subject: [PATCH 4/6] Changed ARDUINO_LORAWAN_VERSION to v0.10.0-pre1 --- src/Arduino_LoRaWAN.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Arduino_LoRaWAN.h b/src/Arduino_LoRaWAN.h index 9d42d25..3ef11db 100644 --- a/src/Arduino_LoRaWAN.h +++ b/src/Arduino_LoRaWAN.h @@ -34,7 +34,7 @@ Copyright notice: /// \ref ARDUINO_LORAWAN_VERSION_COMPARE_LT() to compare relative versions. /// #define ARDUINO_LORAWAN_VERSION \ - ARDUINO_LORAWAN_VERSION_CALC(0, 9, 2, 0) /* v0.9.2 */ + ARDUINO_LORAWAN_VERSION_CALC(0, 10, 0, 1) /* v0.10.0-pre1 */ #define ARDUINO_LORAWAN_VERSION_GET_MAJOR(v) \ (((v) >> 24u) & 0xFFu) From 403ecccb4496d59108fe5176c5b19cc1d60208e8 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 17:46:31 +0100 Subject: [PATCH 5/6] Update library.properties --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 461d64a..f871188 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=MCCI Arduino LoRaWAN Library -version=0.9.2 +version=0.10.0-pre1 author=Terry Moore, ChaeHee Won maintainer=Terry Moore sentence=High-level library for LoRaWAN-based Arduino end-devices. From 19691e34a11e7a33186c13eb30683c5f3eeaa76d Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Thu, 9 Mar 2023 17:52:39 +0100 Subject: [PATCH 6/6] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 09a1ab2..64b3cf3 100644 --- a/README.md +++ b/README.md @@ -428,6 +428,10 @@ Much more elaborate uses can be found in the MCCI [Catena-Arduino-Platform](http ## Release History +- v0.10.0-pre1 includes the following changes. + + - examples/arduino_lorawan_esp32_example: @matthias-bs Added pin mappings for some common ESP32 LoRaWAN boards + - v0.9.2 includes the following changes. - Fix `-Wunused-parameter` warnings from GCC. ([#196](https://github.com/mcci-catena/arduino-lorawan/issues/196)). This is v0.9.2-pre3.