MKRWAN 1310 "Error sending message :(" but seeing uplink in TTN

Hello, I am new here. I am using a MKR WAN 1310 device to send a sample packet using the “First Configuration file” in Arduino as follows:

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

#include <MKRWAN_v2.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:
while (!Serial);
Serial.println(“Welcome to MKRWAN1300/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.print("Your device EUI is: ");

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');


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');


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


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


int err;
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()) {

After uploading the file, I see the following:

“Error sending message :(”

When I go to TTN, I see the following:

““ledState”: null”

Why is this so?