sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.64k stars 628 forks source link

STM32L051C8 gets stuck at LoRa.endPacket() using RA-02 module #702

Open agozie opened 2 weeks ago

agozie commented 2 weeks ago

I am unable to send or receive through a STM32L051C8T7 board.. No failure in setup, but it freezes on LoRa.endPacket();, hSerial.print("4"); is never called in the code below. It also freezes when LoRa.read() is called to receive data. Is STM32L051C8 not supported? Or am I doing something wrong.

`#include

include

include

include

HardwareSerial hSerial(PA10, PA9);

define LORA_SCK PA5

define LORA_MISO PA6

define LORA_MOSI PA7

define LORA_CS PA4

define LORA_RST PB11

int counter = 0;

void setup() { delay(500); hSerial.begin(115200); // while (!hSerial); delay(500);

hSerial.println("LoRa Receiver");

delay(500);

LoRa.setPins(LORA_CS, LORA_RST); SPI.setMISO(LORA_MISO); SPI.setMOSI(LORA_MOSI); SPI.setSCLK(LORA_SCK); SPI.setSSEL(LORA_CS);

SPI.begin();

if (!LoRa.begin(433E6)) { hSerial.println("Starting LoRa failed!"); while (1) ; }

delay(500); hSerial.println("LoRa Receiver Setup Done"); delay(500); }

void loop() {

hSerial.print("Sending packet: "); hSerial.println(counter);

// send packet LoRa.beginPacket(); hSerial.print("1"); LoRa.print("hello "); hSerial.print("2"); LoRa.print(counter); hSerial.print("3"); LoRa.endPacket(); hSerial.print("4");

counter++;

delay(1000);

} `

davidlehrian commented 2 weeks ago

I had a similar problem with an ESP32 module and it turned out to be a grounding issue. Make sure ALL ground pins on your STM32 board are attached to ground as well as ALL ground pins on your LoRa module.