Hi all,
I would like to save data that survives reboot, but did not find any documentation on how to do it on ESP8266. I found the function flash_write, but am not sure how to use it and the filesystem API is not present yet.
Is there a way to store a string/array-of-bytes from Python and load it from Python after reboot ? How would it work ?
Thanks !
Storing persistent data
Re: Storing persistent data
I played around with their basic file storage and it holds files after complete power loss. Was a simple matter of the following commands to write a file:
import boot_
f=open("myfile.txt","w") # opens a file for writing.
f.write("some data! Hooray data!")
f.close()
And to read (assuming you've rebooted)
import boot_
import os
os.listdir() # just for fun, get a list of existing files
f=open("myfile.txt","r")
print(f.read())
f.close()
That's all I've got for now. Only had a few minutes to play thus far. I was debating writing a script to open files on a local webserver and write them into memory as a way to transfer bigger scripts in, but I think I heard they're working on some upip style methods. (I have to think of these things given I only have ESP12s laying about. None of those wonderful looking huzzahs or feathers or whatnot with their USB drive detection)
import boot_
f=open("myfile.txt","w") # opens a file for writing.
f.write("some data! Hooray data!")
f.close()
And to read (assuming you've rebooted)
import boot_
import os
os.listdir() # just for fun, get a list of existing files
f=open("myfile.txt","r")
print(f.read())
f.close()
That's all I've got for now. Only had a few minutes to play thus far. I was debating writing a script to open files on a local webserver and write them into memory as a way to transfer bigger scripts in, but I think I heard they're working on some upip style methods. (I have to think of these things given I only have ESP12s laying about. None of those wonderful looking huzzahs or feathers or whatnot with their USB drive detection)
Re: Storing persistent data
Thanks, that worked.
The new firmware version announced today ships with the filesystem enabled by default, making it easier to achieve this.
The new firmware version announced today ships with the filesystem enabled by default, making it easier to achieve this.
Re: Storing persistent data
I saw that. I'm flashing my dev chip now so I can take it to work and play