Example sketch IRremote ReceiveDump not working

Hello. I am trying to use the raw receive and send function of the IRremote library by shiriff (version 4.3.0). I need to use raw receive and send because the protocol of the cable box I want to control is unknown to this library (the cable box is a rogers scientific atlanta explorer 4290). To get raw readings of. my remote, I tried to use the receive dump example. However, it does not print anything in the serial monitor when I press buttons on my remote.

I have other code which can receive the code but not raw, which works fine, so I know my circuit is okay. I have looked at a number of websites online about using sendRaw, but I can't find out how to get the raw data in the first place.

Does anybody have any ideas on how I can find the raw ir codes for my remote, so I can then send them to my cable box? Any ideas are help. Thanks a lot.

using the new API you could try

#include <IRremote.hpp>

#define IR_RECEIVE_PIN      2 // Pick the right one for your arduino

void printHex8(uint8_t val) {
  if (val < 0x10) Serial.write('0');
  Serial.print(val, HEX);
}

void printHex16(uint16_t val) {
  printHex8(val >> 8);
  printHex8(val & 0xFF);
}

void setup() {
  Serial.begin(115200); Serial.println();
  IrReceiver.begin(IR_RECEIVE_PIN);
}

void loop() {
  if (IrReceiver.decode()) {
    for (size_t i = 0; i < IrReceiver.decodedIRData.rawDataPtr->rawlen; i++) {
      printHex16(IrReceiver.decodedIRData.rawDataPtr->rawbuf[i]); // raw data / tick counts per mark/space, first entry is the length of the gap between previous and current command
      Serial.write(' ');
    }
    Serial.println("\n-------------");

    IrReceiver.resume();
  }
}

IrReceiver.decodedIRData is a structure you can access to read what got received

you can see the structure at Arduino-IRremote/src/IRProtocol.h at c6c7f17f587eabab0833fe0d048dba85251a9735 · Arduino-IRremote/Arduino-IRremote · GitHub

it looks something like this (GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols)

    struct IRData {
      decode_type_t protocol;     // UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
      uint16_t address;           // Decoded address
      uint16_t command;           // Decoded command
      uint16_t extra;             // Used for Kaseikyo unknown vendor ID. Ticks used for decoding Distance protocol.
      uint16_t numberOfBits;      // Number of bits received for data (address + command + parity) - to determine protocol length if different length are possible.
      uint8_t flags;              // IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions
      IRRawDataType decodedRawData;    // Up to 32 (64 bit for 32 bit CPU architectures) bit decoded raw data, used for sendRaw functions.
      uint32_t decodedRawDataArray[RAW_DATA_ARRAY_SIZE]; // 32 bit decoded raw data, to be used for send function.
      irparams_struct *rawDataPtr; // Pointer of the raw timing data to be decoded. Mainly the data buffer filled by receiving ISR.
    };

Thanks for the response. When I run the code, I get this for my remote's power button:
FFFF 002F 000C 0018 000C 000B 000C 0018 000C 000B 000C 0018 000C 000B 000C 000C 000C 0018 000B 000C 000C 000C 000C 000B 000C 000C


01FD 002F 000C 0018 000B 000C 000C 0018 000B 000C 000C 0018 000B 000C 000C 000C 000C 0017 000C 000C 000C 000C 000B 000C 000C 000C


01FD 002F 000C 0018 000B 000C 000C 0018 000B 000C 000C 0018 000B 000C 000C 000C 000C 0017 000C 000C 000C 000C 000B 000C 000C 000C


I'm now trying to send the codes using an IR LED to my TV. I tried using the IRremote library's code again, but it is in a different format than the raw data your code outputted for me. How would you send these codes back to the TV with a IR led? Thanks a lot for the help.

I've never done it

have you looked at the code in the example

I have looked at the example "SendRawDemo", but I can't figure out how to input my data into the program. There are two arrays, which both look different than my data. This is what the portion of the example code with both arrays looks like (if you need the full thing, its under example sketches and is called SendRawDemo):

const uint8_t rawDataP[]
#if defined(__AVR__)
PROGMEM
#endif
= { 180, 90 /*Start bit*/, 11, 11, 11, 11, 11, 34, 11, 34/*0011 0xC of 16 bit address LSB first*/, 11, 11, 11, 11, 11, 11, 11,
        11/*0000*/, 11, 34, 11, 34, 11, 11, 11, 34/*1101 0xB*/, 11, 34, 11, 34, 11, 34, 11, 34/*1111*/, 11, 11, 11, 11, 11, 11, 11,
        34/*0001 0x08 of command LSB first*/, 11, 34, 11, 11, 11, 11, 11, 11/*1000 0x01*/, 11, 34, 11, 34, 11, 34, 11,
        11/*1110 Inverted 8 of command*/, 11, 11, 11, 34, 11, 34, 11, 34/*0111 inverted 1 of command*/, 11 /*stop bit*/};

