Newbie question regarding device activation

I am building a sensor node based on an Arduino MKR 1300 and i am using one of the MKRWAN library examples as template.

In that example this code is ran in the setup function:

if (!modem.begin(EU868)) {
Serial.println(“Failed to start module”);
while (1) {}
};
int connected = modem.joinOTAA(appEui, appKey);

This means that the modem.join() is being sent every time the module is powered on.
Reading the best practices this is not a good way to do it. Modem.join should only be called the first time i power on the module.

As far as i understand Modem.join() only returns an integer to show if the join is successful or not.

Is there a way to store something in the flash storage or query the network to check if the device has joined so i don’t have to rejoin every time i power on the module? Or can i just recompile and skip the join after the first successful join?

For development it’s better to use ABP.

Then switch to OTAA for testing.

Then turn on the device and never turn it off, ever, that’s what LoRaWAN devices generally do, collect data, send it, sleep, rinse, repeat.

You can keep the Join keys in flash and restore them if you do need to power off.

OK,
Thanks for the info. The i will keep the join in the setup for the time being. The device will basically run nonstop when i install it in its final location.

But how do i get my “Join keys”? i can’t see any other keys than the ones i add in the source code. the library does not give me access to anything received at join as far as i can see.

If it’s on all the time you don’t need to store the keys as it won’t forget them.

If it runs out of battery, then it will rejoin.

1 Like