Home

Awesome

<div align = center>

IRMP - Infrared Multi Protocol Decoder + Encoder

A library enabling the sending & receiving of infra-red signals with a low memory footprint.<br/> Supports 50 different protocols.

Badge License: GPLv3     Badge Version     Badge Commits since latest     Badge Build Status     Badge Hit Counter <br/> <br/> Stand With Ukraine

Available as Arduino library "IRMP".

Button Install     Button Changelog

</div>

If you find this library useful, please give it a star.

🌎 Google Translate

<br/>

Features

<br/>
Nano running AllProtocol exampleYouTube VideoInstructable
Nano running AllProtocol exampleYouTube VideoInstructable
<br/>

List of protocols

Sony SIRCS     NEC + APPLE + ONKYO     Samsung + Samsg32     Kaseikyo

JVC     NEC16 + NEC42     Matsushita     DENON     Sharp     RC5     RC6 & RC6A     IR60 (SDA2008) Grundig     Siemens Gigaset     Nokia

BOSE     Kathrein     NUBERT     FAN (ventilator)     SPEAKER (~NUBERT)     Bang & Olufsen     RECS80 (SAA3004)<br/>     RECS80EXT (SAA3008)     Thomson     NIKON camera     Netbox keyboard     ORTEK (Hama)     Telefunken 1560<br/>     FDC3402 keyboard     RC Car     iRobot Roomba     RUWIDO     T-Home     A1 TV BOX    LEGO Power RC<br/>     RCMM 12,24, or 32     LG Air Condition     Samsung48     Merlin     Pentax     S100     ACP24     TECHNICS<br/>     PANASONIC Beamer     Mitsubishi Aircond     VINCENT     SAMSUNG AH     GREE CLIMATE     RCII T+A<br/>     RADIO e.g. TEVION     METZ

NEC     Kaseiko     Denon     RC6     Samsung + Samsg32   were successfully tested in interrupt mode, but there are many protocols which in principle cannot be decoded in this mode.

<br/>

Features

Restrictions

Minimal version

For applications only requiring NEC protocol, there is a receiver which has very small codesize of 500 bytes and does NOT require any timer. See the MinimalReceiver and IRDispatcherDemo example how to use it. Mapping of pins to interrupts can be found here. <br/>

Schematic for Arduino Uno

The VS1838B is used as receiver for all examples and tests. This module has a 120 µs on/low and a 100 µs off/high delay between received signal and output. So it shortens the mark and extends the space by 20 µs.

IR-Receiver connectionSerial LCD connection
Fritzing schematic for Arduino UnoFritzing schematic for Arduino Uno + LCD
<br/>

Supported Arduino architectures / CPU's / boards

For ESP8266/ESP32, this library supports an impressive set of protocols and a lot of air conditioners<br/> <br/> ATtiny and Digispark boards are tested with the recommended ATTinyCore using New Style pin mapping for the pro board.

ArchitectureCPUBoard
avrATmega16, ATmega328P, ATmega32U4, ATtinyX5, ATtinyX7Uno, Nano, Leonardo, Sparkfun Pro Micro, Digispark etc.
megaavrATmega4809Uno WiFi Rev 2, Nano Every
samdSAMD21G18AZero, MKR*, etc. but not DUE, which is sam architecture
esp8266All protocols does not fit in IRAMall
esp32%all
stm32STM32F1xxBluePill
STM32F1STM32F1xxBluePill
apollo3Ambiq Apollo3Sparkfun Apollo3 + Artemis
mbednRF528xNano 33 BLE
Teensiduinoall - but limited support>= Teensy 3
<br/>

Quick comparison of 5 Arduino IR receiving libraries

This is a short comparison and may not be complete or correct.

I created this comparison matrix for myself in order to choose a small IR lib for my project and to have a quick overview, when to choose which library.<br/> It is dated from 24.06.2022 and updated 10/2023. If you have complains about the data or request for extensions, please send a PM or open a discussion.

Here you find an ESP8266/ESP32 version of IRremote with an impressive list of supported protocols.

