I'm using a standard 38kHz receiver with Arduino-IRremote library and it works fine for a while but then it stops working. The loop function is running time after time as expected but at some point the library decode function starts returning false until I reset the board.

This example code works for me with any arduino nano or bare atmega328p at 8Mhz but for both of them it freezes after some receptions.

The code is the library example itself:

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
  irrecv.enableIRIn(); // Start the receiver

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value

Some times this happens fast and other times it is after 20 or more receptions. I only added a led blink later to test if the board is frozen or is only the infrared that stops receiving and it was the second case.

  • HI, are you the same user who posted the issue on Github
    – RSM
    Jul 6, 2015 at 9:56
  • @RSM Yes I am. I don't know if it's a bug or what. First I tested on Nano with RGB leds driven with PWM and thought the problem was with that so I isolated the IR part on a bareduino that only receives from IR and writes to soft serial and sometimes it freezes too. When I reset the bareduino it works again.
    – aalku
    Jul 6, 2015 at 11:36
  • I ran the code on an UNO and a pro micro with a continuous spool of IR data pointer at it for 15 minutes? so I don't know whats up the code on yours
    – RSM
    Jul 6, 2015 at 11:38
  • I never saw it failing when connected to computer so I thougth had something to do with serial output so I removed all the serial prints but still the same result.
    – aalku
    Jul 6, 2015 at 11:40
  • 1
    @Gerben There is a capacitor on the nano input. I think the processor does not hangs. Currently with nano+bare the nano does not hang at all. I am sure of that. RGB leds keep changing. I'll add a led to bareduino to make sure it is not hanged.
    – aalku
    Jul 6, 2015 at 12:35

3 Answers 3


I was having similar problem (but not the same ) And it was due to software serial pins which keep on filling the buffers of MCU.

Some times it happen that pwm pins keep on receiving data e.g. GPS also keep filling the buffer and due to that arduino freeze .

To solve this problem I open new dummy software serial port.( select any pins which is free ) and do listen to your software serial pins when you want to read it otherwise make dummy listen.

  • This seems completely irrelevant to me. The question does not mention software serial.
    – Nick Gammon
    Nov 6, 2015 at 6:07

Arduino tutorials I've seen don't mention it but the datasheets from the ir receptors manufacturers advice to stabilize vcc with a resistor and a capacitor.


It seems without that the receptor fail to correctly report the received wave so the library may decode it wrong. In my case the problem started to happen when I added RGB leds controlled by PWM on the same (stabilized) power supply.


In short: The IRremote Library has bugs that lead to unresponsiveness of the board. There were some updates and now IRremote.h library 3.01 runs about a day with a FastLED.h WS1211 led stripe connected to it.

My approach to make it run reliable more than 24h with the latest library you could connect a digital pin to the reset pin on the Arduino. Then use EVERY_N_HOURS to occasionally pull that pin low.

The Software reset via timer (watchdog timer library) every 2 seconds f.e. worked occasionally but not reliable.

That should even make every 2USD board clone run as reliable as it could/hardware allows it.

Have fun :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.