Using Nucleo-f411re with LoRa ra2 sx1278

Thread Starter

Abdulrahman Albadawi

Joined Jun 9, 2024
1
Hello,
I’m new to embedded systems and currently learning STM32 + LoRa.

I’m using two NUCLEO-F411RE boards and two RA-02 (SX1278) LoRa modules. My goal is to establish basic point-to-point communication.

I initially tried using a LoRa.h library, but I couldn’t get it working reliably. To reduce complexity, I decided to verify SPI communication first, before dealing with LoRa TX/RX logic.


However, SPI itself does not appear to work as expected, so it’s unclear whether the issue is:
  • SPI configuration
  • Hardware wiring
  • Or the LoRa library integration

Below are two minimal examples:
  1. A bare SPI register read (RegVersion = 0x42)
  2. A minimal LoRa.h initialization without TX/RX logic

I would appreciate feedback on:
  • Missing or incorrect SPI configuration
  • Whether the LoRa initialization sequence is reasonable
  • Common SX1278 + STM32 HAL pitfalls


Minimal SPI test (RegVersion check)

#include "main.h"
#include "spi.h"
#include "gpio.h"

#define REG_VERSION 0x42

uint8_t sx1278_read_reg(uint8_t reg)
{
uint8_t tx[2] = { reg & 0x7F, 0x00 };
uint8_t rx[2] = { 0 };

HAL_GPIO_WritePin(NSS_GPIO_Port, NSS_Pin, GPIO_PIN_RESET);
HAL_SPI_TransmitReceive(&hspi1, tx, rx, 2, HAL_MAX_DELAY);
HAL_GPIO_WritePin(NSS_GPIO_Port, NSS_Pin, GPIO_PIN_SET);

return rx[1];
}

int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_SPI1_Init();

uint8_t version;

while (1)
{
version = sx1278_read_reg(REG_VERSION); // expect 0x12
HAL_Delay(1000);
}
}

Minimal LoRa.h initialization (no TX/RX)
is in this repository: LoRa/Src/main.c at master · SMotlaq/LoRa
 
Top