SubjectIRMPIRLremoteIRLib2<br/>mostly unmaintainedIRremoteTinyIRIRsmallDecoder
Number of protocols50Nec + Panasonic + Hash *12 + Hash *17 + PulseDistance + Hash *NEC + FASTNEC + RC5 + Sony + Samsung
Timing method receiveTimer2 or interrupt for pin 2 or 3InterruptTimer2 or interrupt for pin 2 or 3Timer2InterruptInterrupt
Timing method sendPWM and timing with Timer2 interruptsTimer2 interruptsTimer2 and blocking waitPWM with Timer2 and/or blocking wait with delay<br/>Microseconds()blocking wait with delay<br/>Microseconds()%
Send pinsAllAllAll ?Timer dependentAll%
Decode methodOnTheFlyOnTheFlyRAMRAMOnTheFlyOnTheFly
Encode methodOnTheFlyOnTheFlyOnTheFlyOnTheFly or RAMOnTheFly%
Callback suppportx%%xx%
Repeat handlingReceive + Send (partially)%?Receive + SendReceive + SendReceive
LED feedbackx%xxReceive%
FLASH usage (simple NEC example with 5 prints)1820<br/>(4300 for 15 main / 8000 for all 40 protocols)<br/>(+200 for callback)<br/>(+80 for interrupt at pin 2+3)1270<br/>(1400 for pin 2+3)48301770900?1100?
RAM usage52<br/>(73 / 100 for 15 (main) / 40 protocols)623342271929
Supported platformsavr, megaavr, attiny, Digispark (Pro), esp8266, ESP32, STM32, SAMD 21, Apollo3<br/>(plus arm and pic for non Arduino IDE)avr, esp8266avr, SAMD 21, SAMD 51avr, attiny, esp8266, esp32, SAM, SAMDAll platforms with attach<br/>Interrupt()All platforms with attach<br/>Interrupt()
Last library update5/20234/201811/20229/20235/20232/2022
RemarksDecodes 40 protocols concurrently.<br/>39 Protocols to send.<br/>Work in progress.Only one protocol at a time.Consists of 5 libraries. *Project containing bugs - 63 issues, 10 pull requests.Universal decoder and encoder.<br/>Supports Pronto codes and sending of raw timing values.Requires no timer.Requires no timer.

* The Hash protocol gives you a hash as code, which may be sufficient to distinguish your keys on the remote, but may not work with some protocols like Mitsubishi

<br/>

Pin usage

You may use every pin for input or output, just define it like #define IRMP_INPUT_PIN 2 and #define IRSND_OUTPUT_PIN 3. The PWM of the output pin is generated by software bit banging.

Dynamic pins numbers

If you want to use pin numbers for input, output and LED feedback specified at runtime, you must define IRMP_IRSND_ALLOW_DYNAMIC_PINS. See ReceiveAndSendDynamicPins example.<br/> The irmp_init and irsnd_init function then allows up to 3 parameters uint_fast8_t aIrmpInputPin/aIrsndOutputPin, uint_fast8_t aIrmpFeedbackLedPin, bool aIrmpLedFeedbackPinIsActiveLow.<br/> Be aware, only one pin and enable flag for receive and send feedback LED is supported.

<br/>

Receiving and sending simultaneously

Receiving and sending is possible with this library, but since we use only 1 timer, receiving is inhibited while sending the IR signal.<br/> Sending the IR signal starts with saving current timer configuration, setting the timer to the send configuration / frequency, sending the signal (and waiting for the gap after the signal) and then automatically reset the timer to its previous (receiving) configuration.

<br/>

API

IRMP

// Init functions
void irmp_init (void);
void irmp_init(uint_fast8_t aIrmpInputPin);
void irmp_init(uint_fast8_t aIrmpInputPin, uint_fast8_t aIrmpFeedbackLedPin);
void irmp_init(uint_fast8_t aIrmpInputPin, uint_fast8_t aIrmpFeedbackLedPin, bool aIrmpLedFeedbackPinIsActiveLow);
void irmp_register_complete_callback_function(void (*aCompleteCallbackFunction)(void));

// Info function
bool irmp_IsBusy();
void irmp_print_active_protocols(Print *aSerial);

// Main check for result function used in loop()
bool irmp_get_data (IRMP_DATA *)

// Result print functions
void irmp_result_print(Print *aSerial, IRMP_DATA * aIRMPDataPtr);
void irmp_result_print(IRMP_DATA *aIRMPDataPtr);

IRSND

// Init functions
void irsnd_init (void);
// 3 additional init functions if IRMP_IRSND_ALLOW_DYNAMIC_PINS is defined
void irsnd_init(uint_fast8_t aIrsndOutputPin);
void irsnd_init(uint_fast8_t aIrsndOutputPin, uint_fast8_t aIrmpFeedbackLedPin);
void irsnd_init(uint_fast8_t aIrsndOutputPin, uint_fast8_t aIrmpFeedbackLedPin, bool aIrmpLedFeedbackPinIsActiveLow);

// Send function - sends frame AND trailing space
bool irsnd_send_data (IRMP_DATA *, uint8_t);

