树莓派3B+搭配Buster版本系统进行红外遥控开发

2023-05-16

一、配件清单

  • 树莓派:3B+
  • 系统版本:Buster
  • 红外接收器:VS1838B

  • 红外遥控器:未知型号(标有ar mp3字样)

 

  • 杜邦线若干

二、 线路组合准备

根据网上查找的VS1838B红外接收器的引脚定义

OUTGNDVCC
信号输出接地电源输入

将红外接收器连接到树莓派对应引脚,此次OUT对应的IO引脚为 BCM2

三、安装服务,进行配置

官方文档:http://lirc.org/html/configuration-guide.html

安装LIRC服务

sudo apt-get install lirc

注意,在某些教程中,可能会让你修改 /etc/lirc/hardware.conf 等文件,但根据最新版本的文档,无需编辑这个文件

需要进行以下操作

  • 将lirc的配置dist文件转为有效配置文件
sudo cp /etc/lirc/lirc_options.conf.dist /etc/lirc/lirc_options.conf
sudo cp /etc/lirc/lircd.conf.dist /etc/lirc/lircd.conf
sudo cp /etc/lirc/lircd.conf.d/devinput.lircd.conf.dist /etc/lirc/lircd.conf.d/devinput.lircd.conf
  •  修改lirc_options.conf文件
vi /etc/lirc/lirc_options.conf

将以下内容

driver          = devinput
device          = auto

替换为 

driver          = default
device          = /dev/lirc0
  • 编辑/boot/config.txt
sudo vi /boot/config.txt
  •  找到 dtoverlay 配置项,修改对应的GPIO接口(使用vim编辑器时,可按 / 键后输入dtoverlay直接查找)
#下面的gpio_pin=值为树莓派与接收器OUT端连接的gpio口
dtoverlay=gpio-ir,gpio_pin=2
#下面的配置是用于发送使用,当前只使用接收,直接注释
#dtoverlay=gpio-ir-tx,gpio_pin=17
  • 确认lirc服务工作正常
sudo systemctl stop lircd
sudo systemctl start lircd
sudo systemctl status lircd
  • 重启树莓派
sudo shutdown -r 0

 三、测试接收服务

  • 首先关闭lirc服务
sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0

 使用发射器对准接收器随便按几个按钮,会看见终端输出类似以下内容

space xxxxx
pulse xxx
space xxxxx
pulse xxx
space xxxxx

证明接收器工作正常

四、配置接收器编解码文件

有两种方式可以进行配置

  1. 使用 irrecord 指令 录制
  2.  使用现成配置文件

irrecord指令录制

irrecord录制指令如下

  • 查看命名空间
irrecord -list-namespace
  • 进行录制
irrecord -d /dev/lirc0 /etc/lirc/lircd.conf.d/test.lircd.conf

直接获取配置文件

根据stack overflow上的讨论,和本人实际测试,因为遥控器特殊及新版本lirc录制算法的原因,实际录制出来的文件无法正常工作

推荐使用以下方式获取配置文件

  1. 使用 irdb-get 工具
  2. 官方配置文件库下载 http://lirc.sourceforge.net/remotes/
  3. 克隆git仓库获取 https://git.code.sf.net/p/lirc-remotes/code

 

  • 对应本文所示的控制器,经测试有效的配置文件如下
sudo vi /etc/lirc/lircd.conf.d/carmp3.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 Sat Mar  7 11:28:13 2015
# running on a Raspberry Pi 2 with Raspbian GNU/Linux 7 (Kernel 3.18.7-v7+)
# and then edited
#
# contributed by Martin Kilgus
#
# brand:                        No-Name YK-001 as included in "GPIO Electronics Starter Kit" sourced from eBay
# model no. of remote control:  YK-001
# devices being controlled by this remote: universal
#
#
# Remote layout:
# (it appears that the same remote is also available with
#  different labels printed on the buttons)
#
# +----------------------------------+
# |                                  |
# | Power      Mode       Mute       |
# |                                  |
# | Previous   Next       Play/Pause |
# |                                  |
# | (Vol)-     Vol(+)     EQ         |
# |                                  |
# | 0          100+       Back       |
# |                                  |
# | 1          2          3          |
# |                                  |
# | 4          5          6          |
# |                                  |
# | 7          8          9          |
# |                                  |
# +----------------------------------+

