LoginSignup
5
8

More than 5 years have passed since last update.

Raspberry Pi と irMagician(赤外線モジュール)で家電を操作する

Posted at

Raspberry Pi と irMagician(赤外線モジュール)で家電を操作する

リモコンで操作可能な家電を、Raspberry Pi (赤外線モジュール)から操作します。
今回の赤外線モジュールは、大宮技研の irMagician を使用します。

irMagician – 高機能/低価格赤外線リモコン | 大宮技研 合同会社

Raspberry Pi の初期設定

設定ファイル編集

Raspberry Pi の「/boot/cmdline.txt」に記載されている「console=serial0,115200」を削除します。

$ sudo vi /boot/cmdline.txt
編集前の /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait splash plymouth.ignore-serial-consoles
編集後の /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait splash plymouth.ignore-serial-consoles

再起動

irMagician をUSB接続して再起動します。

$ sudo reboot

確認

「ls /dev/ttyACM0」を実行し、「ttyACM0」が表示されれば使用準備が整いました。

$  ls /dev/ttyACM0
/dev/ttyACM0

スクリプトのダウンロード

python から irMagician を利用するためのスクリプト「irmcli.py」をダウンロードします。
https://github.com/netbuffalo/irmcli.git

赤外線の学習

リモコンの赤外線データをモジュールに学習させます。
以下のコマンドを実行の上、赤外線モジュールにリモコンの赤外線を照射します。

$ python irmcli.py -c
Capturing IR...
'

赤外線の照射

学習させた赤外線を、赤外線モジュールから照射します。

$ python irmcli.py -p
Playing IR...
... Done !

学習させた赤外線を照射しても、家電を操作できない場合があります。
エアコンが irMagician(赤外線モジュール)で操作できない

赤外線データの保存

モジュールが学習した赤外線データをJSONファイルとして Raspberry Pi に保存します。

 $ python irmcli.py -s  -f filename.json
Saving IR data to filename.json ...
Done !
filename.json
{"postscale": 100, "freq": 38, "data": [175, 1, 205, 135, 66, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 24, 9, 7, 9, 24, 9, 24, 9, 24, 9, 24, 9, 24, 9, 24, 9, 7, 9, 24, 9, 7, 9, 7, 9, 7, 9, 7, 9, 24, 9, 7, 9, 7, 9, 7, 9, 24, 9, 24, 9, 24, 9, 24, 9, 7, 9, 24, 9, 24, 9, 24, 9, 86, 135, 33, 9], "format": "raw"}

保存した赤外線データの照射

Raspberry Pi に保存したデータをもとに赤外線を照射します

$ python irmcli.py -p -f filename.json
Playing IR with filename.json ...
... Done !

参考

irMagicianをSiriから使う | 大宮技研 合同会社

5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8