void loop() {

#if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__))
    /*
     * Send hand crafted data from RAM
     * The values are NOT multiple of 50, but are taken from the NEC timing definitions
     */
    Serial.println(F("Send NEC 16 bit address=0xFB04 and command 0x08 with exact timing (16 bit array format)"));
    Serial.flush();

    const uint16_t rawData[] = { 9000, 4500/*Start bit*/, 560, 560, 560, 560, 560, 1690, 560,
            560/*0010 0x4 of 16 bit address LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000*/, 560, 1690, 560, 1690, 560,
            560, 560, 1690/*1101 0xB*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111*/, 560, 560, 560, 560, 560, 560, 560,
            1690/*0001 0x08 of command LSB first*/, 560, 560, 560, 560, 560, 560, 560, 560/*0000 0x00*/, 560, 1690, 560, 1690, 560,
            1690, 560, 560/*1110 Inverted 8 of command*/, 560, 1690, 560, 1690, 560, 1690, 560, 1690/*1111 inverted 0 of command*/,
            560 /*stop bit*/}; // Using exact NEC timing
    IrSender.sendRaw(rawData, sizeof(rawData) / sizeof(rawData[0]), NEC_KHZ); // Note the approach used to automatically calculate the size of the array.

    delay(1000); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
#endif

Do you know how I can input my results above into this code? Sorry for all the questions, I'm really new to arduino and I'm still trying to figure out raw ir codes.

Ensure that your IR receiver module is properly connected to Arduino. Also check the IR receiver is compatible with the iRemote Library. Some on module has different pinouts.

Hello, I know my receiver is wired correctly as it works when I am just getting the regulars hex code. I’m trying to find out how to send and receive the raw codes

if you run their example, you should see some stuff in the Serial monitor when you record an entry

➜ what do you see?

Well I'm not sure because I get an error when uploading the code:

fatal error: PinDefinitionsAndMore.h: No such file or directory
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

exit status 1

Compilation error: PinDefinitionsAndMore.h: No such file or directory

How should I add this file? Thanks

PinDefinitionsAndMore.h is part of the sketch files

Ok, I got the example sketch running. It seems to be working fine, but it does not work to turn my TV on. In the serial monitor, it prints out the raw codes, and when I click my push button it says it has sent the code.

Here is what shows in the serial monitor:
Received unknown code and store 47 timing entries as raw
rawData[48]:
-3276750
+3350,-3300

  • 850,-2550 + 800,-2550 + 850,- 800 + 850,-2550
  • 800,-2550 + 850,-2500 + 850,- 850 + 800,-2550
  • 850,-2500 + 850,-2500 + 850,- 850 + 850,- 800
  • 850,- 850 + 800,-2550 + 850,- 800 + 850,- 850
    Sum: 62900
    Stop receiving
    Button pressed, now sending raw 47 marks or spaces
    Button released -> start receiving
    Stop receiving

When I replace the IR LED for a regular LED, it blinks quickly, which I think shows that the wiring and everything is correct. But still, the IR LED is not able to control my TV. Do you have any ideas what might be the issue here (or another way to do it)? I really thought this would have worked. Thanks in advance.

So this seems to work as expected indeed- not sure why it would not work.

Is the IR led close enough / directed to the TV ?

May be the mark and spaces have specifics not reproduced by the player

It looks like it is sending raw 16 bits. What is the hex code that works? Is it NEC format?

Edit: it doesn't appear to be NEC. So what hex values and protocol actually work? That would tell you what the individual bit values are supposed to be. Also, all the numbers end in 00 or 50. So I assume it is rounding to the nearest 50, which may not be good enough.

In case it matters, it appears Sony has 12bit, 15bit and 20bit IR codes, and can use 40KHz or even 56KHz modulation. So your receiver may not be perfectly matched. But if it works in hex, then it should work in raw.

Edit: According to this:

https://www.righto.com/2010/03/understanding-sony-ir-remote-codes-lirc.html

the code should be repeated at least twice more, 45ms apart.

Yikes, that doesn't sound too great. Yeah, I have made sure the IR led is close enough. What do you mean by the mark and spaces?

The protocol I really want to use is unknown. However, I was trying the program with the sony codes to see if they might work instead (my TV is sony, so I need sony codes to turn it on and off, but my cable channels are using an unknown protocol - hence why I am trying to use raw codes).

Interesting. Do you know how I could account for different frequency modulations? Is it something I can control in the program?

Yes, I understand. I think I was the one who suggested that in your other thread.

But you said somewhere above that you were able to read a key on the Sony remote as a hex value and then send that out again, and that worked on the TV. So I'm asking what that hex value was. I want to translate that into what raw should be, and see how it compares to the raw input you got (assuming you hit the same key on both).

I suspect that somewhere in the library there is a setting for the modulation frequency. But I'm not sure that's the problem. If you got a hex value to work at 38K, that could be close enough to 40K that it doesn't matter.

Oh ok. I didn't remember it was you! That was a good suggestion.
The hex code for the TV's power (Sony) reads as A90.

This is the raw data I get from clicking that same button:
Received unknown code and store 25 timing entries as raw
rawData[26]:
-3276750
+2400,- 600
+1200,- 600 + 600,- 600 +1200,- 550 + 600,- 600
+1200,- 600 + 600,- 600 + 600,- 600 +1200,- 600

  • 600,- 600 + 600,- 600 + 600,- 600 + 550
    Sum: 19100

It tends to show this array twice for every time I click the power button (which is a little strange, because sony codes send the signal three times?).