|
楼主 |
发表于 2013-1-22 17:02:05
|
显示全部楼层
本帖最后由 baoxiaozhong 于 2013-1-22 17:20 编辑
linux0ne 發表於 2013-1-22 15:25
你是否可以翻譯一下這個文章,這是一個用pi結合iphone手機開啟車庫門的創意,也是不錯的,只是E文能力不濟, ...
Hi, this is my first real Raspberry Pi project - SiriProxy running on the Raspberry Pi, along with wiringPi to access the Pi's GPIO pins and turn a relay on/off. The relay is then hooked up to my automatic garage door system. So, I have control of the door with Siri on my iPhone.
大意為作者想要用PI的 GPIO 來控制RELAY的 開關,進而控制車庫的門,(車庫門在中國或是台灣大都是鐵捲門,所以應該是上 停 下 三個RELAY),然後用Siri 語音控制iPhone手機,然後送訊號給 Pi 。
註︰事實上這個並不難,知道GPIO的定義腳,送出 上 停 下三個訊號,可能只難在SIRI的部份,這部份APP可能比較不好寫。
There are probably other ways to do the same thing, such as running a web server on the Pi and have that access the GPIO's etc but I basically cobbled this together for my own needs - and it works fine.
作者認為要利用網頁伺服器架在PI來做。
I am running the Pi as "root" for this whole setup as it just makes things easier for me and I'm using the "wheezy" distro.
Follwing the instructions here: http://www.idownloadblog.com/201 ... oxy-tutorial-video/ should get SiriProxy up and running, if you do follow these instructions then swap commands 11, 12 and 13 to 12, 13, 11. Command 7 by the way will take about 90 minutes to compile on the pi!
作者利用 wheezy 這個OS,取的root 權限進行規劃,並且依照 http://www.idownloadblog.com/201 ... oxy-tutorial-video/ 這個網頁的說明,安裝了 SiriProxy 這個程式。
註:也就是說作者不是自行寫 app,而是利用現有的軟體,讓siri 語音系統能夠直接丟指令給另一個作業系統,但是在另一個作業系統上,你必需安裝GIT 程式,來與 iphone OS 溝通。
Then install wiringPi from https://projects.drogon.net/raspberry-p ... d-install/
GIT 安裝方法在這裡 https://projects.drogon.net/rasp ... wnload-and-install/
依照他提供的方法安裝GIT 在你的Pi 上,其中 WiringPi 是要自已編譯的。
Once these are installed its just a case of modifying the example ruby script included with siriproxy.
Edit this file: /root/SiriProxy/plugins/siriproxy-example/lib/siriproxy-example.rb
在這裡要編輯 /root/SiriProxy/plugins/siriproxy-example/lib/siriproxy-example.rb 這個檔案,將下面的程式碼貼上去。 你可以用 sudo nano /root/SiriProxy/plugins/siriproxy-example/lib/siriproxy-example.rb 新增檔案,按 ctrl+o存檔,ctrl+x 離開,先找到下面的程式碼:
listen_for /test siri proxy/i do
say "Siriproxy is up and running!" #say something to the user!
request_completed #always complete your request! Otherwise the phone will "spin" at the user!
end
然後再換成或加入下面的程式碼:
listen_for /open the garage door/i do
say "Opening the garage door.."
request_completed
system("gpio mode 1 out")
system("gpio write 1 1")
system("sleep 0.5")
system("gpio write 1 0")
end
listen_for /close the garage door/i do
say "Closing the garage door.."
request_completed
system("gpio mode 1 out")
system("gpio write 1 1")
system("sleep 0.5")
system("gpio write 1 0")
end
從上面程式碼中,你可以看到 說 Opening the garage door 就是開門(只能說英文,不能說中文),控制gpio mode 1 輸出, 說 Closing the garage door ,也是控制gpio mode 1 輸出。
註:這裡我認為有點問題,也就是它開和關門,都是同一個點,與我們常用的鐵捲門開關是不同的,。
As you can see, the ruby script is basically calling "system" commands to access wiringPi. Setting a GPIO pin as an output then setting it high for half a second then low again.
作者說這就是一個基本的程式碼,讓你知道它是如何運作的。
You can have siri to call any command you can type in a terminal window, such as a passwordless SSH login to a remote pc to have it shut down or rebooted.
作者說你現在應該會利用siri來呼叫Pi幫你做事了吧,基至你可以用來幫你做電腦上的重啟或是開關機。
listen_for /turn off my laptop/i do
response = ask "Are you sure you want me to shut down your laptop?"
if(response =~ /yes/i)
say "OK, I'll shut it down now.."
system("ssh root@192.168.1.74 shutdown -h now")
else
say "OK, I wont!"
end
request_completed
end
作者又舉個例子,教你如何用siri 的語音來做電腦的SSH 登入,然後關機動作。在這裡是 SSH登入 192.168.1.74,而且是以root帳號進行關機。
作者把他控制車庫門的影片貼在下面網址,你可能要翻牆才看的到:
http://www.youtube.com/watch?v=NUJ5z76Xv5o&feature=youtu.be
註:影片中作者的門,並不是鐵捲門,而是一整個門板上下翻,所以只用一個relay,不過作者提供了很好的控制理念,用語音控制pi(事實上是控制 iOS,也就是說你要先買一台 iOS 設備)幫你完成一些事情。
另外如果看不到影片,請再通知我一下,我再把影片傳到國內網站,不過也沒什麼可以看的,就是你對手機叫開門,然後pi就輸出訊號到relay ,relay 動作輸出訊號給車庫門開關,車庫門就進行開或關的動作。
|
|