|
60 | 60 | // 20220729 Created |
61 | 61 | // 20230307 Changed cMyLoRaWAN to inherit from Arduino_LoRaWAN_network |
62 | 62 | // instead of Arduino_LoRaWAN_ttn |
63 | | -// |
| 63 | +// Added Pin mappings for some common ESP32 LoRaWAN boards |
64 | 64 | // |
65 | 65 | // Notes: |
66 | 66 | // - After a successful transmission, the controller can go into deep sleep |
|
120 | 120 | // LoRa_Serialization |
121 | 121 | #include <LoraMessage.h> |
122 | 122 |
|
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 |
130 | 190 |
|
| 191 | +#endif |
131 | 192 |
|
132 | 193 | // Uplink message payload size (calculate from assignments to 'encoder' object) |
133 | 194 | const uint8_t PAYLOAD_SIZE = 8; |
@@ -779,10 +840,10 @@ cSensor::doUplink(void) { |
779 | 840 | battery_ok = true; // sensor battery status |
780 | 841 |
|
781 | 842 | 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); |
786 | 847 | DEBUG_PRINTF("Status:\n"); |
787 | 848 | DEBUG_PRINTF(" battery_ok: %d\n", battery_ok); |
788 | 849 | DEBUG_PRINTF(" data_ok: %d\n", data_ok); |
|
0 commit comments