H
@robert-hh I implemented your advice - but it seems the problem persists. Firstly a bit of background.
I have a LoPy4 on a Pytrack. It is transmitting the GPS coordinates over Lora every 10 seconds, as well as saving the records to local storage (not SD card). As Lora is 'fire and forget' I am concerned about missing GPS points when the unit is out of range. When the unit gets back to the office it connects via Wifi and uploads all the saved records, and it then deletes the records when a successful upload is completed.
I also implemented your advice and the unit measures the battery voltage once every 10 second cycle. At the moment I use it to determine if it is on battery voltage, or external power (through USB). But I also realized I don't do as you advised, in that I don't shut down the unit when the battery is nearly empty. I've looked at the different options to shutdown the device and I am unsure which would be the best?
Do I close all files (to prevent corrupting the file system) and put the unit into deep sleep and wake up every 60 seconds to check if power has been restored? Or is there a way to 'shut down' the unit and it will only wake up when power is restored? Do I have to turn of the WDT otherwise it will wake the unit when the WDT expires?
Second to this, why has a safety shutdown not been implemented in the low-level code? If a unit can only operate down to a specified voltage, the low-level can force close all open files, and shut down the unit. The lowest battery voltage I've measured is 3.048239V.