This is long-- there's a summary at the end :)
If you are using MicroPython, then you can use micro:bit's 30k file system -
with open("filename.txt", "w") as file_object:
file_object.write("[your data here]")
To manage files on your micro:bit, you can use MicroFS or "ufs" for short. To install: $ pip install microfs
. Your four commands are:
ufs ls
to see all files on your micro
ufs rm filename.txt
to delete a file on your micro
ufs put path/to/your/file.txt optional_target_filename.txt
to copy a file onto your micro from your computer
ufs get filename.txt optional/path/to/target/file.txt
to copy a file from your micro to your computer.
For more information, type ufs --help
.
NOTES: Flashing you micro:bit will delete all your information; however, turning it off will not. Also, micro:bit's file system is flat, meaning it has no directories; everything is stored at the top level.
As per your request for BLE, I can't really help in that area, but I would like to point out the radio
MicroPython module, used with import radio
followed by a radio.on()
(for conserving battery; there's also a radio.off()
)
- send data with
radio.send("[your data here]")
- recieve data with
radio.recieve()
which takes from the top of a message queue.
The radio
module sends radio waves at a channel that's between 0 and 100, set in a default. I'm not sure exactly how to change this, but there should be documentation somewhere :) I'm sorry that this isn't a great solution, but, hopefully, it'll point you in the right direction.
EDIT: To change the radio channel, set radio.channel
to your desired channel (default=7). It can 0-100 inclusive, which in reality is 2400MHz-2500MHz. For more info, go here.
SUMMARY
main.py on the micro
import microbit
import radio
with open("datalog.txt") as logfile:
logfile.write(microbit.temperature()) #or whatever data you had in mind
radio.channel = 47 #2447MHz, feel free to use something else
radio.send(microbit.temperature()) #or whatever
app pseudocode
radio.listenOn(2447MHz) #or whatever
@event.recieveRadioMessage()
void function(evt) {
#tell user the data
screen.display(evt.msg)
}