Olimex MOD-LoRa868

Hi! First time here!

I am trying to get a lora module from olimex to work with arduino-lmic, but I am having hard time doing so.

Pinout seems to be ok - no spi errors, correct chip is set in config file - CFG_sx1276_radio 1, log output seems to be sending data and also spectrum analyzer is showing some data. When I use the same code on Lora32u4, everything is working as expected.

For me it feels like on olimex board there is some kind of setting already set that prevents it from using bigger spread and thus gateway cannot be reached. I am using OTAA activation.

Do you have any ideas where to look?

So after quite a lot of fiddling I found that issue was in power policy. If I create my own HalConfig class and override getTxPowerPolicy by returning RFO instead of PA_BOOST it starts to work - but to get here that was a journey.
I must say I have no idea what exactly those are, but there is some mention in comments about: “HopeRF needs (and previous versions of this library always chose) PA_BOOST mode. So that’s our default.” and olimex documentation mentions this: "Note that the Chinese clones of SX1276 like RFM95W have bug in low data rate optimization flag settings and high power mode, due to the popularity of these clones all default Arduino libraries for LoRa has wrong setup to work around the RFM95W bug. "

If anyone else comes across a weird issue that everything should work, but its not working, try this:

// HalConfig.h

#ifndef _HalConfig_h_
#define _HalConfig_h_

#include <arduino_lmic_hal_configuration.h>

class MyHalConfig_t : public Arduino_LMIC::HalConfiguration_t {

public:
    MyHalConfig_t();
    virtual TxPowerPolicy_t getTxPowerPolicy (TxPowerPolicy_t policy, int8_t requestedPower, uint32_t frequency) override;
};

#endif
// HalConfig.cpp

#include <arduino_lmic_hal_configuration.h>
#include "HalConfig.h"
#include "Boards.h"

#define LMIC_FORCE_POWER_POLICY Arduino_LMIC::HalConfiguration_t::TxPowerPolicy_t::RFO

// Init
MyHalConfig_t::MyHalConfig_t(){};

// Override getTxPowerPolicy
Arduino_LMIC::HalConfiguration_t::TxPowerPolicy_t MyHalConfig_t::getTxPowerPolicy (
    Arduino_LMIC::HalConfiguration_t::TxPowerPolicy_t policy,
    int8_t requestedPower,
    uint32_t frequency
) {
    LMIC_API_PARAMETER(policy);
    LMIC_API_PARAMETER(requestedPower);
    LMIC_API_PARAMETER(frequency);

    #ifdef LMIC_FORCE_POWER_POLICY
        return LMIC_FORCE_POWER_POLICY;
    #endif

    // default: use PA_BOOST exclusively
    return Arduino_LMIC::HalConfiguration_t::TxPowerPolicy_t::PA_BOOST;
};

And the while setting up lmic pins:

#include "HalConfig.h"
static MyHalConfig_t myHalConfig{};

// Pins - loaded from Boards.h
const lmic_pinmap lmic_pins = {
    .nss = PIN_NSS,
    .rxtx = PIN_RXTX,
    .rst = PIN_RST,
    .dio = {PIN_DIO0, PIN_DIO1, PIN_DIO2},
    .rxtx_rx_active = PIN_RX_ACTIVE,
    .rssi_cal = PIN_RSSI_CAL,
    .spi_freq = PIN_SPI_FREQ,
    .pConfig = &myHalConfig
};