Mkr wan 1310 send message

Hello,
My message can’t be sent I did this, and this message shows that I can’t connect :

"Quelque chose s’est mal passé ; êtes-vous à l’intérieur? Rapprochez-vous d’une fenêtre et réessayez

"

#include <MKRWAN.h>

LoRaModem modem;

String appEui = "0000000000000000";
String appKey = "

";



void setup() {

    // put your setup code here, to run once:

    Serial.begin(115200);
    while (!Serial);
    Serial.println("Bienvenue dans mon code");

    if (!modem.begin(EU868)) {

        Serial.println("Impossible de demarer le module");
        while (1) {}

    };

    Serial.print("La version du module est : ");
    Serial.println(modem.version());
    Serial.print("Mon EUI est :  ");
    Serial.println(modem.deviceEUI());

    // se connecter avec les valeurs situées dans le header
    int connected = modem.joinOTAA(appEui, appKey);

    if (!connected) {
        Serial.println("Quelque chose s'est mal passé ; êtes-vous à l'intérieur? Rapprochez-vous d'une fenêtre et réessayez");
        while (1) {}
    }

    delay(5000);

    int err;

    modem.setPort(3);

    modem.beginPacket();

    modem.print("MASSE");

    err = modem.endPacket(true);

    if (err > 0) {

        Serial.println("Message sent correctly!");

    } else {

        Serial.println("Error sending message :(");

    }
}

void loop() {

    while (modem.available()) {

        Serial.write(modem.read());

    }

    modem.poll();
}

I need help to solve my problem

Are you in range of a gateway?

Have you properly registered your node details?

17:34:20.895 -> Your module version is: ARD-078 1.2.3
17:34:20.895 -> Your device EUI is: a8610a30323a6e0e
17:35:23.580 -> Something went wrong; are you indoor? Move near a window and retry

type or paste code here

/*
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>

// LoRaModem modem;

// Uncomment if using the Murata chip as a module
LoRaModem modem(Serial1);

#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;

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
// change this to your regional band (eg. US915, AS923, …)
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”);
while (1) {}
}

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

void loop() {
Serial.println();
Serial.println(“Enter a message to send to network”);
Serial.println("(make sure that end-of-line ‘NL’ is enabled)");

while (!Serial.available());
String msg = Serial.readStringUntil(’\n’);

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();
modem.print(msg);
err = modem.endPacket(true);
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(1000);
if (!modem.available()) {
Serial.println(“No downlink message received at this time.”);
return;
}
char rcv[64];
int i = 0;
while (modem.available()) {
rcv[i++] = (char)modem.read();
}
Serial.print("Received: “);
for (unsigned int j = 0; j < i; j++) {
Serial.print(rcv[j] >> 4, HEX);
Serial.print(rcv[j] & 0xF, HEX);
Serial.print(” ");
}
Serial.println();
}

trying to connect to TTN V3, 2 days ago it worked (but not properly) at least I was able to send uplink messages which got decoded properly. Now it is not working. What I am asking myself: did I try to often and got “blacklisted” ?

I am doing a smart farming project where mkr1310 should be able to switched off and on as the farmer would use it just some months / year and where it controls irrigation, so the device would be mounted on one field for e.g. 2 nights and then on another. downlink would be timer settings and uplink would be status reports

Appkey and AppEUI did work 2 days ago and I checked on TTN that they are still correct

I have 2 gateways within reach and my device is set up outside

On what? The same device?

yes on the same mkr1310 I got since sunday 13 uplink und 19 downlink messages for testing. then today with the same configuration and with the gateway near me online it out of the sudden did not work anymore. I then did a reset, tested mkrwan.h instead of mkrwan_v2.h but with no success. I did a firmware update, first configuration and a test, all with the credentials which worked yesterday. no chance. so I wanted to ask if I maybe hit the communication limit at the gateway. I also saw once in the live data view a join accept, but the arduino code / serial monitor did not show a Join.
There seems to be a major problem with mkr1310 and TTN, maybe they did update something ?
I am sure I registered the right EUI and have the right app key

on another note: the webhook with datacake, are the downlinks encrypted and how can I decrypt them ?

basically I would like to have a downlink from datacake with a switch command to a relay on arduino (e.g. ON AA== off AQ==). but as the most basic tests are not working I am slowly getting annoyed by LorRaWan, as my client needs a reliable system for a simple problem

also I do not see an option to scale such a project (and buy an account) when I would have this mess with 100+ irrigation valves

also most tutorials from arduino are for V2, maybe there was a change in V3 and the firmware of arduino 1.2.3 which create this error ?

another issue:

first configuration:

/*
  First Configuration
  This sketch demonstrates the usage of MKR WAN 1300/1310 LoRa module.
  This example code is in the public domain.
*/

