Program is erased from internal memory
-
I've made a lora sensor node using the Lopy +PyTrack and I'm seeing some weird behaviour which I'm wondering is expected.
The program itself reads a file from the internal memory, does some sensing, transmits some parameters over LoRa, saves a file again and goes into deep sleep using the pytrack library.
I think that every time my battery runs out somehow the internal memory is erased/corrupted because when I connect the LoPy over USB the blue LED starts flashing and my boot/main.py and the data folder are gone. After I sync through Atom everything is fine again.
What could be going on here? The internal flash should be non volatile right?
I'm writing to the file using
import json with open('/data/state.json') as stateFile: stateFile.write(json.dumps(state))And going into deep sleep with
import pytrack pytrack.setup_sleep(10) pytrack.go_to_sleep() -
@joeri
If you look into history
you can find same posts as yours.I do not know what is the check rule - but if partition is broken in some way it is automatically formated during boot. Then you goot fresh
boot.pyandmain.pybetter is saving to SD card
-
Allright. I'll use the SD card. That will increase the power consumption a bit though.
It has happened a few times already, I can't believe the battery runs out exactly while I'm saving the state (which is just a few bytes)
-
You need to close the file as soon as the write is complete. If the unit shuts down while the file is open there's a good chance to corrupt the flash. This will erase the flash when it reboots.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login