转:http://www.waveshare.net/study/article-622-1.html
https://my.oschina.net/funnky/blog/147094
https://www.freemindworld.com/blog/2013/130316_raspberry_pi_with_remote_control.shtml
http://forum.armbian.com/index.php/topic/1953-guide-configuring-orange-pi-pc-to-receive-irinfrared/
http://www.withonly.com/?p=515
http://www.codesec.net/view/483862.html
http://tieba.baidu.com/p/4113304506
树莓派
红外接线第一针接gpio18,第二针接gnd,第三针接3.3v
modprobe lirc_rpi报错的话
打开/boot/config.txt最后一行加上dtoverlay = lirc-rpi
http://bbs.csdn.net/topics/391944909
http://blog.sina.com.cn/s/blog_6b2252130102w4cj.html
opi armbian
先测试下,sudo modprobe sunxi_ir_rx
sudo apt-get install evtest安装调试工具
cat /proc/bus/input/devices查看哪个是红外设备
然后执行evtest,按下遥控器,如果没问题会有输出
OrangePi 红外
#安装lirc
apt-get install lirc
apt-get install evtest
#修改 /etc/lirc/hardware.conf 文件:
########################################################
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS=""
#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD=false
#Don't start irexec, even if a good config file seems to exist.
#START_IREXEC=false
#Try to load appropriate kernel modules
LOAD_MODULES=true
# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="sunxi_cir"
# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
########################################################
/etc/init.d/lirc stop
/etc/init.d/lirc start
#测试,随便按遥控器,如果出现一堆的pluse和space,表示工作正常
mode2 -d /dev/lirc0
接下来就可以录制按键了:
#查看可以使用的key列表,随后输入key必须在这列表里
irrecord --list-namespace
#录制前需要关闭lirc
sudo /etc/init.d/lirc stop
#开始录制,开始后需要随便按键通过2*80的调试
#按后会出现...,第一排长按,第二排点按
cd ~/
irrecord -n -d /dev/lirc0 lircd.conf
一开始都随便按,直到输入名称如KEY_1回车后,输入如数字1表示录制1
#当前路径就生成了 lircd.conf 文件,复制到 /etc/lirc/ 下
sudo cp lircd.conf /etc/lirc/lircd.conf
启动并调试:
sudo /etc/init.d/lirc start
#使用irw命令测试
sudo irw
然后按遥控器上刚才录制的按键比如数字1
输出类似这样,说明正确
0000000032a6807f 00 KEY_1 tv
0000000032a640bf 00 KEY_2 tv
0000000032a6c03f 00 KEY_3 tv
接下来就是 最后一步,接受红外线信号,并执行相关命令
lircrc出场
nano /etc/lirc/lircrc
#/etc/lirc/lircrc 内容
begin
prog = irexec #这个可随意
button = KEY_1 #按钮的名称
config = sudo reboot #执行的命令
end
begin
prog = irexec
button = KEY_2
config = echo "hello lirc one!"
end
然后运行irexec命令,接受信号,执行命令
写入对应命令的项,格式如下:
--------------------------------------------
begin
prog = irexec
remote = *
button = power
repeat = 0
config = echo "shutdown now!";halt;
end
begin
prog = irexec
remote = lirc.conf
button = mute
repeat = 0
config = echo "now mute"
end
--------------------------------------------
begin~end表示一个独立的配置块。
prog域的值表示使用该配置块的程序名称。
remote的值表示使用的遥控器名称(参见lircd.conf中的定义)。只有一个遥控时也可为*
button 的值表示遥控器按键名称(参见lircd.conf中的定义)。
repeat 的值表示按键的重复次数。
config 的值表示该按键对应的字符串,该字符串可以被prog定义的应用程序获得。
我的orange pi lite
root@orangepilite:~# cat lircd.conf
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Wed Dec 7 17:05:56 2016
#
# contributed by
#
# brand: lircd.conf
# model no. of remote control:
# devices being controlled by this remote:
#
begin remote
name lircd.conf
bits 32
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 9045 4523
one 553 1692
zero 553 565
ptrail 565
repeat 9047 2264
gap 141552
toggle_bit_mask 0x0
begin codes
KEY_1 0x20DFC837
end codes
end remote
root@orangepilite:~# cat /etc/lirc/lircrc
begin
prog = irexec
button = KEY_1
config = echo "hello lirc one!";ls /root; ssh -p 22 pi@192.168.0.119 'uptime'
end