Raspberry PI Arduino通讯
Raspberry PI Arduino communication
我有一个 Raspberry Pi 和 Arduino 通过 UART(TxRx) 连接,我有一个网站 HTML 托管在 rPi 上。
当在网站上按下按钮时,我需要做什么,字符串将通过 UART 发送到 arduino。
我已经尝试通过命令 echo test > /dev/ttyAMA0
从 rPi 的终端发送字符串,测试是我想要发送的字符串并且它有效。
您需要 rPi 上的 CGI 脚本。当用户的网络浏览器转到该页面(或通过按下按钮定向到该页面)时,CGI scirpt 将 运行 在 rPi 上,它可以将数据从串行端口输出。这是一个随机 CGI tutorial if it helps, but you should look at the docs for whatever webserver your running (probably apache?)
是的,我是 运行 一个 apache 网络服务器。
我忘了写我已经尝试创建一个包含 echo
命令的 .sh 文件。
这是我创建的 .sh 脚本:
#!/bin/sh
echo 1 > /dev/ttyAMA0
echo "Content-type: text/html"
echo ""
echo "<html><head><title>DzAnej Systems"
echo "</title></head><body>"
echo "<meta http-equiv=\"refresh\" content=\"0; url = http://192.168.1.3/dashboard.html\" />"
echo "</body></html>"
此脚本将 1
发送到 /dev/ttyAMA (Arduino)
return 将用户转到上一页...
底部工作正常(return 到上一页)但是 echo
命令不知何故不起作用...
我有一个 Raspberry Pi 和 Arduino 通过 UART(TxRx) 连接,我有一个网站 HTML 托管在 rPi 上。
当在网站上按下按钮时,我需要做什么,字符串将通过 UART 发送到 arduino。
我已经尝试通过命令 echo test > /dev/ttyAMA0
从 rPi 的终端发送字符串,测试是我想要发送的字符串并且它有效。
您需要 rPi 上的 CGI 脚本。当用户的网络浏览器转到该页面(或通过按下按钮定向到该页面)时,CGI scirpt 将 运行 在 rPi 上,它可以将数据从串行端口输出。这是一个随机 CGI tutorial if it helps, but you should look at the docs for whatever webserver your running (probably apache?)
是的,我是 运行 一个 apache 网络服务器。
我忘了写我已经尝试创建一个包含 echo
命令的 .sh 文件。
这是我创建的 .sh 脚本:
#!/bin/sh
echo 1 > /dev/ttyAMA0
echo "Content-type: text/html"
echo ""
echo "<html><head><title>DzAnej Systems"
echo "</title></head><body>"
echo "<meta http-equiv=\"refresh\" content=\"0; url = http://192.168.1.3/dashboard.html\" />"
echo "</body></html>"
此脚本将 1
发送到 /dev/ttyAMA (Arduino)
return 将用户转到上一页...
底部工作正常(return 到上一页)但是 echo
命令不知何故不起作用...