#include <MKRWAN.h>

LoRaModem modem;

// Uncomment if using the Murata chip as a module
// LoRaModem modem(Serial1);

String appEui;
String appKey;
String devAddr;
String nwkSKey;
String appSKey;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial);
  Serial.println("Welcome to MKR WAN 1300/1310 first configuration sketch");
  Serial.println("Register to your favourite LoRa network and we are ready to go!");
  // change this to your regional band (eg. US915, AS923, ...)
  if (!modem.begin(EU868)) {
    Serial.println("Failed to start module");
    while (1) {}
  };
  Serial.print("Your module version is: ");
  Serial.println(modem.version());
  if (modem.version() != ARDUINO_FW_VERSION) {
    Serial.println("Please make sure that the latest modem firmware is installed.");
    Serial.println("To update the firmware upload the 'MKRWANFWUpdate_standalone.ino' sketch.");
  }
  Serial.print("Your device EUI is: ");
  Serial.println(modem.deviceEUI());

  int mode = 0;
  while (mode != 1 && mode != 2) {
    Serial.println("Are you connecting via OTAA (1) or ABP (2)?");
    while (!Serial.available());
    mode = Serial.readStringUntil('\n').toInt();
  }

  int connected;
  if (mode == 1) {
    Serial.println("Enter your APP EUI");
    while (!Serial.available());
    appEui = Serial.readStringUntil('\n');

    Serial.println("Enter your APP KEY");
    while (!Serial.available());
    appKey = Serial.readStringUntil('\n');

    appKey.trim();
    appEui.trim();

    connected = modem.joinOTAA(appEui, appKey);
  } else if (mode == 2) {

    Serial.println("Enter your Device Address");
    while (!Serial.available());
    devAddr = Serial.readStringUntil('\n');

    Serial.println("Enter your NWS KEY");
    while (!Serial.available());
    nwkSKey = Serial.readStringUntil('\n');

    Serial.println("Enter your APP SKEY");
    while (!Serial.available());
    appSKey = Serial.readStringUntil('\n');

    devAddr.trim();
    nwkSKey.trim();
    appSKey.trim();

    connected = modem.joinABP(devAddr, nwkSKey, appSKey);
  }

  if (!connected) {
    Serial.println("Something went wrong; are you indoor? Move near a window and retry");
    while (1) {}
  }

  delay(5000);

  int err;
  modem.setPort(3);
  modem.beginPacket();
  modem.print("HeLoRA world!");
  err = modem.endPacket(true);
  if (err > 0) {
    Serial.println("Message sent correctly!");
  } else {
    Serial.println("Error sending message :(");
  }
}

