Problem with NUCLEO-LRWA1 / IDE Arduino

Hello,
We are a group of students who carry out a supervision project.
We use a NUCLEO 64 F401RE card (STMicroelectronics) and a NUCLEO-LRWAN1 card (STMicroelectronics).
The goal is to set up communication via the LORA wireless network.
However, we have a problem with the NUCLEO-LRWAN1 card.
The program compiles correctly, but at runtime we get the following message in the serial monitor: "Lora module not ready"
We are unable to figure out how to resolve this persistent problem.
We used the sample programs first and tried modify them using other programs offered on the forum (without any success).
Thank you in advance for your help.

Code :

/*
  LoRaOTAA.ino

  Establish a connection on a LoRaWAN network in OTAA mode.
  Send a join request and wait the join accept.
  Exchange data to/from the network.

  Extract of the LoRaWAN standard:

    For Over The Air Activation, end-devices must follow a join procedure prior to participating in
    data exchanges with the network server. An end-device has to go through a new join
    procedure every time it has lost the session context information.

    The join procedure requires the end-device to be personalized with the following information
    before its starts the join procedure: a globally unique end-device identifier (DevEUI), the
    application identifier (AppEUI), and an AES-128 key (AppKey).

  USI will burn the unique IEEE EUI64 at factory.

*/
#include "LoRaWANNode.h"

#define FRAME_DELAY 300000  // in ms. Every 5 minutes by default.

// Serial port use to communicate with the USI shield.
// By default, use D0 (Rx) and D1(Tx).
// For Nucleo64, see "Known limitations" chapter in the README.md
HardwareSerial SerialLora(PA2, PA3);       //(PC10, PC11); // PA2 PA3

// AppKey and AppEUI.
const char appKey[] = "78FCD341D4xxxxxxxxxxxxxxxxE3959B0";
const char appEUI[] = "70B3xxxxxxxx77C";

// Data send
char frameTx[] = "Hello world!";

void setup()
{
  Serial.begin(115200);
  SerialLora.begin(115200);
  Serial.println("-- LoRaWAN OTAA sketch --");

  // Enable the USI module and set the radio band.
  while(!loraNode.begin(&SerialLora, LORA_BAND_EU_868)) {
    Serial.println("Lora module not ready");
    delay(1000);
  }
  
  // Send a join request and wait the join accept
  while(!loraNode.joinOTAA(appKey, appEUI)) {
    Serial.println("joinOTAA failed!!");
    delay(1000);
  }

  Serial.println("Lora module ready, join accepted.\n");

  String str = "Device EUI: ";
  loraNode.getDevEUI(&str);
  Serial.println(str);
  str = "Application key: ";
  loraNode.getAppKey(&str);
  Serial.println(str);
  str = "Application EUI: ";
  loraNode.getAppEUI(&str);
  Serial.println(str);
}

void loop()
{
  receive();
  transmit();
  delay(FRAME_DELAY);
}

void receive(void) {
  uint8_t frameRx[64];
  uint8_t len;
  uint8_t port;

  // Check if data received from a gateway
  if(loraNode.receiveFrame(frameRx, &len, &port)) {
    uint8_t n = 0;
    Serial.print("frame received: 0x");
    while(len > 0) {
      Serial.print(frameRx[n], HEX);
      Serial.print(',');
      len--;
      n++;
    }
    Serial.print(" on port "); Serial.println(port);
  } else {
    Serial.println("No data");
  }
}

void transmit(void) {
  // Send unconfirmed data to a gateway (port 1 by default)
  int status = loraNode.sendFrame(frameTx, sizeof(frameTx), UNCONFIRMED);
  if(status == LORA_SEND_ERROR) {
    Serial.println("Send frame failed!!!");
  } else if(status == LORA_SEND_DELAYED) {
    Serial.println("Module busy or duty cycle");
  } else {
    Serial.println("Frame sent");
  }
}

never used the Nucleo but are you sure of your pins there

HardwareSerial SerialLora(PA2, PA3);       //(PC10, PC11); // PA2 PA3

Same with experience, but I doubt that SoftwareSerial will work at 115200 bps.

it's hardware serial that's being used. I assumed you can reassign extra ports

From where did you get this code and are these known limitations somehow relevant?
I guess you are using the stm32duino official core.

Hello,
We use the example from the library : STM32duino I-NUCLEO-LRWAN1
The LoRaWANOTAA program: send / receive data in OTAA mode.

For data transmission, we used pins D0 (RX) and D1 (TX) of the card Nucleo 64:
HardwareSerial SerialLora(PA2, PA3);

image

For PA2 and PA3, it looks like you should use hardwareSerial2 instead of hardwareSerial .

Edit:
but also look for another pinout which shows all the pin labels for all the pins. You may need that serial port for the programmer and should look for other ones.

Maybe this is similar: NUCLEO-F446RE | Mbed

As far as I know the nucleo boards use the embedded ST-Link for programming, so all serial lines should be free for use.

That may be so. However, there could also be other issues regarding the use of D0 and D1 on the Arduino pattern header:

From NUCLEO-F446RE | Mbed (which appears to use the same headers) :

On Nucleo 64-pins boards, the D0 and D1 pins are not available per default as they are used by the STLink Virtual Comm Port. More information HERE

The Lora card is here and it appears to use the Arduino header pins on the Nucleo board: https://www.st.com/en/evaluation-tools/i-nucleo-lrwan1.html#overview&secondary=st_all-features_sec-nav-tab

That's indeed an important information and it seems to be the same on the nucleo 401 board. So the TO should use another serial line or change the solder bridges.

The USART pins (= Serial) used by default are the D0 / D1 pins. These are USART2 pins (= Serial2) according to our research set by default.
So we tried to use other USART pins (but not the same as the default).
We have selected the USART1 (Serial1).
Serial1 TX pins are available on D8 (= PA_9) and D10 (= PB_6).
Serial1 RX pins are available on D2 (= PA_10) and on the Morpho connector.
So we tested with USART1 PA9 / PA10 pins.

Code :
HardwareSerial SerialLora(PA9, PA10);

We still have the same error with the message: "Lora module not ready"
We have not yet tried changing the solder bridges (fear of damaging the board).

I don't think you can simply change the serial pins without making a corresponding change to the port. Have you tried changing Y here:

HardwareSerialY   SerialLora( RXpin, TXpin);

Edit
Instead of soldering and breaking jumpers, one option may be to remove the Lora shield and connect it to the Nucleo board with Dupont jumper wires. Then you'll be free to use some of the "non-Arduino" pins on that board.

Edit2
Can you find the Lora program on Github and post a link to it. I've seen where the serial baud rate is set at only 9600. You are using 115200 which may not match the board.

We will try your solution.

Here is the link to the github library:

Here is the link to the github example program we are using :

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.