// Info functions
bool irsnd_is_busy (void);

void irsnd_stop (void);

IRMP and IRSND

// LED feedback function
void irmp_irsnd_LEDFeedback(bool aEnableBlinkLed);

// Timer management functions for 
void disableIRTimerInterrupt(void);
void enableIRTimerInterrupt(void);
void storeIRTimer(void);
void restoreIRTimer(void);
<br/>

Examples

In order to fit the examples to the 8K flash of ATtiny85 and ATtiny88, the Arduino library ATtinySerialOut is required for this CPU's.

AllProtocols

Receives up to 40 protocols concurrently and displays the short result on a 1602 LCD. The LCD can be connected parallel or serial (I2C).<br/>

SimpleReceiver + SimpleSender

This examples are a good starting point.<br/> SimpleReceiver can be tested online with WOKWI. Click on the receiver while simulation is running to specify individual IR codes.

MinimalReceiver + MinimalSender

If code size matters, look at these examples.<br/> The MinimalReceiver example uses the TinyReceiver library which can only receive NEC and FAST codes, but does not require any timer.<br/> MinimalReceiver can be tested online with WOKWI. Click on the receiver while simulation is running to specify individual IR codes.

SmallReceiver

If the protocol is not NEC and code size matters, look at this example.<br/> MinimalReceiver can be tested online with WOKWI. Click on the receiver while simulation is running to specify individual IR codes.

ReceiverTimingAnalysis

This example analyzes the signal delivered by your IR receiver module. Values can be used to determine the stability of the received signal as well as a hint for determining the protocol.<br/> It also computes the MARK_EXCESS_MICROS value, which is the extension of the mark (pulse) duration introduced by the IR receiver module.<br/> It can be tested online with WOKWI. Click on the receiver while simulation is running to specify individual IR codes.

<br/>

Compile options / macros for this library

To customize the library to different requirements, there are some compile options / macros available, which must be set before including the library e.g. with #include <irmp.hpp>.<br/> Modify it by setting the value to 1 or 0. Or define the macro with the -D compiler option for global compile (the latter is not possible with the Arduino IDE, so consider using Sloeber.<br/>

NameDefault valueDescription
IRMP_INPUT_PIN2The pin number which gets compiled in, if not using IRMP_IRSND_ALLOW_DYNAMIC_PINS. See also PinDefinitionsAndMore.h
IRMP_FEEDBACK_LED_PINLED_BUILTINThe pin number for the feedback led which gets compiled in, if not using IRMP_IRSND_ALLOW_DYNAMIC_PINS.
FEEDBACK_LED_IS_ACTIVE_LOWdisabledRequired on some boards (like my like my BluePill and my ESP8266 board), where the feedback LED is active low.
NO_LED_FEEDBACK_CODEdisabledEnable it to disable the feedback LED function. Saves 30 bytes program memory.
IRMP_IRSND_ALLOW_DYNAMIC_PINSdisabledAllows to specify pin number at irmp_init() - see above. This requires additional program memory.
IRMP_PROTOCOL_NAMES0 / disabledEnable protocol number mapping to protocol strings - needs some program memory.
IRMP_USE_COMPLETE_CALLBACK0 / disabledUse Callback if complete data was received. Requires call to irmp_register_complete_callback_function().
IRMP_ENABLE_PIN_CHANGE_INTERRUPTdisabledUse Arduino attachInterrupt() and do no polling with timer ISR. This restricts the available input pins and protocols. The results are equivalent to results acquired with a sampling rate of 15625 Hz (chosen to avoid time consuming divisions). For AVR boards an own interrupt handler for INT0 or INT1 is used instead of Arduino attachInterrupt().
IRMP_ENABLE_RELEASE_DETECTION0 / disabledIf user releases a key on the remote control, last protocol/address/command will be returned with flag IRMP_FLAG_RELEASE set.
IRMP_HIGH_ACTIVE0 / disabledSet to 1 if you use a RF receiver, which has an active HIGH output signal.
IRMP_32_BIT0 / disabledThis enables MERLIN protocol, but decreases performance for AVR. Enabled by default for 32 bit platforms.
F_INTERRUPTS15000The IRMP sampling frequency.
USE_ONE_TIMER_FOR_IRMP_AND_IRSNDdisabledMust be defined if you use receiving and sending simultaneously, since both use the same timer resource. Must not be enabled if you only use receiving.
IRSND_USE_CALLBACK0 / disabledCalls a function if send output signal changes to active (sending the IR signal).
IR_OUTPUT_IS_ACTIVE_LOWdisabledOutput LOW for active IR signal. Use it if IR LED is connected between VCC and output pin.
IRSND_GENERATE_NO_SEND_RFdisabledDo not generate the carrier frequency (of 38 kHz), just simulate an active low receiver signal.
IRSND_IR_FREQUENCY38000The modulation frequency for sent signal. The send signal is generated by bit banging, so the internal interrupt frequency is IRSND_IR_FREQUENCY * 2. The send control function is called at a rate of IRSND_IR_FREQUENCY / 2, resulting in a send packet signal resolution of 2 on/off periods.
---
IRMP_MEASURE_TIMING + IR_TIMING_TEST_PINenabledFor development only. The test pin is switched high at the very beginning and low at the end of the ISR.

