1 week, 4 days ago.

NUCLEO F411RE and LoRa not working

I'm currently trying to get LoRaWAN working but after a few days of trying I still can't. I'm using the NUCLEO F411RE paired with a HOPE RFM95 chip (https://wiki.dragino.com/index.php?title=Lora_Shield - V1.4) shield plugged directly on top into the arduino pins.

I've looked into the SX1276 LoRa drivers (https://github.com/ARMmbed/mbed-semtech-lora-rf-drivers) and know they support the RFM95 chip (compared to the original semtec drivers). I also got rid of all the LoRaWAN stuff and started using just the SX1276_LoRaRadio driver to purely send or receive arbitrary data.

Have tested to shields do work with arduino uno's using this lib https://github.com/sandeepmistry/arduino-LoRa (which is also acting as my receiver).

Have checked and matched the pins against this arduino lib over and over again too. Any suggestions?

EDIT: Also I don't get any interrupt callbacks like tx_done or tx_error. Starting to think this could be a hardware problem with my particular stm board.

main.cpp

#include "mbed.h"
#include "SX1276_LoRaRadio.h"

PinName LORA_SPI_MOSI = D11;
PinName LORA_SPI_MISO = D12;
PinName LORA_SPI_SCLK = D13;
PinName LORA_CS = D10;
PinName LORA_RESET = D9;
PinName LORA_DIO0 = D2;
PinName LORA_DIO1 = D6;
PinName LORA_DIO2 = D7;
PinName LORA_DIO3 = D3;
PinName LORA_DIO4 = NC;
PinName LORA_DIO5 = NC;
PinName LORA_RF_SWITCH_CTL1 = NC;
PinName LORA_RF_SWITCH_CTL2 = NC;
PinName LORA_TXCTL = NC;
PinName LORA_RXCTL = NC;
PinName LORA_ANT_SWITCH = NC;
PinName LORA_PWR_AMP_CTL = NC;
PinName LORA_TCXO = NC;

SX1276_LoRaRadio lora(
    LORA_SPI_MOSI,
    LORA_SPI_MISO,
    LORA_SPI_SCLK,
    LORA_CS,
    LORA_RESET,
    LORA_DIO0,
    LORA_DIO1,
    LORA_DIO2,
    LORA_DIO3,
    LORA_DIO4,
    LORA_DIO5,
    LORA_RF_SWITCH_CTL1,
    LORA_RF_SWITCH_CTL2,
    LORA_TXCTL,
    LORA_RXCTL,
    LORA_ANT_SWITCH,
    LORA_PWR_AMP_CTL,
    LORA_TCXO
);


void tx_done(){
    printf("TX_DONE\r\n");
}

void rx_done(const uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr){
    printf("RX_DONE\r\n");
}

void rx_error(){
    printf("RX_ERROR\r\n");
}

void tx_timeout(){
    printf("TX_TIMEOUT\r\n");
}

void rx_timeout(){
    printf("RX_TIMEOUT\r\n");
}

#define payload_len 1

#define frequency 915E6
#define bandwidth 1 //LoRa: [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
#define datarate 7 // SPREADING FACTOR //LoRa: [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096  chips]
#define coderate 1 //LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
#define bandwidth_afc 0
#define preamble_len 8
#define symb_timeout 0
#define fix_len true
#define crc_on false
#define freq_hop_on false
#define hop_period 0
#define iq_inverted false
#define rx_continuous true

#define power 17
#define fdev 0
#define timeout 100000

int main()
{

    radio_events_t lora_events;


    printf("-- reset --\r\n");
    lora_events.tx_done = callback(&tx_done);
    lora_events.rx_done = callback(&rx_done);
    lora_events.rx_error = callback(rx_error);
    lora_events.tx_timeout = callback(&tx_timeout);
    lora_events.rx_timeout = callback(&rx_timeout);

    printf(" - init lora\r\n");
    lora.lock();

    lora.init_radio(&lora_events);
    lora.set_channel(frequency);
    lora.set_public_network(false);

    lora.set_tx_config(modem_type::MODEM_LORA, 
                        power, 
                        fdev,
                        bandwidth, 
                        datarate,
                        coderate, 
                        preamble_len,
                        fix_len, 
                        crc_on, 
                        freq_hop_on,
                        hop_period, 
                        iq_inverted, 
                        timeout
    );

    lora.unlock();
    printf(" - ok\r\n");

    uint8_t p[payload_len];
    for(int i = 0; i < payload_len; i++){
        p[i] = 0;
    }
    while(1){
        printf("!\r\n");
        lora.send(p, payload_len);
        wait(2);
    }
}
Comment on this question
Be the first to answer this question.

You need to log in to post a question