Custom pin mapping for helium.ino example (LMiC v4.0.0)

i’m trying to set the pin mapping for a custom pro mini board that isn’t supported within the Arduino_lmic_hal_boards library. I’ve previously been able to get my node to work using the ttn_otaa and ttn_abp sketches, as I just change the pin numbers in the array, but the helium.ino example sketch uses the inbuilt mapping. The example says:

// If your board isn't supported, declare an lmic_pinmap object as static
// or global, and set pPimMap to that pointer.

Can someone explain what this means and what is happening in the background? How can I take my custom pinmapping:

 // Pin mapping
const lmic_pinmap lmic_pins = {
    .nss = 6,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 5,
    .dio = {2, 3, 4},

and point it to pPinMap within the sketch? Or is there a way to directly modify the pins within the library or add a custom board type?

There is another difference between examples further down in void(setup) where instead of calling:


like in the ttn_otaa example, the helium.ino example calls


I suppose if I successfully point pPinMap to the custom mapping above, then this will work.

Any suggestions much appreciated. I don’t yet have a great understanding of the LMiC inner workings so am stuck with how to proceed from here.


1 Like

Hey there,

Pointers point to a place in memory.

So once you’ve defined your boards pin map in lmic_pins you want to send its memory address to the pointer, you do this by putting an & in front of the variable name.

my code looks like this

    // Pin mapping
    //  We use the built-in mapping -- see src/hal/getpinmap_thisboard.cpp
    // If your board isn't supported, declare an lmic_pinmap object as static
    // or global, and set pPimMap to that pointer.

    lmic_pinmap lmic_pins = {
    .nss = 15,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = LMIC_UNUSED_PIN,
    .dio = {5, 4, LMIC_UNUSED_PIN},
    // optional: set polarity of rxtx pin.
    .rxtx_rx_active = 0,
    // optional: set RSSI cal for listen-before-talk
    // this value is in dB, and is added to RSSI
    // measured prior to decision.
    // Must include noise guardband! Ignored in US,
    // EU, IN, other markets where LBT is not required.
    .rssi_cal = 10,
    // optional: override LMIC_SPI_FREQ if non-zero
    .spi_freq = 1000000,

    const lmic_pinmap *pPinMap = &lmic_pins;

    // don't die mysteriously; die noisily.
    if (pPinMap == nullptr) {
        pinMode(LED_BUILTIN, OUTPUT);
        for (;;) {
            // flash lights, sleep.
            for (int i = 0; i < 5; ++i) {
                digitalWrite(LED_BUILTIN, 1);
                digitalWrite(LED_BUILTIN, 0);
            Serial.println(F("board not known to library; add pinmap or update getconfig_thisboard.cpp"));
1 Like

thanks a lot for this! problem solved!