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 '15 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 '15 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 '15 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 '15 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 '15 at 12:35

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.

| improve this answer | |
  • This seems completely irrelevant to me. The question does not mention software serial. – Nick Gammon Nov 6 '15 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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