begin remote

  name  car-mp3
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9007  4448
  one           581  1658
  zero          581   542
  ptrail        578
  repeat       9005  2231
  pre_data_bits   16
  pre_data       0xFF
  gap          107592
  toggle_bit_mask 0x0

      begin codes
          KEY_CHANNELDOWN                0xA25D # Symbol "Power", color of button: red
          KEY_CHANNEL                 0x629D # Text "Mode", color of button: black
          KEY_CHANNELUP                 0xE21D # Symbol "Mute", color of button: black
          KEY_PREVIOUS             0x22DD # Symbol "|<<" / Text "Prev", color of button: red
          KEY_NEXT                 0x02FD # Symbol ">>|" / Text "Next", color of button: red
          KEY_PLAYPAUSE            0xC23D # Symbol ">||" / Text "Play/Pause", color of button: red
          KEY_VOLUMEDOWN           0xE01F # Symbol "-" / Text "Vol-", color of button: black
          KEY_VOLUMEUP             0xA857 # Symbol "+" / Text "Vol+", color of button: black
          KEY_EQUAL                0x906F # Text "EQ", color of button: black
          KEY_0                    0x6897 # Text "0", color of button: white
          KEY_100+                0x9867 # Text "100+", color of button: white
          KEY_200+                 0xB04F # Symbol "Return", color of button: black
          KEY_1                    0x30CF # Text "1", color of button: white
          KEY_2                    0x18E7 # Text "2", color of button: white
          KEY_3                    0x7A85 # Text "3", color of button: white
          KEY_4                    0x10EF # Text "4", color of button: white
          KEY_5                    0x38C7 # Text "5", color of button: white
          KEY_6                    0x5AA5 # Text "6", color of button: white
          KEY_7                    0x42BD # Text "7", color of button: white
          KEY_8                    0x4AB5 # Text "8", color of button: white
          KEY_9                    0x52AD # Text "9", color of button: white
      end codes

end remote
  • 重启lirc服务,即可正常使用
sudo systemctl restart lircd

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

树莓派3B+搭配Buster版本系统进行红外遥控开发 的相关文章

