Timeout and internal error

Hello everyone.

I am trying to send a message over the LoRa network, however, I seem to be able to send only 1 message everytime before the devices encounters some weird behaviour:

This is the (example) code I am using:

#include <Sodaq_RN2483.h>
#include "DHT.h"
// MBili / Tatu
//#define debugSerial Serial
// Autonomo
#define debugSerial SerialUSB
#define loraSerial Serial1
#define DHTPIN 10 // what pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);
//These constants are used for reading the battery voltage
#define ADC_AREF 3.3
#define BATVOLTPIN BAT_VOLT 
#define BATVOLT_R1 4.7
#define BATVOLT_R2 10
// Dev Adress
const uint8_t devAddr[4] =
{
  0x14, 0x00, 0x23, 0x8F
};
// App Session key
const uint8_t appSKey[16] =
{
  0xD5, 0xFC, 0x5D, 0x14, 0xAF, 0x83, 0x96, 0xC6, 0x4B, 0x9A, 0xF9, 0xAD, 0x26, 0xA3, 0x7F, 0x79
};
// Network session key
const uint8_t nwkSKey[16] =
{
  0XEB, 0X41, 0X95, 0X41, 0X67, 0XBA, 0X9B, 0XFC, 0XCC, 0X1C, 0XDC, 0X23, 0XED, 0XA7, 0XFA, 0X1E
};
void setup()
{
  // REMOVE WHEN YOU DONT USE PC
  // This line make the program only run when its connected to the serial monitor
  while ((!debugSerial) && (millis() < 10000));
  
	debugSerial.begin(57600);
	loraSerial.begin(LoRaBee.getDefaultBaudRate());
  digitalWrite(BEE_VCC, HIGH);
	LoRaBee.setDiag(debugSerial); // optional
	if (LoRaBee.initABP(loraSerial, devAddr, appSKey, nwkSKey, true))
	{
		debugSerial.println("Connection to the network was successful.");
	}
	else
	{
		debugSerial.println("Connection to the network failed!");
	}
  dht.begin();
}
void loop()
{
  debugSerial.println();
  digitalWrite(BEE_VCC, HIGH);
  
  debugSerial.println("Sending payload: Humidity, Temperature, Voltage");
  String reading = takeTPHReading();
  reading += ", " + String(getRealBatteryVoltageMV());
  debugSerial.println(reading);
		switch (LoRaBee.sendReqAck(1, (uint8_t*)reading.c_str(), reading.length(), 8))
		{
		case NoError:
			debugSerial.println("Successful transmission.");
			break;
		case NoResponse:
			debugSerial.println("There was no response from the device.");
			break;
		case Timeout:
			debugSerial.println("Connection timed-out. Check your serial connection to the device! Sleeping for 20sec.");
			delay(20000);
			break;
		case PayloadSizeError:
			debugSerial.println("The size of the payload is greater than allowed. Transmission failed!");
			break;
		case InternalError:
			debugSerial.println("Oh No! This shouldn't happen. Something is really wrong! Try restarting the device!\r\nThe program will now halt.");
			while (1) {};
			break;
		case Busy:
			debugSerial.println("The device is busy. Sleeping for 10 extra seconds.");
			delay(10000);
			break;
		case NetworkFatalError:
			debugSerial.println("There is a non-recoverable error with the network connection. You should re-connect.\r\nThe program will now halt.");
			while (1) {};
			break;
		case NotConnected:
			debugSerial.println("The device is not connected to the network. Please connect to the network before attempting to send data.\r\nThe program will now halt.");
			while (1) {};
			break;
		case NoAcknowledgment:
			debugSerial.println("There was no acknowledgment sent back!");
			break;
		default:
			break;
		}
    // Delay between readings
    // 60 000 = 1 minute
		delay(300000);
	
}
String takeTPHReading()
{
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to A0 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  float t = dht.readTemperature();
    
  String data = String(h)  + ", ";
  data += String(t);
  
  return data;
}
float getRealBatteryVoltageMV()
{
  uint16_t batteryVoltage = analogRead(BATVOLTPIN);
  return (ADC_AREF / 1.023) * (BATVOLT_R1 + BATVOLT_R2) / BATVOLT_R2 * batteryVoltage;
}

This is the uart output:

Connection to the network was successful.
Sending payload: Humidity, Temperature, Voltage
22.00, 24.00, 4144.45
Connection timed-out. Check your serial connection to the device! Sleeping for 20sec.
Sending payload: Humidity, Temperature, Voltage
25.00, 24.00, 4149.19
The device is busy. Sleeping for 10 extra seconds.
Sending payload: Humidity, Temperature, Voltage
22.00, 24.00, 4149.19
The device is busy. Sleeping for 10 extra seconds.
Sending payload: Humidity, Temperature, Voltage
22.00, 24.00, 4149.19
The device is busy. Sleeping for 10 extra seconds.
Sending payload: Humidity, Temperature, Voltage
22.00, 24.00, 4149.19
The device is busy. Sleeping for 10 extra seconds.
Sending payload: Humidity, Temperature, Voltage
22.00, 24.00, 4153.93
Oh No! This shouldn't happen. Something is really wrong! Try restarting the device!
The program will now halt.

I don’t know why the devices is busy all the time and I don’t understand why something wrong is happening. I can’t find any documentation as to what the reason is for every error code.

You are only alowed to send 1% of the time. If you use ACK then your air time is alot longer because it wait for a response of the gateway.

The 8 at the end means that in worse case scenario is tries to send the same packet 8x.

Use:

switch (LoRaBee.send(1, (uint8_t*)reading.c_str(), reading.length()))

If you are close to a gateway you still receive 99% of all packages. And your air time drops by 75%. So you can send a lot more messages.

Or make the delay bigger.

Aah I understand, So if I only want to send a message once a day, it is no problem for me to use the ReqAck?

That is no problem.

Regards,
Jan