Skip to content

Commit 97036fa

Browse files
authored
Merge pull request #214 from matthias-bs/esp32-example-pinconfig
Added pin mappings for some common ESP32 LoRaWAN boards
2 parents 13366e9 + 19691e3 commit 97036fa

File tree

4 files changed

+79
-14
lines changed

4 files changed

+79
-14
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ Much more elaborate uses can be found in the MCCI [Catena-Arduino-Platform](http
428428
429429
## Release History
430430
431+
- v0.10.0-pre1 includes the following changes.
432+
433+
- examples/arduino_lorawan_esp32_example: @matthias-bs Added pin mappings for some common ESP32 LoRaWAN boards
434+
431435
- v0.9.2 includes the following changes.
432436
433437
- Fix `-Wunused-parameter` warnings from GCC. ([#196](https://github.com/mcci-catena/arduino-lorawan/issues/196)). This is v0.9.2-pre3.

examples/arduino_lorawan_esp32_example/arduino_lorawan_esp32_example.ino

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
// 20220729 Created
6161
// 20230307 Changed cMyLoRaWAN to inherit from Arduino_LoRaWAN_network
6262
// instead of Arduino_LoRaWAN_ttn
63-
//
63+
// Added Pin mappings for some common ESP32 LoRaWAN boards
6464
//
6565
// Notes:
6666
// - After a successful transmission, the controller can go into deep sleep
@@ -120,14 +120,75 @@
120120
// LoRa_Serialization
121121
#include <LoraMessage.h>
122122

123-
// Pin mapping for ESP32
124-
// SPI2 is used on ESP32 per default! (e.g. see https://github.com/espressif/arduino-esp32/tree/master/variants/doitESP32devkitV1)
125-
#define PIN_LMIC_NSS 14
126-
#define PIN_LMIC_RST 12
127-
#define PIN_LMIC_DIO0 4
128-
#define PIN_LMIC_DIO1 16
129-
#define PIN_LMIC_DIO2 17
123+
// Pin mappings for some common ESP32 LoRaWAN boards.
124+
// The ARDUINO_* defines are set by selecting the appropriate board (and borad variant, if applicable) in the Arduino IDE.
125+
// The default SPI port of the specific board will be used.
126+
#if defined(ARDUINO_TTGO_LoRa32_V1)
127+
// https://github.com/espressif/arduino-esp32/blob/master/variants/ttgo-lora32-v1/pins_arduino.h
128+
// http://www.lilygo.cn/prod_view.aspx?TypeId=50003&Id=1130&FId=t3:50003:3
129+
// https://github.com/Xinyuan-LilyGo/TTGO-LoRa-Series
130+
// https://github.com/LilyGO/TTGO-LORA32/blob/master/schematic1in6.pdf
131+
#define PIN_LMIC_NSS LORA_CS
132+
#define PIN_LMIC_RST LORA_RST
133+
#define PIN_LMIC_DIO0 LORA_IRQ
134+
#define PIN_LMIC_DIO1 33
135+
#define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN
136+
137+
#elif defined(ARDUINO_TTGO_LoRa32_V2)
138+
// https://github.com/espressif/arduino-esp32/blob/master/variants/ttgo-lora32-v2/pins_arduino.h
139+
#define PIN_LMIC_NSS LORA_CS
140+
#define PIN_LMIC_RST LORA_RST
141+
#define PIN_LMIC_DIO0 LORA_IRQ
142+
#define PIN_LMIC_DIO1 33
143+
#define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN
144+
#pragma message("LoRa DIO1 must be wired to GPIO33 manually!")
145+
146+
#elif defined(ARDUINO_TTGO_LoRa32_v21new)
147+
// https://github.com/espressif/arduino-esp32/blob/master/variants/ttgo-lora32-v21new/pins_arduino.h
148+
#define PIN_LMIC_NSS LORA_CS
149+
#define PIN_LMIC_RST LORA_RST
150+
#define PIN_LMIC_DIO0 LORA_IRQ
151+
#define PIN_LMIC_DIO1 LORA_D1
152+
#define PIN_LMIC_DIO2 LORA_D2
153+
154+
#elif defined(ARDUINO_heltec_wireless_stick)
155+
// https://github.com/espressif/arduino-esp32/blob/master/variants/heltec_wireless_stick/pins_arduino.h
156+
#define PIN_LMIC_NSS SS
157+
#define PIN_LMIC_RST RST_LoRa
158+
#define PIN_LMIC_DIO0 DIO0
159+
#define PIN_LMIC_DIO1 DIO1
160+
#define PIN_LMIC_DIO2 DIO2
161+
162+
#elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
163+
#define PIN_LMIC_NSS 6
164+
#define PIN_LMIC_RST 9
165+
#define PIN_LMIC_DIO0 5
166+
#define PIN_LMIC_DIO1 11
167+
#define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN
168+
#pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32S2 defined; assuming RFM95W FeatherWing will be used")
169+
#pragma message("Required wiring: E to IRQ, D to CS, C to RST, A to DI01")
170+
#pragma message("BLE is not available!")
171+
172+
#elif defined(ARDUINO_FEATHER_ESP32)
173+
#define PIN_LMIC_NSS 14
174+
#define PIN_LMIC_RST 27
175+
#define PIN_LMIC_DIO0 32
176+
#define PIN_LMIC_DIO1 33
177+
#define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN
178+
#pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32 defined; assuming RFM95W FeatherWing will be used")
179+
#pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS")
180+
181+
#else
182+
// LoRaWAN_Node board
183+
// https://github.com/matthias-bs/LoRaWAN_Node
184+
// (or anything else)
185+
#define PIN_LMIC_NSS 14
186+
#define PIN_LMIC_RST 12
187+
#define PIN_LMIC_DIO0 4
188+
#define PIN_LMIC_DIO1 16
189+
#define PIN_LMIC_DIO2 17
130190

191+
#endif
131192

132193
// Uplink message payload size (calculate from assignments to 'encoder' object)
133194
const uint8_t PAYLOAD_SIZE = 8;
@@ -779,10 +840,10 @@ cSensor::doUplink(void) {
779840
battery_ok = true; // sensor battery status
780841

781842
DEBUG_PRINTF("--- Uplink Data ---\n");
782-
DEBUG_PRINTF("Air Temperature: % 3.1f °C\n", weatherSensor.temp_c);
783-
DEBUG_PRINTF("Humidity: %2d %%\n", weatherSensor.humidity);
784-
DEBUG_PRINTF("Supply Voltage: %4d mV\n", supply_voltage);
785-
DEBUG_PRINTF("Battery Voltage: %4d mV\n", battery_voltage);
843+
DEBUG_PRINTF("Air Temperature: % 3.1f °C\n", temperature_deg_c);
844+
DEBUG_PRINTF("Humidity: %2d %%\n", humidity_percent);
845+
DEBUG_PRINTF("Supply Voltage: %4d mV\n", supply_voltage_v);
846+
DEBUG_PRINTF("Battery Voltage: %4d mV\n", battery_voltage_v);
786847
DEBUG_PRINTF("Status:\n");
787848
DEBUG_PRINTF(" battery_ok: %d\n", battery_ok);
788849
DEBUG_PRINTF(" data_ok: %d\n", data_ok);

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=MCCI Arduino LoRaWAN Library
2-
version=0.9.2
2+
version=0.10.0-pre1
33
author=Terry Moore, ChaeHee Won
44
maintainer=Terry Moore <tmm@mcci.com>
55
sentence=High-level library for LoRaWAN-based Arduino end-devices.

src/Arduino_LoRaWAN.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Copyright notice:
3434
/// \ref ARDUINO_LORAWAN_VERSION_COMPARE_LT() to compare relative versions.
3535
///
3636
#define ARDUINO_LORAWAN_VERSION \
37-
ARDUINO_LORAWAN_VERSION_CALC(0, 9, 2, 0) /* v0.9.2 */
37+
ARDUINO_LORAWAN_VERSION_CALC(0, 10, 0, 1) /* v0.10.0-pre1 */
3838

3939
#define ARDUINO_LORAWAN_VERSION_GET_MAJOR(v) \
4040
(((v) >> 24u) & 0xFFu)

0 commit comments

Comments
 (0)