Receive and transmit IR remote codes

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Receive and transmit IR remote codes

Post by pythoncoder » Sun Mar 22, 2020 6:48 pm

I have now produced a hopefully stable release. Any users are advised to update. These are the major changes:
  • Support for the MCE protocol (as used to control Kodi etc).
  • Improved docs.
  • Bugfix to RC5X where polarity of extended bit was inverted (rx and tx). Also affects RC5.
  • Bugfix to NEC transmitter where MSB of address was ignored.
  • Transmitter now validates args and raises a ValueError if out of range.
There is limited support for capturing and replaying unknown IR sequences. This is not a universal remote control, for reasons explained in the docs. Tools are provided to help experimenters write code to receive, store and "blast" undocumented, proprietary protocols. This without establishing the protocol structure - a task which can be quite challenging.
Peter Hinch
Index to my micropython libraries.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Receive and transmit IR remote codes

Post by pythoncoder » Tue Mar 09, 2021 11:57 am

This now supports the Raspberry Pi Pico in addition to Pyboards and ESP32. The receiver supports ESP8266.
Peter Hinch
Index to my micropython libraries.

uncoded0123
Posts: 6
Joined: Wed Aug 12, 2020 11:09 am

Re: Receive and transmit IR remote codes

Post by uncoded0123 » Fri Mar 26, 2021 2:16 am

Thanks Peter, for this and all the other contributions you have done for programmers.

shegger
Posts: 3
Joined: Thu Apr 01, 2021 6:56 am

Re: Receive and transmit IR remote codes

Post by shegger » Thu Apr 01, 2021 7:14 am

Hi Peter,
thanks for your code. I successfully implemented it. I saw your video on YouTube regarding the codes of different remote controls.
Is there somewhere a list of all codes of remote controls? When I have a device, which may be controlled by an remote control, do I have to buy the remote controll first, read the address and codes first? Can I use the lirc codes?

In the lirc codes I see e.g.
name Samsung_VCR
bits 16
flags SPACE_ENC|REPEAT_HEADER|CONST_LENGTH
# flags SPACE_ENC|REPEAT_HEADER
eps 25
aeps 100

header 4560 4410
one 625 1600
zero 625 490
ptrail 625
repeat 625 490
pre_data_bits 16
pre_data 0xA0A0
gap 100000
# gap 97350
# repeat_gap 48900
# repeat_gap 30800
toggle_bit 0


begin codes
KEY_POWER 0x00000000000040BF # Was: Power

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Receive and transmit IR remote codes

Post by pythoncoder » Thu Apr 01, 2021 8:48 am

shegger wrote:
Thu Apr 01, 2021 7:14 am
Hi Peter,
thanks for your code. I successfully implemented it. I saw your video on YouTube regarding the codes of different remote controls.
Is there somewhere a list of all codes of remote controls?...
I have no video on YouTube.

Unfortunately I have a minimal grasp of LIRC. My solution does assume that you have a sample of the remote and capture its codes. If you know the protocol used by a piece of kit (NEC, Sony, Philips etc) then you might be able to figure out which button transmits which code by experimentation. But if you have the piece of kit, wouldn't you also have the remote?

I am sure this information could be extracted from LIRC files, but I haven't investigated this.
Peter Hinch
Index to my micropython libraries.

shegger
Posts: 3
Joined: Thu Apr 01, 2021 6:56 am

Re: Receive and transmit IR remote codes

Post by shegger » Thu Apr 01, 2021 3:38 pm

pythoncoder wrote:
Thu Apr 01, 2021 8:48 am
But if you have the piece of kit, wouldn't you also have the remote?

I am sure this information could be extracted from LIRC files, but I haven't investigated this.
Hi,
I have a camera which is able to be controlled by a remote control, but it is an add on. So I would have to buy the remote control to get the code and then I do not need it any longer. So my guess was, to get this information from, lirc, because there are a lot of remote controls listed. I will check and if I find out how to get the codes from lirc I will inform you.

Best Stefan

shegger
Posts: 3
Joined: Thu Apr 01, 2021 6:56 am

Re: Receive and transmit IR remote codes

Post by shegger » Sun Apr 11, 2021 3:58 pm

Hi Peter,
I'm still struggling with your code. I just tried to switch off my TV via pico. So I checked what remote control I have and it is a Sony 12 bit. Fine: So the RC was recognized. Now I wanted to send the power OFF code. Therefor I recorded the code via rx code to burst.py and then send it via tx code. But it does not work. Where do I make the mistake?

Best Stefan

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Receive and transmit IR remote codes

Post by pythoncoder » Mon Apr 12, 2021 6:55 am

Given that you know you have a Sony 12 bit remote you should be able to run

Code: Select all

from ir_rx.test import test
test(2)  # The specific test for Sony 12 bit
Then make a record of the data and address value associated with each button that is of interest. Transmitting using those values using the ir_tx SONY_12 class should work.
Peter Hinch
Index to my micropython libraries.

KOKS
Posts: 3
Joined: Thu Apr 15, 2021 3:47 pm

Re: Receive and transmit IR remote codes

Post by KOKS » Fri Apr 16, 2021 9:47 pm

Hello Peter!

I wondering if there is possibilty to use this code to transmit the signal on 433.92MHz. I'm trying to use the RPI pico with some RF transmitter module to remotely control an electrical outlet. What should i change in your code? Could you give me some tips?
I'm pretty sure it is not so hard but it is my first time with microcontroller and i don't really know how to start doing with that.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Receive and transmit IR remote codes

Post by pythoncoder » Sat Apr 17, 2021 11:08 am

Please see the micropython-remote library which does this.
Peter Hinch
Index to my micropython libraries.

Post Reply