Hi,
I'm relativly new in arduino/coding,... and i hope i'm dooing everything right in this post. Please let me know if not. :o
For the beginning i want to make a p2p connection between a MKRWAN 1300 and a MEGA 2560 R3 with the Dragino LoRa Shield v1.4.
After struggeling a little with getting the MKR1300 to "start LoRa" i turned the checking of the version off by adding a return 1. (Like discussed in this link: Starting LoRa failed! · Issue #68 · sandeepmistry/arduino-LoRa · GitHub)
Now i'm struggeling in sending or receiving the message. After lots of research in half of google i added some LoRa settings to the example codes. But still i got no success. And because you couldn't find anything about the MKR1300 i came to this forum.
Twice i received one message (different trials), but it was twice just one message with a verry bad RSSI (around -119). But the two modules are on the same table, maybe a distance of 0.5m. Both are with the delivered antennas.
I'm using the lates versions of the libraries and the IED 1.8.5.
My scetches are based on the examples DumbModemLoraSender (for MKR1300, from MKRWAN lib) and LoRaReceiver (for Mega with shield).
My code for the MKR1300 is:
#include <SPI.h>
#include <LoRa.h>
#include <MKRWAN.h>
const long freq = 868E6;
int counter = 1;
const int led = 6;
LoRaModem modem;
void setup()
{
Serial.begin(9600);
while (!Serial);
modem.dumb();
pinMode(led, OUTPUT);
LoRa.setPins(LORA_IRQ_DUMB, 6, 1); // set CS, reset, IRQ pin
LoRa.setTxPower(17, PA_OUTPUT_RFO_PIN);
LoRa.setSPIFrequency(125E3);
LoRa.setSignalBandwidth(31.25E3);
LoRa.setSpreadingFactor(9);
LoRa.setSyncWord(0x34);
LoRa.setCodingRate4(5);
LoRa.setPreambleLength(65535);
LoRa.begin(freq);
Serial.println("LoRa Sender");
if (!LoRa.begin(freq))
{
Serial.println("Starting LoRa failed!");
while (1);
}
Serial.print("Frequency ");
Serial.println(freq);
}
void loop()
{
digitalWrite(led, HIGH);
Serial.print("Sending packet: ");
Serial.println(counter);
// send packet
LoRa.beginPacket();
LoRa.print("Tis is SPARTA no ");
LoRa.print(counter);
LoRa.endPacket();
counter++;
digitalWrite(led, LOW);
delay(5000);
}
My code for the Mega is:
#include <SPI.h>
#include <LoRa.h>
const long freq = 868E6;
int led = 53;
int reset_lora = 9;
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(reset_lora, OUTPUT);
digitalWrite(reset_lora, LOW);
delay(1000);
digitalWrite(reset_lora, HIGH);
Serial.println("LoRa Receiver");
LoRa.setPins(10, A0, 2); // set CS, reset, IRQ pin
LoRa.setSPIFrequency(125E3);
LoRa.setSignalBandwidth(31.25E3);
LoRa.setSpreadingFactor(9);
LoRa.setSyncWord(0x34);
LoRa.setCodingRate4(5);
LoRa.setPreambleLength(65535);
// LoRa.setTxPower(17, PA_OUTPUT_PA_BOOST_PIN);
LoRa.begin(freq);
LoRa.receive();
if (!LoRa.begin(freq))
{
Serial.println("Starting LoRa failed!");
while (1);
}
Serial.println("LoRa Started");
Serial.print("Frequency ");
Serial.println(freq);
}
void loop()
{
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize)
{
// received a packet
digitalWrite(led, HIGH);
Serial.print("Received packet '");
// read packet
while (LoRa.available())
{
Serial.print((char)LoRa.read());
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
digitalWrite(led, LOW);
}
}
Hope someone can help me