Combination of LoRa and LoRaWAN

Hello,

currently I am working on an project that requires a LoRa PTP-connection to be forwarded into The Things Network.
As a test I created a program which connects to TTN and sends a message every 2 minutes. The LoRaWAN connection on it´s own always worked pretty good.
My problem is that TTN does not receive any messages as soon as I begin the PTP connection, even if I end it directly again.
With help of the serial monitor i found out that the programm stops working in line 84.

The Arduino I am using is a MKR WAN 1310.
The libraries I am using are MKRWAN.h ; SPI.h ; LoRa.h

Now my question. Is it possible to switch between LoRa and LoRaWAN?

code:

/*
  Lora Send And Receive
  This sketch demonstrates how to send and receive data with the MKR WAN 1300/1310 LoRa module.
  This example code is in the public domain.
*/

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

LoRaModem modem;

#include "arduino_secrets.h"
// Please enter your sensitive data in the Secret tab or arduino_secrets.h
String appEui = SECRET_APP_EUI;
String appKey = SECRET_APP_KEY;

int Counter = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial);

  if (!modem.begin(EU868)) {
    Serial.println("Failed to start module");
    while (1) {}
  };
  Serial.print("Your module version is: ");
  Serial.println(modem.version());
  Serial.print("Your device EUI is: ");
  Serial.println(modem.deviceEUI());

  int connected = modem.joinOTAA(appEui, appKey);
  if (!connected) {
    Serial.println("Something went wrong; are you indoor? Move near a window and retry");
    Serial.println(connected);
    while (1) {}
  }
  else
  {
    Serial.println("Connected");
  }

  // Set poll interval to 60 secs.
  modem.minPollInterval(60);
  // NOTE: independently by this setting the modem will
  // not allow to send more than one message every 2 minutes,
  // this is enforced by firmware and can not be changed.

  delay(1000);

  if (!LoRa.begin(868E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }

  delay(1000);
}

void loop() {
  LoRa.end();

  delay(10000);

  Counter++;

  String msg = "Sendevorgang: ";

  Serial.println();
  Serial.print("Sending: " + msg + " - ");
  for (unsigned int i = 0; i < msg.length(); i++) {
    Serial.print(msg[i] >> 4, HEX);
    Serial.print(msg[i] & 0xF, HEX);
    Serial.print(" ");
  }
  Serial.println();

  int err;
  modem.beginPacket();
  Serial.println("Paket begonnen");
  modem.print(msg + Counter);
  Serial.print("Nachricht verschicken");
  err = modem.endPacket(true);
  Serial.println("Paket beenden");

  if (err > 0) {
    Serial.println("Message sent correctly!");
  } else {
    Serial.println("Error sending message :(");
    Serial.println("(you may send a limited amount of messages per minute, depending on the signal strength");
    Serial.println("it may vary from 1 message every couple of seconds to 1 message every minute)");
  }
  delay(12000);
}

Care needed to avoid upsetting the timing on the LoRaWAN side.

How many LoRa PTP nodes will there be, and how often will each forward a message to the MKR WAN 1310 ?

the critical moment can be found in a file in the gateway with a name like "dual_chn_pkt_fwd.cpp"

90 or 95 percent down from the top. typically the shortest line in the packet forwarder.

lgw.UDPsend(packet);

that is, LoRa Gateway send a UDP packet

another example:

// Build and send message.
      memcpy(buff_up + 12, json.c_str(), json.size());
      SendUdp(buff_up, buff_index + json.size());

      fflush(stdout);

if you are feeling frisky you can add a similar line just before or after that line to send the same packet to your local network. if it's your gateway you can send the same packet to I2C or serial.

I am trying to set ChirpStack up to retain the packets, send them to I2C, process my sensors in the RPi in my gateway. if I can't make that work my backup plan is to put an ethernet shield on an UNO, make that my packet destination, use the UNO and an I2C to 16IO module to pull pins low in my Mega

srnet:
Care needed to avoid upsetting the timing on the LoRaWAN side.

How many LoRa PTP nodes will there be, and how often will each forward a message to the MKR WAN 1310 ?

I plan to send signal every 2 minutes via PTP. Messages are only forwarded when the state of the ptp signal has changed. So the loRaWAN messages should be maximum 20 per days.

Using two LoRa libraries for the same device does not sound easy at all.

The LoRa devices setups for LoRaWAN and LoRa point to point are diffferent and conflicting. Quite how you would constantly flip libraries and keep all the timing needed for LoRaWAN, I have no idea.

A more pragmatic solution would be to use a seperate LoRaPTP device, just a ProMini and LoRa device would do, and have that communicate via serial to the LoRaWAN node.

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