这很长——最后有一个摘要:)
如果你使用的是 MicroPython,那么你可以使用 micro:bit 的 30k file system -
with open("filename.txt", "w") as file_object:
file_object.write("[your data here]")
要管理 micro:bit 上的文件,您可以使用 MicroFS 或简称“ufs”。安装:$ pip install microfs。你的四个命令是:
-
ufs ls 可以查看你微信上的所有文件
-
ufs rm filename.txt 删除你微信上的文件
-
ufs put path/to/your/file.txt optional_target_filename.txt 将文件从您的计算机复制到您的微型计算机上
-
ufs get filename.txt optional/path/to/target/file.txt 将文件从您的微型计算机复制到您的计算机。
如需更多信息,请输入ufs --help。
注意: 闪烁你的 micro:bit 将删除你的所有信息;但是,将其关闭不会。此外,micro:bit 的文件系统是扁平的,这意味着它没有目录;一切都存储在顶层。
根据您对 BLE 的要求,我在这方面确实帮不上忙,但我想指出 radio MicroPython 模块,与 import radio 一起使用,后跟 radio.on()
(对于节省电池;还有一个radio.off())
- 用
radio.send("[your data here]")发送数据
- 使用
radio.recieve() 接收来自消息队列顶部的数据。
radio 模块在默认设置的 0 到 100 之间的频道发送无线电波。我不确定如何更改它,但应该在某个地方有文档 :) 很抱歉这不是一个很好的解决方案,但希望它能为您指明正确的方向。
编辑:要更改广播频道,请将radio.channel 设置为您想要的频道(默认值=7)。它可以0-100(含),实际上是2400MHz-2500MHz。欲了解更多信息,请转至here。
摘要
微上的main.py
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
应用伪代码
radio.listenOn(2447MHz) #or whatever
@event.recieveRadioMessage()
void function(evt) {
#tell user the data
screen.display(evt.msg)
}