Mindstorms EV3如何通过蓝牙与我的电脑通信?

2024-10-01 05:02:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用micropython2编写一个EV3。我在笔记本电脑上运行了另一个Python3程序,这个程序应该以无线方式向EV3发送数据。可以通过蓝牙吗?如果不可能,我该怎么做


Tags: 程序方式发送数据python3笔记本电脑无线ev3micropython2
2条回答

我不知道这个问题的答案,我也没有一个EV3砖头来尝试这个。由于你还没有说你已经尝试了什么,我想我会分享一些关于尝试实验的想法

我查看了关于蓝牙的ev3 micropython文档,搜索结果如下: https://pybricks.github.io/ev3-micropython/messaging.html

这看起来蓝牙通信可能基于蓝牙串行端口配置文件(SPP),因此SPP客户端是否可以通信值得一看

第一个实验可能是在EV3上启动一个BluetoothMailboxServer,看看您是否能够从PC上与它配对?(顺便问一下,你在笔记本电脑上运行的是什么操作系统?)

如果您有Windows,请执行此URL帮助中的以下说明: https://www.instructables.com/id/Raspberry-Pi-Bluetooth-to-PuTTY-on-Windows-10/

On your Windows 10 Desktop/ Laptop first enable the Bluetooth transceiver. Select Start, Settings, then Devices. At this point resist the intuitive temptation to Add bluetooth or other device. Instead, scroll down to 'Related settings', and select Devices and printers. Find your Desktop/ Laptop under 'Devices', right click it, then select Bluetooth settings from the pop up menu. This brings up the 'Bluetooth settings dialogue:

Select the COM ports tab, then select Add... to bring up the 'Add COM port' dialogue. Here we select the 'Outgoing' radio button, and then click on Browse... This will yield the 'Select Bluetooth Device' dialogue. All going well, you should see your Raspberry Pi listed as a discovered device. Select the Raspberry Pi device listed, and click OK twice. This should take you back to the COM ports tabbed dialogue, and list a COM port that is now associated with the Windows 10/ Raspberry Pi pairing. Take note of which COM port has been assigned.

在Linux笔记本电脑上,以这种方式创建客户端是否有效: http://blog.kevindoran.co/bluetooth-programming-with-python-3/

Linux上的另一种选择是通过以下方式创建客户端: https://bluedot.readthedocs.io/en/latest/btcommapi.html#bluetoothclient

如果您有Android手机,您可以尝试从手机与EV3服务配对,然后尝试连接此SPP应用程序: https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal

另一种选择是BluetoothMailboxServer可能正在使用蓝牙低能量(BLE)。如果是这样,那么如果你的笔记本电脑上有最新版本的Chrome浏览器,你可以找到更多信息。转到URLchrome://bluetooth-internals/#devices并执行start scan。EV3设备启动了吗

关于EV3和运行在笔记本电脑上的python代码之间的通信, 首先,我们需要使用命令安装模块python-ev3dev2:

pip install python-ev3dev2

关于它的用法,您可以参考ev3dev2

确保您的ev3dev设备已打开,并且与主机有网络连接。在这里,蓝牙可以工作,您可以参考一个演示:vscode-hello-python.

相关问题 更多 >