MKRWAN 1300 receiving errors

Hi guys!
Im new with arduino, but i want to build a p2p connection with 2 Arduino MKR WAN 1300.
Im using LoRa sender and LoRa receiver examples from sandeepmistry's LoRa library, with I2C sensor data, and LCD display. (But these problems are the same with the untouched example codes.)

  1. The Received data is full of errors.

  2. The connection is very unstable, and hard to buildup. It need a couple of reset to get data from the sender, but when im able to receive, after 2-3 packet it dies and spam my serial monitor with random characters and freezes my arduino.

The codes im using:
(Receiver)

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

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

  while (!LoRa.begin(868E6))
  {
    Serial.println("Starting LoRa failed!");
    LoRa.begin(868E6);
  }
    Serial.println("LoRa ok");
    LoRa.setSyncWord(0xF3);
    LoRa.setCodingRate4(8);
}

void loop()
{

  int packetSize = LoRa.parsePacket();
  if (packetSize)
  {
    while (LoRa.available())
    {
      Serial.print((char)LoRa.read());
    }
      Serial.println(LoRa.packetFrequencyError());
      Serial.println(LoRa.packetRssi());
  }
}

(Sender:)


#include <Adafruit_DPS310.h>
#include <Wire.h>
#include <SHT2x.h>
#include <SPI.h>
#include <LoRa.h>

uint32_t start;
uint32_t stop;

SHT2x sht;

Adafruit_DPS310 dps;
Adafruit_Sensor *dps_temp = dps.getTemperatureSensor();
Adafruit_Sensor *dps_pressure = dps.getPressureSensor();

  String T = "";
  String P = "";
  String H = "";
  
void setup()
{
  Serial.begin(9600);
  //while (!Serial);
  szenzor();
  lora();
  
  dps.configurePressure(DPS310_64HZ, DPS310_64SAMPLES);
  dps.configureTemperature(DPS310_64HZ, DPS310_64SAMPLES);

  dps_temp->printSensorDetails();
  dps_pressure->printSensorDetails();

  sht.begin();
  uint8_t stat = sht.getStatus();
  
  Serial.print(stat, HEX);

}

void loop()
{
  sensors_event_t temp_event, pressure_event;
  dps_temp->getEvent(&temp_event);
  dps_pressure->getEvent(&pressure_event);

  start = micros();
  sht.read();
  stop = micros();

  T =temp_event.temperature;
  P =pressure_event.pressure;
  H =sht.getHumidity();

  delay(1000);

  LoRa.beginPacket();
  LoRa.print("Temp: "+T+" C\n");
  LoRa.print("Press: "+P+" hPa\n");
  LoRa.print("Humi: "+H+" %\n");
  LoRa.endPacket();

  kiir();
  
  delay(4000);
}

void szenzor()
{
  Serial.println("DPS szenzor ellenőrzése");
  if (! dps.begin_I2C(0x76))
  {
    Serial.println("DPS Hiba!");
    for(;;);
  }
  Serial.println("DPS kész.");
}

void lora()
{
  Serial.println("LoRa ellenőrzése.");
  while (!LoRa.begin(868E6))
  {
    Serial.println("LoRa indítása...");
    LoRa.begin(868E6);
  }
  Serial.println("LoRa kész.");
}

void kiir()
{
  Serial.print("A mért értékek:\n");
  Serial.print("\n");
  Serial.print("Temp: "+T+" C\n");
  Serial.print("Press: "+P+" hPa\n");
  Serial.print("Humi: "+H+" %\n");
  Serial.print("\n");
}

Looks like a BAUD mismatch, but check that GND is shared and good.

As you can see tha Baud rate in each program is 9600. I tried with 115200 too, but there is no difference at the view of the error.
And yes the GND is shared. But when im not connect anything to the Arduino, the problem is the same. I can't even send a hello world text without error.

Do you need to set these in the transmitter, too?

  LoRa.setSyncWord(0xF3);
  LoRa.setCodingRate4(8);

Oh yes, i forget to write there in my post, but they are there now.
I think we should ignore my code.
Here is a completely basic code that should work but not work. Could the Arduino be faulty? Because I can't think of anything else.

Sender:

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

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

void loop()
{
  LoRa.beginPacket();
  LoRa.print("abc\n");
  LoRa.endPacket();
  delay(5000);
}

Receiver:

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

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

void loop()
{
  int packetSize = LoRa.parsePacket();
  if (packetSize)
  {
    while (LoRa.available())
    {
      Serial.print((char)LoRa.read());
    }
  }
}

