Commit a3057742 authored by Eric Duminil's avatar Eric Duminil
Browse files

Automatic pin mapping for LoRa

parent 207a7d38
...@@ -9,9 +9,6 @@ namespace config { ...@@ -9,9 +9,6 @@ namespace config {
static const u1_t PROGMEM DEVEUI[8] = LORAWAN_DEVICE_EUI; static const u1_t PROGMEM DEVEUI[8] = LORAWAN_DEVICE_EUI;
static const u1_t PROGMEM APPKEY[16] = LORAWAN_APPLICATION_KEY; static const u1_t PROGMEM APPKEY[16] = LORAWAN_APPLICATION_KEY;
} }
// Pin mapping for TTGO LoRa32 V1
// More info : https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436
const lmic_pinmap lmic_pins = { .nss = 18, .rxtx = LMIC_UNUSED_PIN, .rst = 14, .dio = { 26, 33, 32 } };
// Payloads will be automatically sent via MQTT by TheThingsNetwork, and can be seen with: // Payloads will be automatically sent via MQTT by TheThingsNetwork, and can be seen with:
// mosquitto_sub -h eu.thethings.network -t '+/devices/+/up' -u 'APPLICATION-NAME' -P 'ttn-account-v2.4xxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxx' -v // mosquitto_sub -h eu.thethings.network -t '+/devices/+/up' -u 'APPLICATION-NAME' -P 'ttn-account-v2.4xxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxx' -v
...@@ -167,8 +164,11 @@ namespace lorawan { ...@@ -167,8 +164,11 @@ namespace lorawan {
void initialize() { void initialize() {
Serial.println(F("Starting LoRaWAN.")); Serial.println(F("Starting LoRaWAN."));
// More info about pin mapping : https://github.com/mcci-catena/arduino-lmic#pin-mapping
// Has been tested successfully with ESP32 TTGO LoRa32 V1, and might work with other ESP32+LoRa boards.
const lmic_pinmap *pPinMap = Arduino_LMIC::GetPinmap_ThisBoard();
// LMIC init. // LMIC init.
os_init(); os_init_ex(pPinMap);
// Reset the MAC state. Session and pending data transfers will be discarded. // Reset the MAC state. Session and pending data transfers will be discarded.
LMIC_reset(); LMIC_reset();
// Join, but don't send anything yet. // Join, but don't send anything yet.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// Tested successfully with v3.2.0 and connected to a thethingsnetwork.org app. // Tested successfully with v3.2.0 and connected to a thethingsnetwork.org app.
#include <lmic.h> #include <lmic.h>
#include <hal/hal.h> #include <hal/hal.h>
#include <arduino_lmic_hal_boards.h>
#include <SPI.h> #include <SPI.h>
typedef uint8_t u1_t; typedef uint8_t u1_t;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment