1 # Device drivers for IR (infra red) remote controls
3 This repo provides a driver to receive from IR (infra red) remote controls and
4 a driver for IR "blaster" apps. The device drivers are nonblocking. They do not
5 require `uasyncio` but are compatible with it, and are designed for standard
8 The receiver is cross platform and has been tested on Pyboard, ESP8266, ESP32
11 In a typical use case the receiver is employed at the REPL to sniff the address
12 and data values associated with buttons on a remote control. The transmitter is
13 then used in an application to send those codes, emulating the remote control.
15 Other use cases involve running the receiver in an application. This enables an
16 IR remote to control a device such as a robot. This may be problematic on some
17 platforms. Please see [section 4](./README.md#4-receiver-limitations).
19 ## Raspberry Pi Pico note
21 Early firmware has [this issue](https://github.com/micropython/micropython/issues/6866)
22 affecting USB communication with some PC's. This is now fixed. Please ensure
23 you are using up to date firmware.
25 #### [Receiver docs](./RECEIVER.md)
27 The transmitter driver is compatible with Pyboard (1.x and D series) and ESP32.
28 ESP8266 is unsupported; it seems incapable of generating the required signals.
30 #### [Transmitter docs](./TRANSMITTER.md)
34 IR communication uses a carrier frequency to pulse the IR source. Modulation
35 takes the form of OOK (on-off keying). There are multiple protocols and at
36 least three options for carrier frequency: 36, 38 and 40KHz.
38 In the case of the transmitter the carrier frequency is a runtime parameter:
39 any value may be specified. The receiver uses a hardware demodulator which
40 should be purchased for the correct frequency. The receiver device driver sees
41 the demodulated signal and is hence carrier frequency agnostic.
43 Remotes transmit an address and a data byte, plus in some cases an extra value.
44 The address denotes the physical device being controlled. The data defines the
45 button on the remote. Provision usually exists for differentiating between a
46 button repeatedly pressed and one which is held down; the mechanism is protocol
49 # 2. Supported protocols
51 The drivers support NEC and Sony protocols plus two Philips protocols, namely
52 RC-5 and RC-6 mode 0. There is also support for the OrtekMCE protocol used on
53 VRC-1100 remotes. These originally supported Microsoft Media Center but can be
54 used to control Kodi and (with a suitable receiver) to emulate a PC keyboard.
56 Examining waveforms from various remote controls it is evident that numerous
57 protocols exist. Some are doubtless proprietary and undocumented. The supported
58 protocols are those for which I managed to locate documentation. My preference
59 is for the NEC version. It has conservative timing and good provision for error
60 detection. RC-5 has limited error detection, and RC-6 mode 0 has rather fast
63 A remote using the NEC protocol is [this one](https://www.adafruit.com/products/389).
65 # 3. Hardware Requirements
67 These are discussed in detail in the relevant docs; the following provides an
70 The receiver is cross-platform. It requires an IR receiver chip to demodulate
71 the carrier. The chip must be selected for the frequency in use by the remote.
72 For 38KHz devices a receiver chip such as the Vishay TSOP4838 or the
73 [adafruit one](https://www.adafruit.com/products/157) is required. This
74 demodulates the 38KHz IR pulses and passes the demodulated pulse train to the
77 In my testing a 38KHz demodulator worked with 36KHz and 40KHz remotes, but this
78 is obviously neither guaranteed nor optimal.
80 The transmitter requires a Pyboard 1.x (not Lite), a Pyboard D or an ESP32.
81 Output is via an IR LED which will need a transistor to provide sufficient
82 current. The ESP32 requires an extra transistor to work as a transmitter.
84 ## 3.1 Carrier frequencies
86 These are as follows. The Samsung and Panasonic remotes appear to use
87 proprietary protocols and are not supported by these drivers.
89 | Protocol | F KHz | How found | Support |
90 |:---------:|:-----:|:-------------:|:-------:|
91 | NEC | 38 | Measured | Y |
92 | RC-5 RC-6 | 36 | Spec/measured | Y |
93 | Sony | 40 | Spec/measured | Y |
94 | MCE | 38 | Measured | Y |
95 | Samsung | 38 | Measured | N |
96 | Panasonic | 36.3 | Measured | N |
98 # 4. Receiver limitations
100 The receiver uses a pin interrupt and depends on a quick response to a state
101 change on the pin. This is guaranteed on platforms which support hard IRQ's
102 such as the Pyboard and the RP4 Pico. The ESP32 and ESP8266 only support soft
103 IRQ's. This means that, if code such as WiFi communication is running
104 concurrently, reliable reception may be problematic.
108 Sources of information about IR protocols. The `sbprojects.net` site is an
110 [General information about IR](https://www.sbprojects.net/knowledge/ir/)
113 [altium](http://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol)
114 [circuitvalley](http://www.circuitvalley.com/2013/09/nec-protocol-ir-infrared-remote-control.html)
115 [sbprojects.net](https://www.sbprojects.net/knowledge/ir/nec.php)
118 [RC5 Wikipedia](https://en.wikipedia.org/wiki/RC-5)
119 [RC5 sbprojects.net](https://www.sbprojects.net/knowledge/ir/rc5.php)
120 [RC6 sbprojects.net](https://www.sbprojects.net/knowledge/ir/rc6.php)
123 [SIRC sbprojects.net](https://www.sbprojects.net/knowledge/ir/sirc.php)
126 [OrtekMCE](http://www.hifi-remote.com/johnsfine/DecodeIR.html#OrtekMCE)
128 IR decoders (C sourcecode):
129 [in the Linux kernel](https://github.com/torvalds/linux/tree/master/drivers/media/rc)