{"id":13801827,"url":"https://github.com/peterhinch/micropython_ir","last_synced_at":"2025-04-12T19:46:46.857Z","repository":{"id":37246644,"uuid":"242553549","full_name":"peterhinch/micropython_ir","owner":"peterhinch","description":"Nonblocking device drivers to receive from IR remotes and for IR \"blaster\" apps.","archived":false,"fork":false,"pushed_at":"2024-12-21T14:57:31.000Z","size":987,"stargazers_count":269,"open_issues_count":8,"forks_count":51,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-03T23:10:06.178Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peterhinch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-23T16:44:14.000Z","updated_at":"2025-03-31T16:54:24.000Z","dependencies_parsed_at":"2023-01-19T11:47:35.048Z","dependency_job_id":"6f520e10-bf3c-4162-818d-a364bdd4d0b0","html_url":"https://github.com/peterhinch/micropython_ir","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython_ir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython_ir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython_ir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython_ir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterhinch","download_url":"https://codeload.github.com/peterhinch/micropython_ir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625497,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:28.253Z","updated_at":"2025-04-12T19:46:46.825Z","avatar_url":"https://github.com/peterhinch.png","language":"Python","readme":"# Device drivers for IR (infra red) remote controls\n\nThis repo provides a driver to receive from IR (infra red) remote controls and\na driver for IR \"blaster\" apps. The device drivers are nonblocking. They do not\nrequire `uasyncio` but are compatible with it, and are designed for standard\nfirmware builds.\n\nThe receiver is cross platform and has been tested on Pyboard, ESP8266, ESP32\nand Raspberry Pi Pico.\n\nIn a typical use case the receiver is employed at the REPL to sniff the address\nand data values associated with buttons on a remote control. The transmitter is\nthen used in an application to send those codes, emulating the remote control.\n\nOther use cases involve running the receiver in an application. This enables an\nIR remote to control a device such as a robot. This may be problematic on some\nplatforms. Please see [section 4](./README.md#4-receiver-limitations).\n\n## Raspberry Pi Pico note\n\nEarly firmware has [this issue](https://github.com/micropython/micropython/issues/6866)\naffecting USB communication with some PC's. This is now fixed. Please ensure\nyou are using up to date firmware.\n\n#### [Receiver docs](./RECEIVER.md)\n\nThe transmitter driver is compatible with Pyboard (1.x and D series) and ESP32.\nESP8266 is unsupported; it seems incapable of generating the required signals.\n\n#### [Transmitter docs](./TRANSMITTER.md)\n\n# 1. IR communication\n\nIR communication uses a carrier frequency to pulse the IR source. Modulation\ntakes the form of OOK (on-off keying). There are multiple protocols and at\nleast three options for carrier frequency: 36, 38 and 40KHz.\n\nIn the case of the transmitter the carrier frequency is a runtime parameter:\nany value may be specified. The receiver uses a hardware demodulator which\nshould be purchased for the correct frequency. The receiver device driver sees\nthe demodulated signal and is hence carrier frequency agnostic.\n\nRemotes transmit an address and a data byte, plus in some cases an extra value.\nThe address denotes the physical device being controlled. The data defines the\nbutton on the remote. Provision usually exists for differentiating between a\nbutton repeatedly pressed and one which is held down; the mechanism is protocol\ndependent.\n\n# 2. Supported protocols\n\nThe drivers support NEC and Sony protocols plus two Philips protocols, namely\nRC-5 and RC-6 mode 0. There is also support for the OrtekMCE protocol used on\nVRC-1100 remotes. These originally supported Microsoft Media Center but can be\nused to control Kodi and (with a suitable receiver) to emulate a PC keyboard.\nThe Samsung protocol (NEC variant) is also supported.\n\nExamining waveforms from various remote controls it is evident that numerous\nprotocols exist. Some are doubtless proprietary and undocumented. The supported\nprotocols are those for which I managed to locate documentation. My preference\nis for the NEC version. It has conservative timing and good provision for error\ndetection. RC-5 has limited error detection, and RC-6 mode 0 has rather fast\ntiming.\n\nA remote using the NEC protocol is [this one](https://www.adafruit.com/products/389).\n\n# 3. Hardware Requirements\n\nThese are discussed in detail in the relevant docs; the following provides an\noverview.\n\nThe receiver is cross-platform. It requires an IR receiver chip to demodulate\nthe carrier. The chip must be selected for the frequency in use by the remote.\nFor 38KHz devices a receiver chip such as the Vishay TSOP4838 or the\n[adafruit one](https://www.adafruit.com/products/157) is required. This\ndemodulates the 38KHz IR pulses and passes the demodulated pulse train to the\nmicrocontroller.\n\nIn my testing a 38KHz demodulator worked with 36KHz and 40KHz remotes, but this\nis obviously neither guaranteed nor optimal.\n\nThe transmitter requires a Pyboard 1.x (not Lite), a Pyboard D, an ESP32 or\nRaspberry Pico (RP2). Output is via an IR LED which will need a transistor to\nprovide sufficient current.\n\n## 3.1 Carrier frequencies\n\nThese are as follows. The Panasonic remote appears to use a proprietary\nprotocol and is not supported by these drivers.\n\n| Protocol  | F KHz | How found     | Support |\n|:---------:|:-----:|:-------------:|:-------:|\n| NEC       | 38    | Measured      | Y       |\n| RC-5 RC-6 | 36    | Spec/measured | Y       |\n| Sony      | 40    | Spec/measured | Y       |\n| MCE       | 38    | Measured      | Y       | \n| Samsung   | 38    | Measured      | Y       |\n| Panasonic | 36.3  | Measured      | N       |\n\n# 4. Receiver limitations\n\nThe receiver uses a pin interrupt and depends on a quick response to a state\nchange on the pin. This is guaranteed on platforms which support hard IRQ's\nsuch as the Pyboard and the RP4 Pico. The ESP32 and ESP8266 only support soft\nIRQ's. This means that, if code such as WiFi communication is running\nconcurrently, reliable reception may be problematic.\n\n# 5. References\n\nSources of information about IR protocols. The `sbprojects.net` site is an\nexcellent resource.  \n[General information about IR](https://www.sbprojects.net/knowledge/ir/)\n\nAlso [IRMP](https://www.mikrocontroller.net/articles/IRMP_-_english)\n\nThe NEC protocol:  \n[altium](http://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol)  \n[circuitvalley](http://www.circuitvalley.com/2013/09/nec-protocol-ir-infrared-remote-control.html)  \n[sbprojects.net](https://www.sbprojects.net/knowledge/ir/nec.php)\n\nThe Samsung protocol:  \n[Rustic Engineering](https://rusticengineering.wordpress.com/2011/02/09/infrared-room-control-with-samsung-ir-protocol/)  \n[TechDesign Electronics](https://www.techdesign.be/projects/011/011_waves.htm) Waveforms of various protocols.  \n\n\nPhilips protocols:  \n[RC5 Wikipedia](https://en.wikipedia.org/wiki/RC-5)  \n[RC5 sbprojects.net](https://www.sbprojects.net/knowledge/ir/rc5.php)  \n[RC6 sbprojects.net](https://www.sbprojects.net/knowledge/ir/rc6.php)\n\nSony protocol:  \n[SIRC sbprojects.net](https://www.sbprojects.net/knowledge/ir/sirc.php)\n\nMCE protocol:  \n[OrtekMCE](http://www.hifi-remote.com/johnsfine/DecodeIR.html#OrtekMCE)\n\nIR decoders (C sourcecode):  \n[in the Linux kernel](https://github.com/torvalds/linux/tree/master/drivers/media/rc)\n\nInteresting summary of IR protools (with thanks to Martin Bless):  \n[IRMP](https://www.mikrocontroller.net/articles/IRMP_-_english#IR_Protocols)\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterhinch%2Fmicropython_ir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterhinch%2Fmicropython_ir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterhinch%2Fmicropython_ir/lists"}