Arduino Forum

Products => MKR Boards => MKRWAN1300 => Topic started by: janpfer on Dec 27, 2017, 10:46 pm

Title: MKR 1300: Can't receive messages
Post by: janpfer on Dec 27, 2017, 10:46 pm
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: https://github.com/sandeepmistry/arduino-LoRa/issues/68)

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 :smiley-confuse:
Title: Re: MKR 1300: Can't receive messages
Post by: facchinm on Jan 08, 2018, 09:37 am
Hi janpfer,
probably there are a couple of issues on the MKRWAN side:
one is about the communication channel, which must be set to SPI1 (in the library code, at the moment). I'll prepare a patch on sandeep's library to do it automatically.
The second thing could be caused by LoRa.setSPIFrequency(125E3); which is too high for the passthrough method. LoRa.setSPIFrequency(100000); is safer and should work just fine.
Title: Re: MKR 1300: Can't receive messages
Post by: janpfer on Jan 12, 2018, 03:39 pm
Hi facchinm

I tried it in SPI1 and with an SPI Frequency of 100000 (at the same time) but still no success.

I changed the SPI mode in de .ccp file of your LoRa lib like this:

Code: [Select]
LoRaClass::LoRaClass() :
  _spiSettings(8E6, MSBFIRST, SPI_MODE1),
  _ss(LORA_DEFAULT_SS_PIN), _reset(LORA_DEFAULT_RESET_PIN), _dio0(LORA_DEFAULT_DIO0_PIN),
  _frequency(0),
  _packetIndex(0),
  _implicitHeaderMode(0),
  _onReceive(NULL)


and

Code: [Select]
void LoRaClass::setSPIFrequency(uint32_t frequency)
{
  _spiSettings = SPISettings(frequency, MSBFIRST, SPI_MODE1);
}


Once i tried it with SPI_MODE1 just for the MKR once for both.


The SPIFrequency was set like in the last code, bot on 100000 / 100E3

 
Code: [Select]
LoRa.setSPIFrequency(125E3);

Any more suggestions?
Title: Re: MKR 1300: Can't receive messages
Post by: luigiillica on Jan 22, 2018, 04:49 pm
I have the same problem, did you solve the problem in the meantime?
Title: Re: MKR 1300: Can't receive messages
Post by: janpfer on Jan 30, 2018, 12:06 pm
No, not yet.

Had to let it go and i'm working with two LoRa shields for the moment (need it woorking for a project at my studies).

I hope facchinm will prepare the patch on the lib soon :)
Title: Re: MKR 1300: Can't receive messages
Post by: Halflifo on Feb 07, 2018, 11:31 am
Hello! I've been reading for a few days now about being able to communicate between two Arduino LoRa WAN 1300 modules peer to peer, but I sill hasn't found how. I'm absolutely new to LoRa, and if you could bulid up a communication between the two boards, would you give me some guidance, how it is possible?
Title: Re: MKR 1300: Can't receive messages
Post by: DogBee on Mar 17, 2018, 02:46 am
Total noob to Arduino. Just bought a MKR WAN 1300 through Digi-Key and the board wasn't supplied with an antenna. What antenna do I need and where can I buy it. (Canada). Thanks.
Title: Re: MKR 1300: Can't receive messages
Post by: Surreal_One on Jun 22, 2018, 04:12 pm
I am facing the same problem. Was anyone successful with the peer to peer connection on Arduino MKR 1300 ?
Title: Re: MKR 1300: Can't receive messages
Post by: tumengerel on Jul 20, 2018, 11:13 am
any news
Title: Re: MKR 1300: Can't receive messages
Post by: MITEL on Aug 23, 2018, 11:14 am
Curious me too (not only peer to peer: I am not able to receive downlinks from a gateway).
Title: Re: MKR 1300: Can't receive messages
Post by: saravo on Apr 09, 2019, 11:00 am
Hello, there are any news? I'm trying to communicate 2 MKR WAN 1300 with no success. LoRa always failed to start.

Can anyone help?

thanks
Title: Re: MKR 1300: Can't receive messages
Post by: MITEL on Apr 09, 2019, 03:26 pm
My issue with downlinks was due to the gateway, now there aren't problems. Remember to update the firmware and the library.
Title: Re: MKR 1300: Can't receive messages
Post by: saravo on Apr 10, 2019, 10:15 am
I have solved the problem:
It was caused by the board manager version

Arduino SAMD Board 1.6.21 doesn't work, I realised a downgrade to 1.6.20

I hope that this problem can be solved and can help other developers.