Adapted and simplified from Franck Albinet's exercises available here. Also presented by NSRC at APRICOT 2018.
...
While one of the primary purpose of IoT is to collect and exchange data over an inter-connected network, it is as well important to be able to persist information in the IoT device itself: log files of device's activity, Received Signal Strength Activity (RSSI), ... In the case of high-resolution measurements, it's useful to store them before sending them over the network, in order to save on power.
Learning outcomes
You will learn how to: access and operate device's file system; create and write a file in the flash
folder; handle files safely using with
statement; generate programmatically time stamped log file names; make your code robust and flexible with try ... except
statement.
...