Arduino IRremote library

I have a project that requires IR remote signals. I want to hack the remote used with some LED lights.

I installed the IRremote library and ran the IRrecvDemo sketch. The IR sensor works, it binks when a signal is received.

The sketch produces terrible results. it reads one out of 7 button pushes on average.
The results for the same button produce widely varied Hex readings

I have attached the sketch, the circuit I am using and the Serial window from pushing the same button over 40 times

window.JPG

IRrecvDemo.ino (726 Bytes)

It would be interesting what decode type it detects. Print it out and post results. What type of remote do you use?

I used 4 different ones to test. The results shown are from a keyes IR remote that came in a bundle of toys for the arduino. See attached image for results

Please post the output of the decode_type field of the result you get. What type of sensor are you using? It sound like you're reading a floating pin.

pylon:
Please post the output of the decode_type field of the result you get. What type of sensor are you using? It sound like you're reading a floating pin.

Please see "window.jpg" attached in the original post, that is the output

Please see "window.jpg" attached in the original post, that is the output

No, that's just the value field. I wrote you should post the output of the decode_type field.

And you didn't answer my question about the type of sensor you're using.

pylon:
And you didn’t answer my question about the type of sensor you’re using.

I wish this forum had a code

I used the IR Receiver Sensor - TSOP38238 from adafruit connected the pins per data sheet

I ran the following sketch

//------------------------------------------------------------------------------
// Include the IRremote library header
//
#include <IRremote.h>

//------------------------------------------------------------------------------
// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
//
int recvPin = 11;
IRrecv irrecv(recvPin);

//+=============================================================================
// Configure the Arduino
//
void  setup ( )
{
  Serial.begin(9600);   // Status message will be sent to PC at 9600 baud
  irrecv.enableIRIn();  // Start the receiver
}

//+=============================================================================
// Display IR code
//
void  ircode (decode_results *results)
{
  // Panasonic has an Address
  if (results->decode_type == PANASONIC) {
    Serial.print(results->address, HEX);
    Serial.print(":");
  }

  // Print Code
  Serial.print(results->value, HEX);
}

//+=============================================================================
// Display encoding type
//
void  encoding (decode_results *results)
{
  switch (results->decode_type) {
    default:
    case UNKNOWN:      Serial.print("UNKNOWN");       break ;
    case NEC:          Serial.print("NEC");           break ;
    case SONY:         Serial.print("SONY");          break ;
    case RC5:          Serial.print("RC5");           break ;
    case RC6:          Serial.print("RC6");           break ;
    case DISH:         Serial.print("DISH");          break ;
    case SHARP:        Serial.print("SHARP");         break ;
    case JVC:          Serial.print("JVC");           break ;
    case SANYO:        Serial.print("SANYO");         break ;
    case MITSUBISHI:   Serial.print("MITSUBISHI");    break ;
    case SAMSUNG:      Serial.print("SAMSUNG");       break ;
    case LG:           Serial.print("LG");            break ;
    case WHYNTER:      Serial.print("WHYNTER");       break ;
    case AIWA_RC_T501: Serial.print("AIWA_RC_T501");  break ;
    case PANASONIC:    Serial.print("PANASONIC");     break ;
    case DENON:        Serial.print("Denon");         break ;
  }
}

//+=============================================================================
// Dump out the decode_results structure.
//
void  dumpInfo (decode_results *results)
{
  // Check if the buffer overflowed
  if (results->overflow) {
    Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWBUF");
    return;
  }

  // Show Encoding standard
  Serial.print("Encoding  : ");
  encoding(results);
  Serial.println("");

  // Show Code & length
  Serial.print("Code      : ");
  ircode(results);
  Serial.print(" (");
  Serial.print(results->bits, DEC);
  Serial.println(" bits)");
}

//+=============================================================================
// Dump out the decode_results structure.
//
void  dumpRaw (decode_results *results)
{
  // Print Raw data
  Serial.print("Timing[");
  Serial.print(results->rawlen-1, DEC);
  Serial.println("]: ");

  for (int i = 1;  i < results->rawlen;  i++) {
    unsigned long  x = results->rawbuf[i] * USECPERTICK;
    if (!(i & 1)) {  // even
      Serial.print("-");
      if (x < 1000)  Serial.print(" ") ;
      if (x < 100)   Serial.print(" ") ;
      Serial.print(x, DEC);
    } else {  // odd
      Serial.print("     ");
      Serial.print("+");
      if (x < 1000)  Serial.print(" ") ;
      if (x < 100)   Serial.print(" ") ;
      Serial.print(x, DEC);
      if (i < results->rawlen-1) Serial.print(", "); //',' not needed for last one
    }
    if (!(i % 8))  Serial.println("");
  }
  Serial.println("");                    // Newline
}

