【发布时间】:2017-09-02 05:16:58
【问题描述】:
我需要帮助尝试让 Raspberry pi 使用 NRF24l01+ 与 Arduino 通信。
来自 nrf24 库的示例文件无法运行或编译;我已经为 arduino 和 pi 尝试了 5 个库,都没有工作。但现在,我将使用我能找到的最详细的指南:http://invent.module143.com/daskal_tutorial/rpi-3-tutorial-14-wireless-pi-to-arduino-communication-with-nrf24l01/
我正在运行 raspbian(来自新手)。到目前为止,我所做的一切都完全按照本指南告诉我的去做。当我在 pi 上运行程序时(没有发送 arduino,只是为了测试),代码运行出错:
File "sendArduino.py", line 38
if (n > = 32 and n <= 126):
SyntaxError: invalid syntax
所以我完全删除了 if 语句,并取消了 if 语句中的代码行的缩进。当我现在运行它时,我得到一个不同的错误。
Traceback(most recent call last):
File "sendArduino.py", line 11, in <module>
radio.begin(0, 17)
File "/home/pi/Desktop/NRF24L01/lib_nrf24.py", line 373, in begin
self.spidev.open(0, csn_pin)
FileNotFoundError: [Errno 2] No such file or directory
在看到它是 SPI 部分不起作用后,我返回并从教程中重新下载了 python spidev,但它给出了相同的错误。
我真的不知道在这里做什么。事实上,我想做的只是使用这些 nrf24 模块在 arduino 和 raspberry pi 之间发送 20 个 int valuesfr float 值。 (最好在 python 或 cpp 中)。我已经尝试了一堆其他指南,我不知道我做错了什么。
【问题讨论】:
-
如果你使用的是
if (n &gt; = 32 and n &lt;= 126):,很明显为什么它不是一个有效的语法。这只是if (n >= 32 and n <= 126):的 html 编码字符串。不要只是复制/粘贴示例代码。 -
所以大于/小于号的错误是由于复制粘贴造成的?很高兴知道。
-
不仅是复制/粘贴,而且由于该网页上的错误,
&gt;和&lt;在该页面上。复制/粘贴后,您必须将它们修复为正确的运算符。 -
代码仍然没有运行并在更改后给出第二个错误。
-
@KamyarInfinity 谢谢你,你的建议对我有用!
标签: python c++ arduino raspberry-pi