Connection to network with InitABP

Hello, I am trying to send a message over the LoRa network. In my code I try to connect to the network with the initABP function.

This is the code I am using:

}
if (dagCounter == 4)
{

dagCounter  = 0 ;
luchtvGem   = 0 ;    
//TODO TERUG NAAR 24 ZETTEN V
luchtvGem   = (luchtvTot / 4); // bereken de gemiddelde luchtvochtigheid 
BattLow     = (getRealBatteryVoltageMV() < 3700); // Batterij wordt als "laag voltage" gezien wanneer deze lager is dan 3.7 Volt
loraBericht = (String(bericht(tempmin, tempmax, deurGeopend, bewegingPIR, BattLow)) + String(luchtvGem)) ;
SerialUSB.println("**************************************");
SerialUSB.println("batterij: " + String(getRealBatteryVoltageMV()));
SerialUSB.println("minimale temperatuur:  " + String(tempmin));
SerialUSB.println("maximale temperatuur:  " + String(tempmax));
SerialUSB.println("Deur geopend:          " + String(deurGeopend));
SerialUSB.println("Beweging:              " + String(bewegingPIR));
SerialUSB.println("batterij leeg:         " + String(BattLow));
SerialUSB.println("gemiddelde luchtvochtigheid: " + String(luchtvGem));
SerialUSB.println("Lora bericht:          " + String(loraBericht));
SerialUSB.println("**************************************");
// reset sensor waarden
bewegingPIR = false;
deurGeopend = false;
tempmax     = 0;
tempmin     = 50;
luchtvTot   = 0 ;
// Zet de Pinnen naar de LoRabee hoog
digitalWrite(BEE_VCC, HIGH);
loraSerial.begin(LoRaBee.getDefaultBaudRate());

if (LoRaBee.initABP(loraSerial, devAddr, appSKey, nwkSKey, true))
{
  SerialUSB.println("Connection to the network was successful.");
}
else
{
  SerialUSB.println("Connection to the network failed!");
}

switch (LoRaBee.send(1, (uint8_t*)loraBericht.c_str(), loraBericht.length()))
{
  case NoError:
    SerialUSB.println("Successful transmission.");
    digitalWrite(13, HIGH);
    delay(500);
    digitalWrite(13, LOW);
    break;
  case InternalError: // Bij een internal error krijgt de node een reset
    NVIC_SystemReset();
    break;
  case NetworkFatalError: // bij een netwerk error krijgt de node een reset
    NVIC_SystemReset();
    break;
  default:
    break;
}
enable_beweging = true;
enable_deur     = true;
// Zet de Pinnen naar de LoRabee laag
digitalWrite(BEE_VCC, LOW);   

}

(Dagcounter increments every minute, so I’m trying to send a message every 4 minutes)

But whenever the node has sent 1 message, every time the node treis to connect after the first message, it tells me the connection to the network has failed. If I reset the board, the first time the program tries to send the message, It sends the message without issue, but the second time and every time after that it fails again. How is that possible?

Can you move the initABP to the setup() of the Arduino code and only run it once?

Keep the BEE_VCC high, if you want to consume less power use the sleep command of the lora module.

LoRaBee.sleep([milliseconds]);
LoRaBee.wakeUp();

The latest version of the library is available on github