LIRC tests

Active today
Viewed 28 times

I installed the lirc library and I tried to use it, I need this for a project

sudo mode2 -d/dev/lirc0
Using driver default on device /dev/lirc0
Trying device: /dev/lirc0
Please use the --raw option to access the device directly instead through the abstraction layer

If I use with –raw

Using raw access on device /dev/lirc0
Problems: this device is not a LIRC kernel device (it does not
support LIRC_GET_REC_MODE ioctl). This is not necessarily a
problem, but mode2 will not work.  If you are using the --raw
option you might try using without it and select a driver
instead. Otherwise, try using lircd + irw to view the decoded
data - this might very well work even if mode2 doesn't.

I am new to the PI world, I don’t know where the problem is. The receiver? The circuit? Pins? Please help !

CONTEXT: I just want to record some IR signals so I can use them after. This is the circuit I used : https://www.hackster.io/austin-stanton/creating-a-raspberry-pi-universal-remote-with-lirc-2fd581

 New contributor
  • Given that we have no information about the receiver, the circuit, or the pins how are we meant to help? Some context about what you are doing and how is needed. – joan 21 hours ago
  • I’ll edit in the question – Teofil Sandu 21 hours ago
  • @Teofil Sandu, I skimmed through the tutorial hackster.io/austin-stanton/… to see if you missed anything in your installation procedure. Now I am scribbling something and hopefully can make an answer. I am going very slow because I am also a lirc newbie and have not tried this lirc thing before. – tlfong01 20 hours ago
  • @Teofil Sandu, Now I have summarized the installation and testing procedure in Appendix A of my answer. The tutorial is a bit out of date. I worried that the driver or kernel is not compatible with your Rpi3B+ raspbian 9 stretch (let me know if my guess of your config is correct). The tutorial also suggests to read the LIRC user guide. I have never read this guide. So I need to first skim through it, to understand what the hell is “Mode 2”, and should I indeed to use Mode2. – tlfong01 19 hours ago
  • @Teofil Sandu, Now I have googled the LIRC wikipedia but found it too brief. But at least now know what does “LIRC” stands for (See Appendix B). I need to google further to learn more. – tlfong01 19 hours ago
  • I remember some weeks ago I was playing with a HDMI switcher which uses infra red control. So I bought some IR toys to DIT remotes. I was thinking of remotes by hand. But now on second though perhaps I should consider using Rpi LIRC to control those remotes instead by my stupid human hand. So I am visiting the post to refresh my memory. raspberrypi.stackexchange.com/questions/99823/… – tlfong01 19 hours ago
  • @Teofil Sandu, my old answer to the HDMI switcher question includes some references of IR emitter and detector. I found one instructable very good. I have included it in my answer – Reference 4. There is a detailed description on how to install and test LIRC (Steps 23~25). Now I am taking a break and carry on tomorrow. You might like to comment on my progress so far. – tlfong01 18 hours ago
  • @Teofil Sandu, This PiHut tutorial is also very good. thepihut.com/blogs/raspberry-pi-tutorials/… – tlfong01 18 hours ago
  • Okay I will try it, thanks a lot ! – Teofil Sandu 17 hours ago
  • @Teofil Sandu, Good, so you can read my testing notes and point out if I make any mistakes, miss anything, or you would like to make counter suggestions. Now I have google around and concluded that almost everybody is using the same IR receiver chip call XX838 (Reference 7). So I will search my junk box for this little guy. I found that the PiHut tutorial is also using this thing. So I now go look for this 838 guy. See you later. – tlfong01 5 hours ago
  • @Teofil Sandu, I luckily found a 838 toy kit in my junk box. So I will start testing it. See Appendix (D) for more details. – tlfong01 2 hours ago


I am installing LIRC and found a problem. Can you help?


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, …

lirc toy

Updatge 2019sep12hkt1509

Now I am reading the Vishay TSOP1838 IR Receiver DataSheet and made a summary.

vishay tsoip1838

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.

repeat sending button number 1

And I am studying the NEC IR protocol to see if my cheapie remote and indeed sending NEC codes.

NEC IR protocol

/ 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 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


(A) Installing and testing LIRC

