Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

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()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

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

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.

share|improve this question
    
HI, are you the same user who posted the issue on Github –  RSM Jul 6 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 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 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 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 at 12:35

1 Answer 1

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.

circuit

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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