Raspberry Pi で blink(1) を動作させる

これまで Mac で blink(1) を動作させることを書いてきた。

[Raspberry Pi][Mac] motionEyeOS の動体検知を blink(1) で通知にする – with a Christian Wife
https://wacw.cf/2017/03/06/blink1-with-motioneyeos/

[Raspberry Pi][Mac] motionEye の動体検知を blink(1) で通知にする – with a Christian Wife
https://wacw.cf/2017/04/05/blink1-with-motioneye/

[Raspberry Pi][Mac] motionEye の動体検知を blink(1) で通知にする2 – with a Christian Wife
https://wacw.cf/2017/04/06/blink1-with-motioneye-2/

しかし、本当にやりたかったのは、Raspberry Pi での blink(1) の動作だ。これができれば、motionEye の動体検知をダイレクトに通知できる。これまでは Mac を介するややこしい方法だったのだ。

そして、やっとうまくいったので、その方法を紹介する。使用したのは Raspberry Pi 3 Model B だ。

(1)blink1-tool のソースコード(Source code)をダウンロードしてくる。この際、私は最新の v1.98 でうまくいかなかったので(コンパイルでエラーがでる)、v1.97 をダウンロードしてきた。

Releases · todbot/blink1 · GitHub
https://github.com/todbot/blink1/releases

(2)1のファイルを Raspberry Pi に転送する。
私は ftp で転送したが、そもそも最初から Raspberry Pi で1のファイルをダウンロードすればいいのかも。

(3)2のファイルを解凍。

(4)Terminal で以下のコマンドを実行。

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libusb-1.0-0-dev
sudo apt-get install libudev-dev

参考:
» Raspberry Piでblink(1)を光らす at TechnoCompiler Blog –
http://blog.technocompiler.com/raspberry-piでblink1を光らす/

software installation – couldn’t install libusb library – Raspberry Pi Stack Exchange
http://raspberrypi.stackexchange.com/questions/36234/couldnt-install-libusb-library

(5)cd コマンドで3の commandline ディレクトリへ移動。

(6)make コマンドを実行。

これでインストールが完了だ。

試しに commandline ディレクトリの状態で以下のコマンドを実行してみると赤に光るはず。

sudo ./blink1-tool --red

さらに以下のコマンドでオフにできる。

sudo ./blink1-tool --off

その他のコマンド

・赤を5回点滅
sudo ./blink1-tool --red --blink 5

・青を3秒おきに3回点滅
sudo ./blink1-tool --blue --blink 3 --delay 3000

・2秒ごとに新しい色
sudo ./blink1-tool -t 2000 --random=100

・中断
Ctrl+c

参考:
blink1-tool command-line – blink(1)
https://blink1.thingm.com/blink1-tool/

これで cron に登録したり、バッチファイルを作成したり、そして motionEye の通知など・・・いろいろなことができるようになる!