Simple IRremote query

Hello,
(And Happy New year too)
I am a relative novice re. coding, so please be patient :slight_smile:

I have connected an TSOP48 IR receiver to an Mega 2560 clone and am using the code below. This was copied from online example and not altered by me as yet.

#include <IRremote.hpp>

#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
  }
}

//

If I use a Sony TV remote I get hex values on the Arduino serial monitor, for pressing 1, 2, 3 eg:
image

Oscilloscope trace at IR receiver output looks like:

image

With 12 negative pulses, +pulse width is ~650uS, -ve pulse width 550uS.
This is all good as far as I am aware :slight_smile:

However if I use a light bulb controlling remote, the serial monitor is all FFFFFFFF

image

Oscilloscope trace looks like:

Same timebase on both traces.

With 33 negative pulses, in the first section of 9 negative pulses +ve pulse width is ~540uS, -ve pulse width 580uS. (measured using 'scope cursor and measurement facility).

My question is, how can I decode this data stream? Is there something that has to be passed to the library IRremote? Or does another library have to be used? Or do I have write my own (too difficult as this stage for me?)

I have a similar issue with a sound system IR remote control. At this stage I am guessing when one is fixed others will be too.

Thanks for help.

Try this code:

#include <IRremote.hpp>

#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(IrReceiver.decode()){ 
    Serial.println(IrReceiver.decodedIRData.decodedRawData , HEX);
     IrReceiver.resume();
  }
}

Great, thank you very much.

It is all simple when you know the answer :wink: Which I did not.

image

Sometimes it helps if you just add a minimal delay on the order of 10 to 50 milliseconds before irrecv.resume().

That made the digits presented on the serial monitor much "cleaner". Thanks you :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.