0

I am trying to figure out how to read IR codes of a TV remote, so I can build my own web-based remote using a Raspberry Pi 3 with IR receiver and IR transmitter. I see a ton of articles online but could not find an article that articulates a DIY tutorial on just this part.

Ultimately, I want to map all the buttons on a TV remote, and then build a web based interface used to transmit the user selected IR codes to control a TV.

I have a RPi3 (second gen) kit with some basic accessories like breadboard, resistors, and jumper wires. IR receiver and transmitter components are confusing to choose, depending on which article I am reading.

Web User
  • 119
  • 1
  • 6
  • This question is pretty broad for this site. Questions should typically be more focused on specific problems that you've encountered with examples of what you've tried. – Brick Jun 04 '19 at 21:44
  • http://www.lirc.org/ – goldilocks Jun 04 '19 at 21:52
  • 1
    most of the work of reading the signal has already been done .... what is the TV manufacturer and model? – jsotola Jun 05 '19 at 01:24
  • @jsotola Sony XBR55X930E – Web User Jun 06 '19 at 22:55
  • 1
    here is some info about the sony IR protocol https://www.sbprojects.net/knowledge/ir/sirc.php ....... http://www.righto.com/2010/03/understanding-sony-ir-remote-codes-lirc.html – jsotola Jul 30 '19 at 03:03
  • it looks like sony TVs can be controlled by a wifi remote .... it should be easier to implementt that IR remote .... http://docs.esupport.sony.com/imanual/NA/EN/hx750/mediaremote.html – jsotola Jul 30 '19 at 04:18

2 Answers2

2

While answers which are mostly links are discouraged, IR is NOT simple enough to explain in a few paragraphs.

You seem well informed already acknowledging that each button has its own code. That is a little bit over simplified (depending on the "codes" being used), but you at least have a good grasp of it and what you want to do.

The Pi has a great IR package called LIRC (think Linux Infrared Remote Control) which has a lot of documentation.

This link is pretty much exactly what you are looking for and it sounds like you have already looked at quite a few ideas.

This was built using a Pi Zero, just a stripped down Pi. Using LIRC really makes it slick!

www.instructables.com/id/Raspberry-Pi-Zero-Universal-Remote/.

Wendall
  • 221
  • 1
  • 7
  • I have the latest version of Raspbian Stretch April 2019 work kernel 4.19. lirc-pi seems to be replaced by gpio-ir. Also irrecord is unable to detect my Sony remote's IR signals, even though mode2 is detecting the pulses and spaces just fine. I read somewhere that Sony remotes use 40 khz instead of 38 khz. Is this behind the issues I am running into? – Web User Jun 11 '19 at 06:47
  • Any 36 khz receiver will receive 38 and 40 khz. And any 38 khz will receive 36 and 40 khz. Their frequency "selection" is quite broad. In the equipment I worked with our 38 khz receivers worked fine with 25 khz IR remotes. I have read that LIRC was either dropped or replaced. I have not worked with it for a while... – Wendall Jun 11 '19 at 13:21
1

You can use lirc to achieve what you want. When you have installed it you can use its diagnose tool mode2 to get low level information about the signals that are received from the remote control.

Then you need a configuration file that maps the lirc pulses to the buttons of your remote control. On the internet there is a database with many config files for remote controls. If you cannot find yours you have to training your remote control by yourself with:

rpi ~$ sudo irrecord -n -d /dev/lirc0 ~/lircd.conf

Next step is to use irw to check which button of your remote control has what action (volume up/down etc.).

Finally you can use irexec to map a script to each button on the remote control that is executed when the button is pressed. Within this script you can send commands through a web based interface to control a TV.

For details how to do all this using a Raspberry Pi you can look at Raspberry Pi 3 lirc running/working.


If you are looking for an alternative to lirc you can use direct kernel support with gpio-ir. Look at /boot/overlay/README. There you will find:

Name:   gpio-ir
Info:   Use GPIO pin as rc-core style infrared receiver input. The rc-core-
        based gpio_ir_recv driver maps received keys directly to a
        /dev/input/event* device, all decoding is done by the kernel - LIRC is
        not required! The key mapping and other decoding parameters can be
        configured by "ir-keytable" tool.
Load:   dtoverlay=gpio-ir,<param>=<val>
Params: gpio_pin                Input pin number. Default is 18.

        gpio_pull               Desired pull-up/down state (off, down, up)
                                Default is "up".

        rc-map-name             Default rc keymap (can also be changed by
                                ir-keytable), defaults to "rc-rc6-mce"


Name:   gpio-ir-tx
Info:   Use GPIO pin as bit-banged infrared transmitter output.
        This is an alternative to "pwm-ir-tx". gpio-ir-tx doesn't require
        a PWM so it can be used together with onboard analog audio.
Load:   dtoverlay=gpio-ir-tx,<param>=<val>
Params: gpio_pin                Output GPIO (default 18)

        invert                  "1" = invert the output (make it active-low).
                                Default is "0" (active-high).
Ingo
  • 42,107
  • 20
  • 85
  • 197