//+=============================================================================
// Dump out the decode_results structure.
//
void  dumpCode (decode_results *results)
{
  // Start declaration
  Serial.print("unsigned int  ");          // variable type
  Serial.print("rawData[");                // array name
  Serial.print(results->rawlen - 1, DEC);  // array size
  Serial.print("] = {");                   // Start declaration

  // Dump data
  for (int i = 1;  i < results->rawlen;  i++) {
    Serial.print(results->rawbuf[i] * USECPERTICK, DEC);
    if ( i < results->rawlen-1 ) Serial.print(","); // ',' not needed on last one
    if (!(i & 1))  Serial.print(" ");
  }

  // End declaration
  Serial.print("};");  // 

  // Comment
  Serial.print("  // ");
  encoding(results);
  Serial.print(" ");
  ircode(results);

  // Newline
  Serial.println("");

  // Now dump "known" codes
  if (results->decode_type != UNKNOWN) {

    // Some protocols have an address
    if (results->decode_type == PANASONIC) {
      Serial.print("unsigned int  addr = 0x");
      Serial.print(results->address, HEX);
      Serial.println(";");
    }

    // All protocols have data
    Serial.print("unsigned int  data = 0x");
    Serial.print(results->value, HEX);
    Serial.println(";");
  }
}

//+=============================================================================
// The repeating section of the code
//
void  loop ( )
{
  decode_results  results;        // Somewhere to store the results

  if (irrecv.decode(&results)) {  // Grab an IR code
    dumpInfo(&results);           // Output the results
    dumpRaw(&results);            // Output the results in RAW format
    dumpCode(&results);           // Output the results as source code
    Serial.println("");           // Blank line between entries
    irrecv.resume();              // Prepare for the next value
  }
}

I got the following when pressing the #1 key repeatedly

Encoding : UNKNOWN
Code : FCABFFBF (32 bits)
Timing[5]:

  • 450, - 100 +7750, - 500 + 50
    unsigned int rawData[5] = {450,100, 7750,500, 50}; // UNKNOWN FCABFFBF

Encoding : UNKNOWN
Code : FDAC0152 (32 bits)
Timing[5]:

  • 50, - 50 +7900, - 50 + 350
    unsigned int rawData[5] = {50,50, 7900,50, 350}; // UNKNOWN FDAC0152

Encoding : UNKNOWN
Code : 76DF9DBF (32 bits)
Timing[7]:

  • 200, - 200 + 250, - 50 +8500, - 50 + 200
    unsigned int rawData[7] = {200,200, 250,50, 8500,50, 200}; // UNKNOWN 76DF9DBF

Encoding : UNKNOWN
Code : FCABFFBF (32 bits)
Timing[5]:

  • 100, - 450 +7400, - 600 + 200
    unsigned int rawData[5] = {100,450, 7400,600, 200}; // UNKNOWN FCABFFBF

Encoding : UNKNOWN
Code : 4CB0FADC (32 bits)
Timing[5]:
+8400, - 50 + 50, - 300 + 50
unsigned int rawData[5] = {8400,50, 50,300, 50}; // UNKNOWN 4CB0FADC

Encoding : UNKNOWN
Code : FEAC02E5 (32 bits)
Timing[5]:

  • 250, - 500 +7550, - 50 + 50
    unsigned int rawData[5] = {250,500, 7550,50, 50}; // UNKNOWN FEAC02E5

Encoding : UNKNOWN
Code : 49B0F624 (32 bits)
Timing[5]:
+8100, - 50 + 300, - 50 + 50
unsigned int rawData[5] = {8100,50, 300,50, 50}; // UNKNOWN 49B0F624

artistinfla:
I wish this forum had a code

Does it look like a repository to you?

aarg:
Does it look like a repository to you?

I did not mean to include that. I was looking for the "``" to put the code in a scrolling wondow

I got the following when pressing the #1 key repeatedly

This look more than strange to me. You either have a very bad reception (are the batteries of the IR remote still OK) or you have a wrong wiring. I don't expect the sensor to be damaged so I'm looking for other possible failure reasons.

Do you point the IR remote to the rounded side of the sensor?

What type of Arduino are you using? Is it the UNO of the picture in the first post?

pylon:
This look more than strange to me.

3 different sensors, 2 different Unos. It is only 3 wires, and all are perfectly fine. Yes, I pointed the remote, with brand new batteries, at the "rounded" part of the sensor.

I used 4 different remotes, all with same results of not receiving inconsistent results for the same button being pushed.

I don't have the same hardware as you have but with my hardware I get consistent results (I know, that doesn't help you much).

Did you check that the modulated frequency of the used remotes match the filter of the sensor (which should be 38kHz if you wrote the correct part number in the first post)?