These next macros for TinyIRReceiver must be defined in your program before the line #include <TinyIRReceiver.hpp> to take effect.

NameDefault valueDescription
IR_RECEIVE_PIN2The pin number for TinyIRReceiver IR input, which gets compiled in.
IR_FEEDBACK_LED_PINLED_BUILTINThe pin number for TinyIRReceiver feedback LED, which gets compiled in.
NO_LED_FEEDBACK_CODEdisabledEnable it to disable the feedback LED function. Saves 14 bytes program memory.

Changing include (*.h) files with Arduino IDE

First, use Sketch > Show Sketch Folder (Ctrl+K).<br/> If you have not yet saved the example as your own sketch, then you are instantly in the right library folder.<br/> Otherwise you have to navigate to the parallel libraries folder and select the library you want to access.<br/> In both cases the library source and include files are located in the libraries src directory.<br/> The modification must be renewed for each new library version!

Modifying compile options with Sloeber IDE

If you are using Sloeber as your IDE, you can easily define global symbols with Properties > Arduino > CompileOptions.<br/> Sloeber settings

<br/>

Timer usage

The IRMP receive library works by polling the input pin at a rate of 10 to 20 kHz. Default is 15 kHz.<br/> Some protocols (NEC, Kaseiko, Denon, RC6, Samsung + Samsg32) can be received without timer usage, just by using interrupts from the input pin by defining IRMP_ENABLE_PIN_CHANGE_INTERRUPT. There are many protocols which in principle cannot be decoded in this mode. See Interrupt example.<br/> In interrupt mode, the micros() function is used as timebase.

The IRMP send library works by bit banging the output pin at a frequency of 38 kHz. This avoids blocking waits and allows to choose an arbitrary pin, you are not restricted to PWM generating pins like pin 3 or 11. The interrupts for send pin bit banging require 50% CPU time on a 16 MHz AVR.<br/> If both receiving and sending is required, the timer is set up for receiving and reconfigured for the duration of sending data, thus preventing receiving in polling mode while sending data.<br/> The tone library (using timer 2) is still available. You can use it alternating with IR receive and send, see ReceiveAndSend example.<br/>

<br/>

Tips and tricks

<br/>

AllProtocols example

Serial LCD outputArduino Serial Monitor output
LCD startSerial Monitor

Sample Protocols

NECNEC42RC5KASEIKYO
DENONGRUNDIGIR60MATSUSHITA
NUBERTONKYORECS80RUWIDO
SAMSUNGSIEMENSTELEFUNKENTELEFUNKEN
<br/>

Documentation at mikrocontroller.net

English

http://www.mikrocontroller.net/articles/IRMP_-_english<br/> http://www.mikrocontroller.net/articles/IRSND_-_english

German

http://www.mikrocontroller.net/articles/IRMP<br/> http://www.mikrocontroller.net/articles/IRSND

German Forum

https://www.mikrocontroller.net/topic/irmp-infrared-multi-protocol-decoder?goto=6996113#6996137

<br/>

Revision History

Version 3.6.4

Version 3.6.3

Version 3.6.2

Version 3.6.1

Version 3.6.0

Version 3.5.1

Version 3.5.0

Version 3.4.1

Version 3.4.0

Version 3.3.5

Version 3.3.4

Version 3.3.3

Version 3.3.2

Version 3.3.1

Version 3.3.0

Version 3.2.3

Version 3.2.2

Version 3.2.1

Version 3.2.0

Version 3.1.2

Version 3.1.1

Version 3.1.0

Version 3.0.0

Version 2.2.1

Version 2.2.0

Version 2.1.0

Version 2.0.0

Version 1.2.2

Version 1.2.1

Version 1.2.0 - This version contains a bug for the AVR architecture

Version 1.1.0

Version 1.0.1

CI

The library examples are tested with GitHub Actions for the following boards: