MKR1310, how to use the serialFlash to store network keys to avoid OTAA joins

Hi,

Regading the new MKR1310 PCB, how to use the new FLASH memory to store the network keys between poweups to avoid repeted OTAA Joins.

We run the MKR1310 on battery and when we go to sleep after our task is complete. When the device wake up again it dont remember the network keys so we need to do another OTAA join again, I would like to store the key before the device go to sleep and read them again on powerup and do a ABP join instead (read keys from memory)

We are using the sparkfun nano timer…
(SparkFun Nano Power Timer - TPL5110 - PRT-15353 - SparkFun Electronics)

We are complete newbies so plese be generous withsample code and explanation.

My application joins once and then I do not have to join again after that unless I cycle the power. I am using sleep.

I believe the module firmware retains a copy of the session keys during sleep. I think the only way you loose them is if you leave, get kicked or loose power.

Some people sleep by turning off the power. Is that what you do?

I just noticed the reference to the Sparkfun timer so i surmize you are turning off the MKRWAN. Get rid of that and use the ArduinoLowPower library. You do not have to worry about the session keys then. Sleep current can be reduced to about 20uA if you use an external power supply. If you use the power supply on the 1310, sleep current is about 100uA.

Regarding the serial flash, try the SPI Memory library.

Thanks a lot sslupdsky,

We used the external sparkfun nano timer to shut of the MKR1310 because we did thought that arduino low power timer library could not shut of for more than 8 seconds. Our LoRA data sending intervall must be in the range of 30 or 60 minutes, so we want to sleep for more than 8 seconds.

Do you have a skecht/code to share how longer sleep period is achived ?

You can sleep for hours, days, weeks if you want. I actually only sleep for about 62ms. But, i sleep 99.999 percent of the time so my average current is less than 100uA. Sleeping for a short time allows you to be responsive to user input if you need to. Basically, wake up, check to see if you need to do something, then go back to sleep. If you only need to transmit once an hour, then that is all you do.

So, the trick is not making it sleep longer, that is quite straight forward with the low power library. The challenge is to decrease the sleep period and only stay awake for a few 10’s of microseconds “most of the time”. For that, you need to use the periodic event system since the low power library can only reduce the sleep period to a minimum of 1 sec. if 1 sec responsiveness is all you need, then the low power lib will do as is.