sandeepmistry / arduino-LoRa

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

On the Lora32u4 II board, calling setSpreadingFactor hangs #165

Closed j4zzcat closed 6 years ago

j4zzcat commented 6 years ago

I'm successfully using two Lora32u4 II boards with the default send/receive examples. However, calling setSpreadingFactor with 9, 10, 11 or 12 hangs (haven't tried the other values).

#include <SPI.h>
#include <LoRa.h>

int counter = 0;

void setup() {
  Serial.begin(115200);
  while (!Serial);

  Serial.println("LoRa Sender");

  LoRa.setPins( 8, 4, 7 );
  LoRa.setSpreadingFactor( 10 );
  Serial.println( "After SPF" ); // <-- never gets here

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

void loop() {
  Serial.print("Sending packet: ");
  Serial.println(counter);

  // send packet
  LoRa.beginPacket();
  LoRa.print("hello ");
  LoRa.print(counter);
  LoRa.endPacket();

  counter++;

  delay(5000);
}
Yury-MonZon commented 6 years ago

You have to call LoRa.begin(YOUR_BAND) BEFORE calling LoRa.setSpreadingFactor( 10 );

j4zzcat commented 6 years ago

Thanks.