void loop() {
  while (modem.available()) {
    Serial.write(modem.read());
  }
  modem.poll();
}```

Output:
23:09:31.883 -> Welcome to MKR WAN 1300/1310 first configuration sketch
23:09:31.883 -> Register to your favourite LoRa network and we are ready to go!
23:09:32.657 -> Your module version is: ARD-078 1.2.3
23:09:32.693 -> Please make sure that the latest modem firmware is installed.
23:09:32.693 -> To update the firmware upload the 'MKRWANFWUpdate_standalone.ino' sketch.
23:09:32.693 -> Your device EUI is: a8610a30323a6e0e
23:09:32.693 -> Are you connecting via OTAA (1) or ABP (2)?
23:09:59.023 -> Enter your APP EUI
23:10:15.331 -> Enter your APP KEY
23:11:23.641 -> Something went wrong; are you indoor? Move near a window and retry


I did the firmware update and I am already running the newest firmware 1.2.3.
But it shows always "Update Firmware"

How near - same desk, same room, same building?

There is a Fair Use Policy but it doesn’t sound like you’ve done anything to hit any sort of limit.

It will be simpler to get you online before trying to unravel encrypted downlinks with Datacake.

If you want to rent a TTS instance you need to go to the TTI website and sign up there.

The tutorials for v2 vary in specificity, but as LoRaWAN is a standard, mostly they will be out of date with regards the console.

What is the issue - this just appears to be one of the examples.

“How near - same desk, same room, same building?”
2 km

There is a Fair Use Policy but it doesn’t sound like you’ve done anything to hit any sort of limit.
super, thanks for that information

It will be simpler to get you online before trying to unravel encrypted downlinks with Datacake.

I tried to unravel the project from both sides, thanks for the information again, so the downlinks are encrypted, do I decrypt them with the decoder, and if so, how ?

If you want to rent a TTS instance you need to go to the TTI website and sign up there.
I will have to sign up for a plan later in the project to register a fleet of end devices

The tutorials for v2 vary in specificity, but as LoRaWAN is a standard, mostly they will be out of date with regards the console.

I know that LoRaWAN is the standard and that the v2 vs v3 varies just slightly, just thought that there could be the cuplrit / error

Thank you very much for your replies, you cleared some of my questions, → one step further.

To get back to the same issue:
https://github.com/arduino-libraries/MKRWAN/issues/100

do I have to enable/disable modem channels to connect to TTN ?

Output for FirstConfiguration:
Output:
23:09:31.883 → Welcome to MKR WAN 1300/1310 first configuration sketch
23:09:31.883 → Register to your favourite LoRa network and we are ready to go!
23:09:32.657 → Your module version is: ARD-078 1.2.3
23:09:32.693 → Please make sure that the latest modem firmware is installed.
23:09:32.693 → To update the firmware upload the ‘MKRWANFWUpdate_standalone.ino’ sketch.
23:09:32.693 → Your device EUI is: ----------------------------- (deleted this by hand)
23:09:32.693 → Are you connecting via OTAA (1) or ABP (2)?
23:09:59.023 → Enter your APP EUI
23:10:15.331 → Enter your APP KEY
23:11:23.641 → Something went wrong; are you indoor? Move near a window and retry

so I know that the Key and EUI worked yesterday
I did try now every possible configuration
FW Version is 1.2.3

You need to edit this post to put the quotes in to a block quote using the " on the toolbar as it’s almost impossible to read as it stands.

ok, thx a lot

What do the TTN console logs for the gateway & the device show - does the gateway hear the join request, does the device console show a join accept?

Sounds like all set up ok initially now: Given you say

one of which you call out as

Can we assume the 2nd is >2km?

It may be that you are on the edge of reception or were initially seeing a signal by reflection, either way local conditions at your end or at the GW or anywhere in between may now mean your signal is masked or blocked. Can you get close to the GW for a quick join test and see what values for signal quality you get - say 50-200m away assuming then LOS to GW? WIth a name like Alpine…I assume you may be in a hilly area? and terrain masking may be an issue!

What signal levels were seen with the original messages that did work?

As often advised if developing own nodes you cant beat having ou own local test GW!..

Thank you Jeff for the hint with the reflection / interferences, that could be the problem,
I will as a first step test it near the gateway! And yes, it is in the swiss alps, so there are mountains and some hills. But for this exact use case it is almost line of sight, slightly “hilly”. The 2 Gateways are on top of 2 hills with almost direct LOS, but where I am testing I have 2 buildings which could create the interference/reflection.

Next step would be to buy a 4G outdoor gateway to do some proper testing

Nope, next step would be to look on the consoles to see what’s happening outside the device because we may just be able to fix it for you if we have enough info.

Second step, if you don’t have one local to you, would be to buy at TTIG or other low cost gateway so you can eliminate any reception issues. A 4G one comes with the potential latency of the backhaul.

Thanks again Nick, that is perfect for testing! Didnt know such a device exists, way easier than to congest the local gateways.
For rollout we need then to install additional gateways to cover the desired region. any recommendations ? (Outdoor, 4G)

console output will follow