Go Down

Topic: MKR 1300: Can't receive messages (Read 2045 times) previous topic - next topic

janpfer

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:

facchinm

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.

janpfer

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?

luigiillica

I have the same problem, did you solve the problem in the meantime?

janpfer

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 :)

Halflifo

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?

DogBee

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.

Surreal_One

I am facing the same problem. Was anyone successful with the peer to peer connection on Arduino MKR 1300 ?


MITEL

Curious me too (not only peer to peer: I am not able to receive downlinks from a gateway).

Go Up