I just want to record some IR signals so I can use them for a project.
Now I have written a short python function to write to TxD the IR code of Button Digit 1: b'\xa1\xf1\x00\xff\xa6'. I have also used a scope to display the wave form, to make sure it is clear an sharp.
Now the signal goes from Rpi TxD to RxD of the IR transceiver, which should emit IR light to the other transceiver, whose TxD connects to Win10 RealTerm RxD pin, showing three bytes 0x00, 0xff, 0x16. Everything looks OK. So next step is to write a short python program to replace the RealTerm.
Now I am thinking of programming a simple, newbie version of lirc.conf file for my air conditioner remote and also my two mini remotes. I am also using python to replace the lirc.rw which using unix socket to write to std.io. Instead I will just Rpi4B buster python 3.7.3 to write to Thonny IDE results panel. (References 37, 38, Appendix H).
Mini Remote Controller #1 2019sep20hkt1732
Digit 1 00FF16
Digit 2 00FF19
Digit 3 00FF0D
Digit 4 00FF0C
Digit 5 00FF18
Digit 6 00FF5E
Digit 7 00FF08
Digit 8 00FF1C
Digit 9 00FF5A
Digit 0 00FF52
Mini Remote Controller #2 2019sep20hkt1732
Digit 1 807F028
Digit 2 807F048
Digit 3 807F068
/ to continue, ...
Now I am using Win10 RealTerm to replace lirc.IRsend and lirc.IRrecord to send and receive/decode IR codes to compile the lirc.conf file for the mini remote controller. So far so good. Next step is to use two python functions to replace the realTerm applications.
I tested my Electrolux air conditioner remote controller and two mini remote controllers and found them emitting code as expected. However, I could not find the lirc.conf file of my air con remote in the lirc remote database.
So I guess I need to use IRsend, IRrecord tools to find the code encoding and compile my own lirc.conf file (Ref 35, 36).
However, I found IRsend and IRrecord rather tedious and low level (socket level!). So I think I would cheat by using Python to emit and receive/decode IR signals, and try to compile a simple lirc.conf file for my mini remote controller.
Old Update 1
I used the remote to send IR codes by pressing buttons by hand
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, *, #, ^, v, <, >, OK
and used Win 10 RealTerm to read the signals from UART interfaced IR
Old Update 2
Now I have set up a test rig for looking at the IR signal generated by the mini remote controller. I press button Digit a and found the UART IR transciver geats the serial (9600, 8n1) byte of 0x00ff16. The scope displaced the raw signal which I guess is part of the NEC 38kHz signal for three hex digits 0x00, 0xff, 0x16. I guess I an use Rpi GPIO pin 17 to read this signal to convert to 0x00ff16, and decoded to mini remote controller button Digit 1.
Old Update 3
Now I have put aside the UART IR transceiver, and only test the module in the middle of the setup. This guy gives raw output for mini remote controller button Digit 1. Next is to connect its output to GPIO pin 17 and use LIRC to print on the console "pules, space, pulse space, ..."
Old Update 4
I installed LIRC and tested remote controller OK (Reference 29, Appendix G below).
Mode 2 command display the pulse space data OK:
$ sudo mode2 -d /dev/lirc0
Using driver default on device /dev/lirc0
Trying device: /dev/lirc0 Using device: /dev/lirc0
Running as regular user pi
pulse 600 ...
Old Update 5
Now I am thinking of compiling config files for LIRC. I read that the LIRC utility IRrecord has problems with different version of raspbian kernels. I worry that it might be a waste of time for me to use IRrecord to compile codes for lirc.config. Perhaps I can cheat by using realTerm to record the codes.
I am thinking of starting with my Electrolux air conditioner remote controller. This is a universal mini remote for many vendors, so should be a good reference and case study.
Now I found my air con remote and other two mini remotes can send IR code to the UART IR reader which receives and decodes and send results to realTerm. It is a bit tedious to manually press buttons and list the data logged in the realTerm terminal emulator. So I think it save time to do both IR sending, receiving, decoding, serial output to text files using python. This is what I will do next.
/ to continue, ...
(1) Update 2019sep12hkt1258
Now I have found in my junk box the IR transceiver kit I bought for hacking my HDMI switch box. I guess the remote is the IR transmitter, the black little guy is the IR receiver, and the clear LED is status LED. I need to search the user guide. I bought the kit from TaoBo which usually does not bother to include and user guide. So I need to search PiHut and Hobby Electronics, ...
(2) Update 2019sep12hkt1509
Now I am reading the Vishay TSOP1838 IR Receiver DataSheet and made a summary.
(3) Update 2019sep12hkt1604
Now I am using the remote to repeatedly sending button numbere 1 to the receiver, and use scope to display the repeat number 1 signal.
And I am studying the NEC IR protocol to see if my cheapie remote and indeed sending NEC codes.
(5) Update 2019sep12hke2243
Now I am thinking of using the following module (Ref 19) to test the IR emitter.
Now that I have more or less understand the NEC 38kHz encoding protocol, and also tested OK the 838 receiver, using the remote to manually generate the IR signals, next step is to look at the IR LED. I am studying Vishay's TSAL6200 940nM IR LED which I think is the most popular. I made a summary below. By the way, it took me some 10 minutes to understand funny looking Fig 9, Intensity vs Angle.
(6) Update 2019sep13hkt2111
Remote Button Number 1 Signal Waveform Display
(7) Update 2019sep13hkt2210
I am testing the UART interfaced IR emitter and received. The remote sends out signal by a stupid human finger pressing Button Number 1. UART then Rx receives the signal below. I need to check if it means any thing.
(8) Update 2019sep14hkt1420
Now I am using the RealTerm terminal emulator (Ref 27) to read the NEC encoded IR signals sent by the manual remote controller, and received by the UART controlled IR receiver.
/ to continue, ...
(1) Creating A Raspberry Pi Universal Remote With LIRC - Austin Stanton 2017mar24, 68,705 views
(2) LIRC - Wikipedia
(3) LIRC Introduction from official LIRC web site
(4) Raspberry Pi Zero Universal Remote Instructable (Steps 23~25 IRLC Installation and Testing)
(5) Raspberry Pis, Remotes & IR Receivers!
(6) TSAL6200e IR LED (If = 100mA Vf = 1.5V) Datasheet – Vishay
(7) TSOP38238 (PC838, HX1838, 30~56) IR Receiver – Vishay
(8) HBS838 IR Receiver Module
(9) HobbyElectronics HX1838 Infrared Remote Control Module and Receiver - £5.4
(10) TaoBao HX1838 Infrared Remote Control Module and Receiver - ¥2
(11) TaoBao LIRC Toys 1 - HX1838 Remote
(12) TaoBao LIRC Toys 2 - NEC UART IR Transcviver
(13) TaoBao LIRC Toys 3 - IR Block Detector
(14) ToaBao LIRC Toys 4 - IR Line Tracer
(15) TaoBao LIRC Toys 5 - IR Transceiver 1
(16) TaoBao LIRC Toys 6 - IR Transceiver 2
(17) NEC Infrared Transmission Protocol - Altium
(18) Parallax IR Receiver Learning Notes
(19) AliExpress IR Infrared Transceiver Decoder Module TTL UART NEC Protocol
(20) TaoBao 5V 红外解码模块 红外无线通信 NEC码 接收发射串口通信 编码模块
(21) Infrared emitting diodes catalog - Farnell
(22) IR333C IR 940NM 100MA Emitter datasheet - EverBright
(23) LIRC Remotes Database
(24) Mitsubish LV16-RS-P fan Spec
(25) Mitsubish LV16-RS-P fan User Guide
(26) Raspberry Pi3 lirc - 2019jun14 update
(27) UART, USB/UART send byte, loop back, blink LED RealTerm terminal emulator, logical level converter
(28) LIRC Configuration Guide
(29) LIRC Installation Procedure Verified OK on Rpi4B buster – StackOverflow 2019aug11
(30) LIRC API/programs and (TCP socket / UDP) tools: Mode2, IRrecord, IRsend ...
(31) YS-IRTM NEC Infrared Codec Module User Guide (pdf)
(32) YS-IRTM NEC Infrared Codec Module User Guide (html)
(33) LIRC Remotes Database - Last update 2017-02
(34) Amazon Electrolux Air Conditioner Remote Controller Y512F2 - $10
(35) LIRC Config File Format
(36) lirc.conf Spec
(37) lirc.irw - User command to send data from Unix domain socket to stdout
(38) lirc.lircrc file format (~/.config/lircrc)
(39) LIRC irrecord Learning Notes - tlfong01
(40) AliExpress 850nm IR LED 1 - US$2/10pcs
(41) AliExpress IR Emitting Diode Catalog
(42) 940nm IR Emitting Diode
(43) 850nm IR Emitting Diode 2
(A) Installing and testing LIRC
This tutorial is a little bit out of date. Ref 29 is more up to date. This answer is too long, hitting the forum's 30k words limit. The summary of the tutorial is snipped - tlfong01 2019sep20hkt1104
(B) LIRC - Wikipedia
LIRC (Linux Infrared Remote Control) is an open source package that allows users to receive and send infrared signals with a Linux-based computer system.
With LIRC and an IR receiver the user can control their computer with almost any infrared remote control (e.g. a TV remote control). The user may for instance control DVD or music playback with their remote control.
(C) LIRC Introduction from official LIRC web site
What is LIRC?
LIRC is a package that allows you to decode and send infra-red signals
of many (but not all) commonly used remote controls.
Recent linux kernels makes it possible to use some IR remote controls
as regular input devices. Sometimes this makes LIRC redundant.
However, LIRC offers more flexibility and functionality and is still
the right tool in a lot of scenarios. The most important part of LIRC
is the lircd daemon which decodes IR signals received by the device
drivers and provides the information on a socket. It also accepts
commands for IR signals to be sent if the hardware supports this.
The user space applications allows you to control your computer with your
remote control. You can send X11 events to applications, start
programs and much more on just one button press.
applications are obvious: Infra-red mouse, remote control for your TV
tuner card or CD-ROM, shutdown by remote, program your VCR and/or
satellite tuner with your computer, etc.
Using lirc on Raspberry Pie is quite popular these days.
Supported remote controls
There are some
config files for remote controls at the remotes database. This is
about 2500 devices and counting. These devices should work with the
general drivers or (if it lacks timing info) the driver used to create
If you can't find your remote control here it does not mean that
your remote control is not supported. It's just that there is no
config file for it yet.
All remote controls that are supported by
learning remote controls i.e., almost any, should also work with LIRC.
Supported capture devices
Besides a remote control you also need a
capture device to read the data from the remote.
focused on home-brew capture hardware connected to the serial or
parallel port. Descriptions how to build such hardware can be found
here. Current versions of LIRC also support a broad range of other
As a starter, you can use the kernel built-in support for
many USB dongles and similar. Besides this LIRC supports basically any
conceivable way to capture your data including serial devices,
parallel ports, sound input etc. You can see the complete list in the
(D) HobbyElectronics HX1838 Infrared Remote Control Module and Receiver - £5.4
A cheap and easy to use Infra Red remote and Receiver module. 17
Buttons provides great flexibility to control devices within a range
of up to 8m
Battery:CR2025 Button batteries (supplied)
Transmission Distance: up to 8m (depending on the surrounding environment,
Sensitivity of receiver Effective
Angle: 60° Static Current: 3~5uA,
Dynamic Current: 3~5mA
Supply Voltage 2.7V - 5.5V
Remote size: 8.5 x 4 x 0.65cm (3.3 x 1.6 x 0.25inch) (L x W x H)
(a) Arduino IR Library
(b) Arduino IR Example Program
(c) Arduino Connection Tutorial
(E) Arduino Infrared Remote Tutorial - astrodan3 528,763 views
Amazon NeoMart Raspberry Pi HX1838 Infrared Remote Control Ir Receiver Module DIY Kit
Sensor uses HX1838, high sensitivity
Operating voltage 5V Digital output
VCC 3.3V-5V voltage
Can direct connected 3V3/5V microcontroller
I/O port has 10K pull-up resistor
(E) Mode2 Command - Show kernel output available for LIRC drivers
The original purpose of this program has been to check operation of home-brew LIRC receiver hardware and
to see the IR waveform of the remote controller without an expensive
. Over time, mode2 has evolved to a generic tool to check what kind of
output the kernel makes available for lirc.
Mode2 will simply print pulse and space lengths
to stdout for drivers supporting LIRC_MODE_MODE2. For drivers supporting LIRC_MODE_LIRCCODE such as TV-cards and the irman driver writes the decoded, integer values.
From version 0.9.4, mode2 can also list the devices available for a
This requires enumeration support which is available in most but not all drivers.
When given the correct driver Mode2 should always work. Without a driver, the --
should always work for /dev/lirc* devices. At the time of writing, USB devices also works in most cases. However, since it is tricky to get the path to the usb device, such ones are normally best accessed using a driver.
Not all drivers requires a device.
Updated: Last change: Jan 2017
(F) Infrared Data Association - Wikipedia
IrDA was popular on PDAs, laptops and some desktops from the late
1990s through the early 2000s. However, it has been displaced by other
wireless technologies such as Wi-Fi and Bluetooth, favored because
they don't need a direct line of sight and can therefore support
hardware like mice and keyboards.
It is still used in some environments where interference makes radio-based wireless technologies unusable.
(G) Installing LIRC on Rpi4B raspbian 10 buster OK
LIRC Installation Notes Rpi4B Raspbian 10 buster tlfong01 2019sep17hkt1617
Reference: LIRC Installation Notes – user1200233 StackOverflow 2019aug11
pi@raspberrypi:~ $ date
Sun 15 Sep 2019 12:36:45 PM HKT
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.58-v7l+ #1245 SMP Fri Jul 12 17:31:45 BST 2019 armv7l GNU/Linux
pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get install lirc
dpkg: error processing package lirc (--configure):
installed lirc package post-installation script subprocess returned error exit status 1
Errors were encountered while processing: lirc
E: Sub-process /usr/bin/dpkg returned an error code (1)
Step 2 Edit /etc/lirc/lirc_options.conf
# Before - tlfong01 2019sep15hkt1245
# driver = devinput
# device = auto
# After - tlfong01 2019sep15hkt1246
driver = default
device = /dev/lirc0
Step 4 /boot/config.txt
# Before tlfong01 2019sep15hkt1255
# Uncomment this to enable the lirc-rpi module
# After tlfong01 2019sep15hkt1255
Step 5 - Reboot
pi@raspberrypi:~ $ date
Sun 15 Sep 2019 01:03:31 PM HKT
pi@raspberrypi:~ $ sudo reboot now
Step 6 - Test remote controller
pi@raspberrypi:~ $ sudo systemctl stop lircd.service
Warning: Stopping lircd.service, but it can still be activated by: lircd.socket
pi@raspberrypi:~ $ sudo mode2 -d /dev/lirc0
Using driver default on device /dev/lirc0
Trying device: /dev/lirc0
Using device: /dev/lirc0
Running as regular user pi
Press Ctrl-C to exit
(H) lirc.conf file format
H.1 lirc.irw - User command to send data from Unix domain socket to stdout
H.2 lirc.lircrc file format (~/.config/lircrc)
prog = ...
remote = ...
button = ...
[button = ...] (optional, for key sequences)
repeat = ...
delay = ...
ignore_first_events = ...
config = ...
[config = ...] (optional, for toggle button behaviour)
mode = ...
flags = ...
Bringing it to the point the above says which program (prog) should do
what (config, mode, flags) if you press a certain button (remote,
button) a specified time (repeat, delay). By default for each remote
signal received the lircrc config file is read from top to bottom and
each matching configuration is executed in order of appearance.
(I) Python Program To Send IR Code to UART IR Transceiver Module (firc71.py)