(1) Raspberry Pi 2
(2) 940nm IR LED 40deg - 40 degree viewing angle. Bright and tuned to 940nm wavelength.
(3) 38khz IR Receiver - Receives IR signals at remote control frequencies
(4) PN2222 Transistor - Transistor to help drive IR LED
(5) 10k Ohm resistor - Resistor that goes between RPI GPIO and the PN2222 transistor

sudo apt-get install lirc
Add to your /etc/modules file by entering the command below:
sudo cat >> /etc/modules <<EOF
lirc_rpi gpio_in_pin=23 gpio_out_pin=22
sudo cat > /etc/lirc/hardware.conf <<EOF 

# /etc/lirc/hardware.conf
# Arguments which will be used when launching lircd
# Don't start lircmd even if there seems to be a good config file
# Don't start irexec, even if a good config file seems to exist.
# START_IREXEC=false  
# Try to load appropriate kernel modules
# Run "lircd --driver=help" for a list of supported drivers.
# usually /dev/lirc0 is the correct setting for systems using udev
# Default configuration files for your hardware if any
Edit your /boot/config.txt by entering the command below:
cat >> /boot/config.txt <<EOF
Now restart lircd so it picks up these changes:
sudo /etc/init.d/lirc stop
sudo /etc/init.d/lirc start
***Testing the IR Receiver***
Testing the IR receiver is relatively straightforward. Run these two commands to stop lircd and start outputting raw data from the IR receiver:
sudo /etc/init.d/lirc stop
mode2 -d /dev/lirc0
Point a remote control at your IR receiver and press some buttons. You should see something like this:
space 16300
pulse 95
space 28794
pulse 80
space 19395
pulse 83
space 402351
pulse 135
space 7085
pulse 85
space 2903
If you don’t, something is probably incorrectly configured. Triple check that you’ve connected everything properly and haven’t crossed any wires. I highly recommend referring to the schematics I linked to above. There is also some trouble shooting advice in the RaspberryPi Forum thread I linked to above. Finally - you may want to do this in a dark room. I found that my desk lamp and overhead light would cause the IR receiver to think it was receiving valid signals.
***Testing the IR LED***   
You’re going to need to either find an existing LIRC config file for your remote control or use your IR receiver to generate a new LIRC config file(find existing remote profiles here). In my case, I created a new LIRC config file. To do this, read the documentation on the irrecord application that comes with LIRC.
When using irrecord it will ask you to name the buttons you’re programming as you program them. Be sure to run irrecord --list-namespace to see the valid names before you begin.
Here were the commands that I ran to generate a remote configuration file:
# Stop lirc to free up /dev/lirc0
sudo /etc/init.d/lirc stop
# Create a new remote control configuration file (using /dev/lirc0) and save the output to ~/lircd.conf
irrecord -d /dev/lirc0 ~/lircd.conf  
# Make a backup of the original lircd.conf file
sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf    
# Copy over your new configuration file
sudo cp ~/lircd.conf /etc/lirc/lircd.conf    
# Start up lirc again
sudo /etc/init.d/lirc start    
Once you’ve completed a remote configuration file and saved/added it to /etc/lirc/lircd.conf you can try testing the IR LED. We’ll be using the irsend application that comes with LIRC to facilitate sending commands. You’ll definitely want to check out the documentation to learn more about the options irsend has.    
Here are the commands I ran to test my IR LED (using the “Roku” remote configuration file I created):    
# List all of the commands that LIRC knows for 'Roku'
irsend LIST Roku ""    
# Send the KEY_POWER command once
irsend SEND_ONCE Roku KEY_POWER    
# Send the KEY_VOLUMEDOWN command once
I tested that this was working by pointing the IR led at my Roku receiver and testing whether I could turn it on and press enter.    
sudo cat > /etc/lirc/hardware.conf <<EOF     
# /etc/lirc/hardware.conf
# Arguments which will be used when launching lircd
# 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
# Run "lircd --driver=help" for a list of supported drivers.
# usually /dev/lirc0 is the correct setting for systems using udev    
# Default configuration files for your hardware if any    

(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.

The possible 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 them.

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.

Former versions 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 hardware.

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 left pane.


(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


Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: