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