In the case of Zero, LoRa module refused to initialise. I then added the while loop shown above and the module initialises successfully after the second attempt.
Please note that this happens on every occasion with the Arduino zero, while in the case of the Arduino micro, there is no need for the while loop and the module initialises on the first attempt.
Any ideas? Is this somehow CPU frequency related ?
#include <SPI.h>
#include <LoRa.h>
int counter = 0;
const int csPin = 6; // LoRa radio chip select
const int resetPin = 4; // LoRa radio reset
const int irqPin = 5; // change for your board; must be a hardware interrupt pin
void setup() {
SerialUSB.begin(9600);
while (!SerialUSB);
SerialUSB.println("LoRa Receiver");
LoRa.setSPIFrequency(4E6);
LoRa.setPins(csPin, resetPin, irqPin);// set CS, reset, IRQ pin
delay(1000);
while (!LoRa.begin(433E6)) {
SerialUSB.println("Starting LoRa failed!");
delay(500);
}
SerialUSB.println("Starting LoRa success!");
}
void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
SerialUSB.print("Received packet '");
// read packet
while (LoRa.available()) {
SerialUSB.print((char)LoRa.read());
}
// print RSSI of packet
SerialUSB.print("' with RSSI ");
SerialUSB.println(LoRa.packetRssi());
}
}
type or paste code here
it should be fine as the default for the Lora libray is 8Mhz.
You could try to slow it down even more, all the way to 125kHz
some docs say
There is also a dedicated CS pin that you can use (which must, at least, be set to an output in order for the SPI hardware to function), but note that you can use any other available output pin(s) for CS to your peripheral device(s) as well.
so I was suggesting to put the hardware SS pin as output yourself before configuring SPI