• Stars
    star
    239
  • Rank 168,763 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Nonblocking device drivers to receive from IR remotes and for IR "blaster" apps.

Device drivers for IR (infra red) remote controls

This repo provides a driver to receive from IR (infra red) remote controls and a driver for IR "blaster" apps. The device drivers are nonblocking. They do not require uasyncio but are compatible with it, and are designed for standard firmware builds.

The receiver is cross platform and has been tested on Pyboard, ESP8266, ESP32 and Raspberry Pi Pico.

In a typical use case the receiver is employed at the REPL to sniff the address and data values associated with buttons on a remote control. The transmitter is then used in an application to send those codes, emulating the remote control.

Other use cases involve running the receiver in an application. This enables an IR remote to control a device such as a robot. This may be problematic on some platforms. Please see section 4.

Raspberry Pi Pico note

Early firmware has this issue affecting USB communication with some PC's. This is now fixed. Please ensure you are using up to date firmware.

Receiver docs

The transmitter driver is compatible with Pyboard (1.x and D series) and ESP32. ESP8266 is unsupported; it seems incapable of generating the required signals.

Transmitter docs

1. IR communication

IR communication uses a carrier frequency to pulse the IR source. Modulation takes the form of OOK (on-off keying). There are multiple protocols and at least three options for carrier frequency: 36, 38 and 40KHz.

In the case of the transmitter the carrier frequency is a runtime parameter: any value may be specified. The receiver uses a hardware demodulator which should be purchased for the correct frequency. The receiver device driver sees the demodulated signal and is hence carrier frequency agnostic.

Remotes transmit an address and a data byte, plus in some cases an extra value. The address denotes the physical device being controlled. The data defines the button on the remote. Provision usually exists for differentiating between a button repeatedly pressed and one which is held down; the mechanism is protocol dependent.

2. Supported protocols

The drivers support NEC and Sony protocols plus two Philips protocols, namely RC-5 and RC-6 mode 0. There is also support for the OrtekMCE protocol used on VRC-1100 remotes. These originally supported Microsoft Media Center but can be used to control Kodi and (with a suitable receiver) to emulate a PC keyboard. The Samsung protocol (NEC variant) is also supported.

Examining waveforms from various remote controls it is evident that numerous protocols exist. Some are doubtless proprietary and undocumented. The supported protocols are those for which I managed to locate documentation. My preference is for the NEC version. It has conservative timing and good provision for error detection. RC-5 has limited error detection, and RC-6 mode 0 has rather fast timing.

A remote using the NEC protocol is this one.

3. Hardware Requirements

These are discussed in detail in the relevant docs; the following provides an overview.

The receiver is cross-platform. It requires an IR receiver chip to demodulate the carrier. The chip must be selected for the frequency in use by the remote. For 38KHz devices a receiver chip such as the Vishay TSOP4838 or the adafruit one is required. This demodulates the 38KHz IR pulses and passes the demodulated pulse train to the microcontroller.

In my testing a 38KHz demodulator worked with 36KHz and 40KHz remotes, but this is obviously neither guaranteed nor optimal.

The transmitter requires a Pyboard 1.x (not Lite), a Pyboard D, an ESP32 or Raspberry Pico (RP2). Output is via an IR LED which will need a transistor to provide sufficient current.

3.1 Carrier frequencies

These are as follows. The Panasonic remote appears to use a proprietary protocol and is not supported by these drivers.

Protocol F KHz How found Support
NEC 38 Measured Y
RC-5 RC-6 36 Spec/measured Y
Sony 40 Spec/measured Y
MCE 38 Measured Y
Samsung 38 Measured Y
Panasonic 36.3 Measured N

4. Receiver limitations

The receiver uses a pin interrupt and depends on a quick response to a state change on the pin. This is guaranteed on platforms which support hard IRQ's such as the Pyboard and the RP4 Pico. The ESP32 and ESP8266 only support soft IRQ's. This means that, if code such as WiFi communication is running concurrently, reliable reception may be problematic.

5. References

Sources of information about IR protocols. The sbprojects.net site is an excellent resource.
General information about IR

Also IRMP

The NEC protocol:
altium
circuitvalley
sbprojects.net

The Samsung protocol:
Rustic Engineering
TechDesign Electronics Waveforms of various protocols.

Philips protocols:
RC5 Wikipedia
RC5 sbprojects.net
RC6 sbprojects.net

Sony protocol:
SIRC sbprojects.net

MCE protocol:
OrtekMCE

IR decoders (C sourcecode):
in the Linux kernel

Interesting summary of IR protools (with thanks to Martin Bless):
IRMP

More Repositories

1

micropython-async

Application of uasyncio to hardware interfaces. Tutorial and code.
Python
714
star
2

micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
Python
555
star
3

micropython-nano-gui

A lightweight MicroPython GUI library for display drivers based on framebuf class
Python
459
star
4

micropython-samples

Assorted code ideas, unofficial MP FAQ, plus index to my other repositories.
Python
443
star
5

micropython-font-to-py

A Python 3 utility to convert fonts to Python source capable of being frozen as bytecode
Python
370
star
6

micropython-micro-gui

A lightweight MicroPython GUI library for display drivers based on framebuf, allows input via pushbuttons. See also micropython-touch.
Python
237
star
7

micropython-iot

An approach to designing IOT applications using ESP8266, ESP32 or Pyboard D endpoints
Python
86
star
8

micropython-tft-gui

Simple GUI for Pyboard and TFT touch panel displays
Python
85
star
9

micropython-fourier

Fast Fourier transform in MicroPython's inline ARM assembler.
Python
76
star
10

micropython_eeprom

MicroPython device drivers for memory chips (EEPROM, FRAM, Flash, SPIRAM)
Python
70
star
11

micropython-filters

Digital filters impemented in MicroPython's inline ARM Thumb assembler (e.g. Pyboard, RP2).
Python
64
star
12

micropython_remote

Capture and replay 433MHz remote control codes. Control remote switched power adaptors.
Python
64
star
13

micropython-epaper

Driver for 2.7 inch Adafruit and Embedded Artists e-paper displays
Python
60
star
14

micropython-radio

Simple way to use an nRF24L01 radio to exchange arbitrary Python objects between two Pyboards
Python
52
star
15

micropython-micropower

Support for building ultra low power systems based on the Pyboard (1.x and D series).
Python
44
star
16

micropython-lcd160cr-gui

Touch GUI for the official MicroPython LCD display
Python
28
star
17

micropython-monitor

Display the behaviour of a realtime program with a scope or logic analyser.
Python
28
star
18

micropython-msgpack

MessagePack serialisation library optimised for MicroPython
Python
26
star
19

micropython_data_to_py

A Python3 utility to convert an arbitrary binary file to Python source for storage in Flash
Python
26
star
20

micropython-vs1053

Synchronous and asynchronous drivers for VS1053b MP3/FLAC player
Python
25
star
21

micropython-touch

A GUI for touch panel displays.
Python
18
star
22

micropython-amg88xx

Driver for Grid-EYE thermal infra red array sensor (Adafruit 3538)
Python
18
star
23

micropython_ra8875

MicroPython device driver and nano-GUI for RA8875 based displays
Python
9
star