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.
18 #### [Receiver docs](./RECEIVER.md)
20 The transmitter driver is compatible with Pyboard (1.x and D series) and ESP32.
21 ESP8266 is unsupported; it seems incapable of generating the required signals.
23 #### [Transmitter docs](./TRANSMITTER.md)
27 IR communication uses a carrier frequency to pulse the IR source. Modulation
28 takes the form of OOK (on-off keying). There are multiple protocols and at
29 least three options for carrier frequency: 36, 38 and 40KHz.
31 In the case of the transmitter the carrier frequency is a runtime parameter:
32 any value may be specified. The receiver uses a hardware demodulator which
33 should be purchased for the correct frequency. The receiver device driver sees
34 the demodulated signal and is hence carrier frequency agnostic.
36 Remotes transmit an address and a data byte, plus in some cases an extra value.
37 The address denotes the physical device being controlled. The data defines the
38 button on the remote. Provision usually exists for differentiating between a
39 button repeatedly pressed and one which is held down; the mechanism is protocol
42 # 2. Supported protocols
44 The drivers support NEC and Sony protocols plus two Philips protocols, namely
45 RC-5 and RC-6 mode 0. There is also support for the OrtekMCE protocol used on
46 VRC-1100 remotes. These originally supported Microsoft Media Center but can be
47 used to control Kodi and (with a suitable receiver) to emulate a PC keyboard.
49 Examining waveforms from various remote controls it is evident that numerous
50 protocols exist. Some are doubtless proprietary and undocumented. The supported
51 protocols are those for which I managed to locate documentation. My preference
52 is for the NEC version. It has conservative timing and good provision for error
53 detection. RC-5 has limited error detection, and RC-6 mode 0 has rather fast
56 A remote using the NEC protocol is [this one](https://www.adafruit.com/products/389).
58 # 3. Hardware Requirements
60 These are discussed in detail in the relevant docs; the following provides an
63 The receiver is cross-platform. It requires an IR receiver chip to demodulate
64 the carrier. The chip must be selected for the frequency in use by the remote.
65 For 38KHz devices a receiver chip such as the Vishay TSOP4838 or the
66 [adafruit one](https://www.adafruit.com/products/157) is required. This
67 demodulates the 38KHz IR pulses and passes the demodulated pulse train to the
70 In my testing a 38KHz demodulator worked with 36KHz and 40KHz remotes, but this
71 is obviously neither guaranteed nor optimal.
73 The transmitter requires a Pyboard 1.x (not Lite), a Pyboard D or an ESP32.
74 Output is via an IR LED which will need a transistor to provide sufficient
75 current. The ESP32 requires an extra transistor to work as a transmitter.
77 ## 3.1 Carrier frequencies
79 These are as follows. The Samsung and Panasonic remotes appear to use
80 proprietary protocols and are not supported by these drivers.
82 | Protocol | F KHz | How found | Support |
83 |:---------:|:-----:|:-------------:|:-------:|
84 | NEC | 38 | Measured | Y |
85 | RC-5 RC-6 | 36 | Spec/measured | Y |
86 | Sony | 40 | Spec/measured | Y |
87 | MCE | 38 | Measured | Y |
88 | Samsung | 38 | Measured | N |
89 | Panasonic | 36.3 | Measured | N |
93 Sources of information about IR protocols. The `sbprojects.net` site is an
95 [General information about IR](https://www.sbprojects.net/knowledge/ir/)
98 [altium](http://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol)
99 [circuitvalley](http://www.circuitvalley.com/2013/09/nec-protocol-ir-infrared-remote-control.html)
100 [sbprojects.net](https://www.sbprojects.net/knowledge/ir/nec.php)
103 [RC5 Wikipedia](https://en.wikipedia.org/wiki/RC-5)
104 [RC5 sbprojects.net](https://www.sbprojects.net/knowledge/ir/rc5.php)
105 [RC6 sbprojects.net](https://www.sbprojects.net/knowledge/ir/rc6.php)
108 [SIRC sbprojects.net](https://www.sbprojects.net/knowledge/ir/sirc.php)
111 [OrtekMCE](http://www.hifi-remote.com/johnsfine/DecodeIR.html#OrtekMCE)
113 IR decoders (C sourcecode):
114 [in the Linux kernel](https://github.com/torvalds/linux/tree/master/drivers/media/rc)