I saw a video where almost the same line of programs was useful, he worked right there flawlessly.

Yes, the hardware could be faulty, but I like to assume it is good. Would you post a "code block" of the (new?) error you receive?

What do you mean by "code block" ? Here is the result of receiving "abc" :

abc

I am probably calling "code box" the wrong thing, but copy/pasting using the "</>" button to display formatted code... it (monotype) is easier for me to read than sans.

You have your baud rates set the same, but the "؟" is still present, replacing non-printable ASCII characters being "received/displayed" which tells me data bits are not being received and/or transmitted correctly. Can you use your project in IIC/I2C wired mode as a test (to verify the tx/rx is the problem, and not the antennae )? Because... if all grounds and Vcc are good, and antannae (per the video) and their connections are also in good condition, then my next guess would be your room has a lot of microwaves bouncing around (is your transmit antenna too powerful? too close?), like in a reflective Faraday cell (copper mesh). Are you near a communications room? Computer server room? A microwave oven in-use? I could always tell when someone was using a microwave oven, because the back of my computer monitor faced the break room, my network connection was jammed and my monitor speaker clicked and beeped (same with blackberry tx/rx).

The presence of the ' ؟' is key. Bits are being misread.

I will try the I2c communication tomorrow.

I tried this project in various places:

I tried to have the sender in the yard and the receiver in my room, separated by a wall.

  • 20m.

I tried so that both the sender and the receiver were in the yard, with a direct view of each other.

  • 25m.

I tried to have the sender in the yard and the receiver outside the village.

  • 500m.

And in the end, I tried it all in another city...

The error was the same.

Okay. The code probably is not the issue. My last guess is the antenna: either just the assembly or the connection on one of the boards. You might find using the board in other non-tx/rx projects is without error.

Okay, thank you. I will try using the Arduinos with I2C. If it works, i will order new Antennas.
I’m going to write on this topic after the tests, but I need a few days / weeks of rest for this so after the exams.

The new antennas have arrived, and i tried them... but the results are the same:

image

I will try to get new Arduinos from my consultant, and try them.

In that LoRa library packet CRC checking is not enabled by default.

If you turn it on with;

LoRa.enableCrc();

Then if the problem with corruption is the LoRa module RF comms (or antennas) then you wont seen any packets received.

I cannot think of a good reason why you would turn CRC checking off.

so i got the new arduinos. After updating the firmware, I put the trial programs on it and it also doesn't work, something else may be the problem. I hope that with the help of my consultant we will find out the cause of the problem and contact the official Italian distributor about it.

One of my friends tweaked the code a bit and this was the result of his modifications:

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

void setup()
{
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  Serial.begin(9600);
  while (!Serial);
  LoRa.enableCrc();
  while (!LoRa.begin(868E6))
  {
    Serial.println("Starting LoRa failed!");
    LoRa.begin(868E6);
  }
  Serial.println("Starting LoRa successful!");
}

void loop()
{
  int packetSize = LoRa.parsePacket();
  if (packetSize)
  {
    while (LoRa.available())
    {
      Serial.println("Packet available:");
      String received = LoRa.readString();
      Serial.println("Packet received");
      Serial.println(received);
    }
    Serial.println("Exited while loop");
  }
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}

This resulted in the following activity on the terminal:

18:38:04.054 -> Starting LoRa successful!
18:38:09.574 -> Packet available:
18:38:09.574 -> Packet received
18:38:09.574 -> (e,l' 
18:38:09.574 -> Exited while loop
18:38:15.044 -> Packet available:
18:38:15.044 -> Packet received
18:38:15.044 -> hw,lo 
18:38:15.044 -> Exited while loop
18:38:20.520 -> Packet available:
18:38:20.520 -> Packet received
18:38:20.520 -> henlo0
18:38:20.520 -> Exited while loop
18:38:25.962 -> Packet available:
18:38:25.994 -> Packet received
18:38:25.994 -> xenlo 
18:38:25.994 -> Exited while loop
18:38:31.444 -> Packet available:
18:38:31.444 -> Packet received
18:38:31.444 -> hwll/ 
18:38:31.444 -> Exited while loop
18:38:36.900 -> Packet available:
18:38:36.900 -> Packet received
18:38:36.900 -> hel|o 
18:38:36.900 -> Exited while loop
18:38:42.379 -> Packet available:

From this, it's easy to determine that the problem is this line:

String received = LoRa.readString();

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.