随机推荐

  • WebSocket 前端 Vue 长连接 断线重连

    文章目录 WebSocket简介额外注意点 实际开发代码创建WebSocket工具文件创建WebSocket连接初始化WebSocket心跳防止断开连接收到信息后区分业务信息和心跳信息定义关闭连接的方法 xff0c 方便登出时使用将关闭和创
  • CentOS7下安装mysql5.7

    更多精彩技术分享请浏览本人博客 xff1a https blog csdn net wohiusdashi 一 安装YUM Repo 1 由于CentOS 的yum源中没有mysql xff0c 需要到mysql的官网下载yum repo配
  • VSCode 安装 Go 插件、gopls 是个什么东东

    原文地址 xff1a VSCode 开发 Go 程序也可以和 GoLand 一样强大 VSCode 建议你启用 gopls xff0c 它到底是个什么东东 xff1f
  • RPC 笔记(05)— socket 通信(单线程服务器)

    1 Python 标准库 1 1 socket 提供 RPC 服务的网络通信功能 xff0c 方便用户编写 tcp udp 相关的代码 两个不同机器的进程需要通信时 xff0c 可以通过 socket 来传输数据 客户端 API xff0c
  • ubuntu的文件系统结构

    一 ubuntu 系统的根目录 Linux 系统下 就是系统的根目录 xff0c 所有的目录是由根目录衍生出来的 进入根目录的方法 xff1a 终端输入 34 cd 34 命令 如下所示 xff1a 二 ubuntu 文件系统结构 bin
  • 八、安装go-cqhttp+QQBot教程+对接青龙

    首先要有一台云服务器 阿里云 点击跳转 腾讯云 点击跳转 QQ交流群 244016111 上车 点击跳转 或 关注公众号 汤姆的日记 已更新全套需要点击跳转 一 服务器基础设置及宝塔 43 docker安装教程 二 青龙面板安装教程 43
  • c语言中d和i有什么区别

    c语言中d和i的区别 xff1a 在 printf 格式串中使用时 xff0c 没有区别 在 scanf 格式串中使用时 xff0c 有点区别 xff0c 如下 xff1a 在scanf格式中 xff0c d 只与十进制形式的整数相匹配 而
  • CentOS7.2 安装GitLab服务器

    01 yum install y curl policycoreutils python openssh server 02 systemctl enable sshd 03 systemctl start sshd 04 wget htt
  • STM32CubeMX生成STM32L073RZT6 BootLoader程序

    1 环境 xff1a Windows10 xff0c STM32CubeMX6 0 0 xff0c Keil5 25 单片机为STM32LRZT6 196KBytes Flash xff0c 20KBytes RAM 2 功能要求 设计Bo
  • RHEL7 的注册

    安装RHEL7后 xff0c 在没有注册的时候 xff0c YUM软件仓库是不能使用的 xff0c 需要注册后才可以使用 xff0c 但是RHEL是商用版系统 xff0c 需要购买授权 在网上查找后 xff0c 发现RHEL有个开发者订阅
  • linux下查看可执行文件的相关信息

    1 file 可执行文件 可查看可执行文件是ARM架构还是X86架构 2 nm 可执行文件 可查看文件中的符号 xff0c 包括全局变量 xff0c 全局函数等 3 ldd 可执行文件 可查看文件执行所需要的动态库 4 strings 可执
  • linux下查看系统内存使用情况的几个命令

    最近在客户现场运行的arm linux嵌入式设备出现了死机情况 xff0c 由于接触linux嵌入式设备时间不长 xff0c 遇到该问题后觉得束手无措 后领导提示说查看其他没有死机设备的系统资源使用情况 xff0c 下面介绍下我用到的那些命
  • Linux下获取CPUID、硬盘序列号

    在很多系统软件的开发中 xff0c 需要使用一些系统的唯一性信息 所以 xff0c 得到主机的CPUID 硬盘序列号及网卡的MAC地址 xff0c 就成个一件很重要的应用 需要的准备知识有 xff1a 1 GCC的嵌入汇编 xff0c 具体
  • Thinkpad MORFFHL滑鼠接收器配对

    1 接收器插入电脑 2 关闭鼠标 3 同时按住鼠标左键 右键 滚轮打开电源开关 xff0c 3个键按住3秒左右松手 4 同时按下3个按键 xff0c 指示灯橘色闪烁 5 再次同时按下3个按键 xff0c 配对结束 6 关闭鼠标重新打开 移动
  • Vbox6.04 Debian虚拟机安装增强工具

    环境 xff1a VBox6 04 Debian9 6 64位 在创建Vbox虚拟机后安装好Debian系统 开始操作前请确保虚拟机可以上网 1 root用户登录Debian xff1b 2 uname r 查看debian内核版本 3 a
  • Debian系统源码安装usb网卡驱动

    系统为debian 9 6 64位版本 xff0c 安装网卡驱动为asix的 AX88772B芯片 1 安装系统build模块 apt get install linux image uname r linux headers uname
  • Ubuntu根目录下各文件夹的作用

    Ubuntu上常识和常用命令 xff1a 1 Ubuntu文件结构 在ubuntu上硬盘的目录和Windows上不同 xff0c Windows可以根据自己的需求分不同的盘符 xff0c 但ubuntu上只有一个盘 xff0c 从根目录开始
  • linux中的export命令介绍

    export Linux中export命令介绍 xff0c 三种方法设置环境变量 CSDN博客
  • 一位 JavaScript 铁杆粉眼中的 Rust

    以下为译文 xff1a 我使用 Rust 编写了一些小工具 xff0c 而且觉得很有乐趣 我的日常工作需要大量使用 JavaScript xff0c 而 Rust 给我一种非常熟悉的感觉 xff0c 因此我决定尝试一下Rust 但与此同时
  • 树莓派3B+搭配Buster版本系统进行红外遥控开发

    一 配件清单 树莓派 xff1a 3B 43 系统版本 xff1a Buster红外接收器 xff1a VS1838B 红外遥控器 xff1a 未知型号 xff08 标有ar mp3字样 xff09 杜邦线若干 二 线路组合准备 根据网上查