Uncategorized

LIRC Discussion Record

Asked 
Active today
Viewed 119 times
2
1

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
1

Question

I just want to record some IR signals so I can use them for a project.

Short Answer

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

remote generated IR code

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.

ir test 1

ir test 2

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

ir test 3

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

space 16777215

pulse 8936

space 4383

pulse 600 …

/ to continue, …

Long Answer

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

lirc toy

(2) Update 2019sep12hkt1509

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

vishay tsoip1838

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

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

(5) Update 2019sep12hke2243

Now I am thinking of using the following module (Ref 19) to test the IR emitter.

uart ir transceiver

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.

IR Emittinbg  LED

(6) Update 2019sep13hkt2111

Remote Button Number 1 Signal Waveform Display

remote signal button number 1

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

uart ir receiver

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

ir decoder

/ to continue, …

References

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

Appendices

(A) Installing and testing LIRC

***Materials*** 
(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

***Installation***
sudo apt-get install lirc
Add to your /etc/modules file by entering the command below:
sudo cat >> /etc/modules <<EOF
lirc_dev
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
LIRCD_ARGS="--uinput"
# 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="lirc_rpi"
# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
######################################################## 
EOF
Edit your /boot/config.txt by entering the command below:
cat >> /boot/config.txt <<EOF
dtoverlay=lirc-rpi,gpio_in_pin=23,gpio_out_pin=22
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
irsend SEND_ONCE Roku KEY_VOLUMEDOWN
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
LIRCD_ARGS="--uinput"  
# 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="lirc_rpi"    
# Default configuration files for your hardware if any    
LIRCD_CONF=""
LIRCMD_CONF=""
EOF

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

.END

(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

Features

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)

Documents

(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

Description

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 oscilloscope

. 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 given driver.

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 —

raw option

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
https://stackoverflow.com/questions/57437261/setup-ir-remote-control-using-lirc-for-the-raspberry-pi-rpi

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)
pi@raspberrypi:~ $ 

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
#dtoverlay=lirc-rpi

# After  tlfong01 2019sep15hkt1255
dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# ****************************************************************************

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

space 16777215
pulse 8936
space 4383
pulse 600
space 512
pulse 600
space 511
pulse 602
space 512
pulse 633
space 478
pulse 631
space 480
pulse 370
pulse 128827
space 13678819
space 766560
pulse 8821
space 4455
pulse 567
space 569
pulse 541
space 544
pulse 541
space 568
pulse 542
space 570
pulse 563
space 544
pulse 542
space 568
pulse 541
space 570
pulse 540
space 570
pulse 540
space 1657
pulse 567
space 1632
pulse 567
space 1633
pulse 539
space 1658
pulse 541
space 28920
pulse 8849
space 4427
pulse 542
space 569
pulse 566
space 543
pulse 544
space 566
pulse 568
space 541
pulse 542
space 568
pulse 543
space 568
pulse 543
space 568
pulse 541
space 570
pulse 539
space 1659
pulse 542
space 1665
pulse 547
space 1664
pulse 536
space 1660
pulse 540
space 1666
pulse 542
space 1662
pulse 536
space 1660
pulse 563
space 1636
pulse 564
space 544
pulse 564
space 1643
pulse 560
space 1638
pulse 559
space 544
pulse 542
space 1656
pulse 542
space 570
pulse 540
space 572
pulse 540
space 566
pulse 543
space 1660
pulse 537
space 572
pulse 538
space 570
pulse 556
space 1645
pulse 535
space 568
pulse 540
space 1658
pulse 541
space 1657
pulse 541
space 1658
pulse 541
pulse 130091
space 9590140
space 977218
pulse 8823
space 4456
pulse 541
space 571
pulse 539
space 595
pulse 515
space 594
pulse 515
space 571
pulse 564
space 545
pulse 540
space 568
pulse 542
space 568
pulse 541
space 569
pulse 541
space 1661
pulse 539
space 1656
pulse 543
space 1656
pulse 542
space 1656
pulse 543
space 1661
pulse 538
space 1658
pulse 540
space 1659
pulse 540
space 1663
pulse 536
space 569
pulse 540
space 1657
pulse 540
space 1660
pulse 564
space 544
pulse 541
space 1657
pulse 541
space 569
pulse 540
space 569
pulse 541
space 567
pulse 542
space 1659
pulse 539
space 570
pulse 541
space 593
pulse 516
space 1657
pulse 540
space 595
pulse 513
space 1663
pulse 562
space 1678
pulse 495
space 1656
pulse 540
space 39340
pulse 8814
space 2225
pulse 538
pulse 125213

Press Ctrl-C to exit

.END
  • @Teofil Sandu, Short Answer Update 2 shows setup to read the IR signal generated by pressing the button Digit 1. The UART IR reader reads the raw NEC 38kHz encoded IR signal and converts it to 3 bytes 0x00, 0xff, 0x16. Next is to display the raw signal received by the IR reader (middle guy, no UART of picture). I think Rpi can read this raw signal and convert it to 0x00ff16. Or LIRC can also convert this signal. I sttll have not installed LIRC. This is what I am going to do next. – tlfong01 6 hours ago
  • Ok, keep me posted. I’m really curious about your results! – Teofil Sandu 5 hours ago
  • @Teofil Sandu, Update 4: So I installed LIRC using the stackOverflow tutorial you recommended and found everything OK, display the messages “pulse … space …, …” . I think I can now use LIRCd commands to decode the IR signals. But I already have the UART output IR reader/decoder, so I don’t need LIRC now. Actually I can also use python to read GPIO signal and decode myself like “0x00, 0xff, 0x16” = Digit 1 etc. The NEC code timing seems not too complicated, so I guess it should take me perhaps only a couple of hours to write and debug the program. – tlfong01 4 hours ago
  • I’m glad that it worked. Looking forward to see how the code is implemented! – Teofil Sandu 1 hour ago
  • @Teofil Sandu, I skimmed LIRC programs and utilities (Ref 30) to see anything interesting. I found the tools Mode2, IRrecord, etc are useful to DIY things. But the tools are focused at socket level, which I am not interested at all. What I want is the higher python programming level. So I am moving to python programming, and might not come back. I also found the LIRC python package 5 years old, even LIRC itself has not been updated for two years. In short, LIRC a disappointment for me. – tlfong01 29 mins ago
  • @Teofil Sandu, So my answer to your question is coming to an end. I hope we are both happy to know (1) How to install LIRC, (2) Meaning and use of command Mode 2. Now I am reading the user guide for python UART programming of the IR transceiver module (Ref 31). This is out of scope of your question, so I will not write up here. If you are also using the UART version of IR transceiver, you might like to ask ANOTHER QUESTION in this forum. I will see if I can help. Good luck to your project and cheers! 🙂 – tlfong01 just now   Edit
Chat record

Discussion on question by Teofil Sandu: Problem with LIRC on Raspberry Pi 3

Imported from a comment discussion on raspberrypi.stackexchange.com/questions/103452/…
Q: Problem with LIRC on Raspberry Pi 3

Teofil SanduI 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 r…

joan
joan
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.
Teofil Sandu
Teofil Sandu
I’ll edit in the question

  

tlfong01

tlfong01
2113
@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.
@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.
@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.
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/…
@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.
@Teofil Sandu, This PiHut tutorial is also very good. thepihut.com/blogs/raspberry-pi-tutorials/…
Teofil Sandu
Teofil Sandu
Okay I will try it, thanks a lot !
tlfong01

tlfong01
2113
@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.
@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.
@Teofil Sandu, I just finished a couple of quick and dirty IR receiver tests, just to make sure I more or less understanding correctly how the NEC encoding protocol works and that my IR remote and receiver kit are working OK. I will now take a break and see you tomorrow.
Teofil Sandu
Teofil Sandu
Fri 22:05
Thank you , I will check it out.
By the way have you tried sending any signals? @tlfong01
tlfong01

tlfong01
2113
Well, I tried to install LIRC, following two tutorials (Ref 4 and another). I found one tutorial not too update, and Ref 4 too tedious to remember the steps. I also have no confidence that the lirc driver I successfully installed can run smoothly in my Rpi4B buster. I think I will google further to learn how other Rpi4 users play with lirc. I am also trying using python UART to do further testing.
@Teofil Sandu, I googled again and found one more updated tutorial – Ref 26. Perhaps you can try it. I am not sure if it works for Rpi4B. So I will try the UART module first to get more experience, then come back to try LIRC. PS – More updated lirc info.
Teofil Sandu

Teofil Sandu
So great news, the receiving part works. Do you know if I can see the codes received by the sensor in a raw format?
Maybe something regarding the mode2 command and parameters @tlfong01
tlfong01

tlfong01
2113
@Teofil Sandu, Ah, for now I can only display the wave form in a scope. I am thinking of (1) Use a python program to read the IR signals, (2) Use LIRC to read the IR signals.
I still have not tried the most up to date procedure to install and test LIRC. As I said, the two tutorials I already tried are not working, because they are out of date. BTW, which tutorial you were following? Give me the link and perhaps I can try it later, and see what is the meaning of mode 2 as described in your tutorial. I am going very slowly. I still don’t know what is a config file for lirc.
Teofil Sandu

Teofil Sandu
5
I used the link above and it worked! The only difference is that I had to set lirc1 instead of lirc0, I am thinking maybe because I also added a IR led because I want to try to send them as well after. @tlfong01
The only thing is that mode2 shows in hex format. I would like to try to see them in RAW format. More study I guess
tlfong01

tlfong01
@Teofil Sandu, Ah, the post you just gave me is more up to date than mine. Yours mentions buster, but mine only Rpi3. Now I have more motivation to try it on my Rpi4B buster. I will stall my python method for a while, and try your suggested procedure first.
Teofil Sandu
Teofil Sandu
Fri 22:05
Yeah, it’s more updated. I hope it will work for you too 🙂 @tlfong01
tlfong01

tlfong01
2113
@Teofil Sandu, I have not read the lirc user guide carefully, so I don’t know what is “mode 2”. By the way, if you get the data in hex format, then it is easy to convert them in RAW format. Usually people want to convert RAW to hex, then to text, such as “button 1 pressed”, etc. It if laughable that you are walking in the opposite direction. But I am indeed using the scope to display is the raw mark/space signals. I actually downloaded the raw mark/space signals for button 1, but have not displayed here, because I thought nobody is interested to read the boring raw signals. 🙂
Teofil Sandu
Teofil Sandu
Oh got it. The mode2 is a command to capture the signals from the LIRC library. If you will open the link, you’ll see @tlfong01
tlfong01
tlfong01
Thanks a lot. I will try it later. But it is now jogging time for me. So see you late this evening or tomorrow. Cheers.
Teofil Sandu
Teofil Sandu
Hah, have fun. @tlfong01
19 hours later…
tlfong01

tlfong01
2113
Sat 17:05
@user58972 Yes, I read what you recommended and now know what is “Mode 2”. It is just a command to help displaying the signals and listing the kernel etc. The signals displayed is the the form of “Pulse, . Space, Pulse, Space etc”.
A button generated signal group consists of a starter (two long pause/space) followed by four parts (bytes) address, address repeat, command, command repeat. So the LIRC daemon or driver will decode the signal into 4 bytes or further to meaning full names like “button digit 1 pressed”, “power button pressed” etc.
Then you can use python to do what you want, turn on TV1, power off, etc etc, …A button generated signal group consists of a starter (two long pause/space) followed by four parts (bytes) address, address repeat, command, command repeat. So the LIRC daemon or driver will decode the signal into 4 bytes or further to meaning full names like “button digit 1 pressed”, “power button pressed” etc. Then you can use python to do what you want, turn on TV1, power off, etc etc, …
Now I have a scope, so I don’t need to use mode 2 to display and make sure the signals are pulse, space etc. And I have the UART interfaced IR sender receiver, I don’t even need LIRC (unless you want more powerful commands), I can just use the four bytes from the IR receiver uart interfaced module and move on to control the TV1, TV2, air con, fan, power down etc,
jogging time again, see you late evening or tomorrow, or day after tomorrow.
4 hours later…
tlfong01

tlfong01
2113
Sat 21:10
@user58972 Now I have successfully used the remote controller to generate IR codes by pressing the buttons by hand. The UART interfaced IR reader reads the IR code and write to Win10 RealTerm, which can display on screen, or stored as a text file, in hex or binary format. So LIRC is not needed for now, because even I use LIRC to read the codes, I still need a python program to decode the codes to button names.
2 days later…
Teofil Sandu

Teofil Sandu
5
yst 15:38
Hi. How does the code look like? It would be way easier for me to have a python program rather than using the lirc library every time
And sorry, I was away for the weekend but thank you so much for showing interest regarding this project. It’s something I really need and I’m glad someone took an interest in it !
19 hours later…
tlfong01

tlfong01
2113
10:55
@TeofilSandu (1) Well, I have displayed the code in the top of my answer. I checked 4 remote controllers and found they don’t use the standard NEC 38kHz encoding. So I am thinking of playing with the 17 button mini remote which I will be using to control my little robots.
(2) I agree with you that it is better to use python to send and receive the IR signals. I have successfully use Win10 RealTerm serial terminal emulator to read the IR signals. After I have decided which code to use, It should be easy to use a python program to replace RealTerm to read IR codes.
My goal is to use python to control the 838 receiver to read and decode IR codes, then use the same python program to control the robot. I am not at all to use the LIRC utilities to read IR codes. An as I said earlier, I will use my mini remote to generate 17 codes (up, down, left, right, OK, 0 to 9) I can also use python to generate code by two methods:
(1) extract the mini remote’s 17 button wires to RPi’s GPIO pins, or MCP23017’s GPIO pins, (2) Use python to control the TSAL600 IR emitter. This second method is for a latter part of my robot project, where many master robot emit IR signals/messages to control their slave robots, and start a battle, joining forces and fighting the opposite robot gang, …
The last message was posted 10 hours ago.

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

%d bloggers like this: