Problems with irsend.sendRaw / Sending RAW IR Code

So I have a problem that I don’t seam to get working no matter how I attack it.
I have been using Ken Shirriff's wonderfull IR-Library for Arduino, but I don’t seam to be able to get the “irsend.sendRaw” command working. My problem is that I have a generated RAW IR code from the IRdump sketch included in the library. It looks like this:

A0F22FDA
Unknown encoding: A0F22FDA (32 bits)
Raw (16): -7350 200 -4800 200 -4800 250 -4800 200 -4800 200 -4800 250 -4800 200 -4800 200

I have been trying something like this to no avail….
irsend.sendRaw([7350 200 4800 200 4800 250 4800 200 4800 200 4800 250 4800 200 4800 200], 16, 38)

So how do I write the “irsend.sendRaw” command to send this specific code?

I have been trying something like this to no avail….
irsend.sendRaw([7350 200 4800 200 4800 250 4800 200 4800 200 4800 250 4800 200 4800 200], 16, 38)

You can't create an array on the fly. You need to create and populate a fixed size array, and send that.

That looks like a very odd code. Do you get the same pattern of pulses every time?

It's unusual for the HIGH and LOW pulses to be so different in length: 200 vs 4800? Usually the pulses are closer to a 1:2 or 1:3 ratio, not 1:24!

Also, it shows no sign of data, just the same pattern over an over: 200 4800. Usually the code will represent 1's and 0's by swapping the two widths like 200 -600 = 1 and 600 -200 = 0.

Hmm that sounds wired, this is the data that I can capture time and time again.

A0F22FDA
Unknown encoding: A0F22FDA (32 bits)
Raw (16): -7350 200 -4800 200 -4800 250 -4800 200 -4800 200 -4800 250 -4800 200 -4800 200

2AD785FC
Unknown encoding: 2AD785FC (32 bits)
Raw (18): -7300 200 -4800 200 -4850 200 -4800 200 -4800 200 -4850 200 -4800 200 -4800 200 -4850 200

ekman:
I have been trying something like this to no avail….
irsend.sendRaw([7350 200 4800 200 4800 250 4800 200 4800 200 4800 250 4800 200 4800 200], 16, 38)

Hey ekman,

Two things:

  1. The array needs to have the values separated by commas
  2. The array should be declared outside of that command.

Here's a program i got from THIS BLOG : Digitalduino: Use sonar to control a TV!

#include <IRremote.h>
 
IRsend irsend;
 
// just added my own array for the raw signal
unsigned int powerOn[148] = {4400,4250,550,1600,600,1550,600,1550,550,1600,550,500,550,550,550,1550,600,500,550,500,600,500,550,500,600,450,600,1550,600,1550,550,500,600,1550,550,550,550,500,600,500,550,500,550,500,600,500,550,1600,550,1550,600,1550,600,1550,600,1550,600,1550,550,1600,550,1550,600,500,550,500,600,500,550,500,550,550,550,500,600,450,600,500,550,500,550,1600,550,1600,550,500,600,500,550,1600,550,500,550,500,550,550,550,500,600,500,550,500,600,450,600,500,550,500,550,550,550,500,600,1550,600,450,600,500,550,500,550,550,550,500,600,450,600,500,550,500,600,1550,550,500,600,500,600,1550,550,500,600,500,550,500,550,500,600};
 
void setup()
{
  Serial.begin(9600);
}
 
void loop() {
 
      // altered the code just to send/test my raw code
        irsend.sendRaw(powerOn,148,38);
        delay(2000);
}

NOTE that you'll have to change "148" to "16" in TWO places in the code...
Also, i hope you removed the first received raw value from the array (more info)

Hey ekman,

Two things:

  1. The array needs to have the values separated by commas
  2. The array should be declared outside of that command.

Here's a program i got from THIS BLOG : Digitalduino: Use sonar to control a TV!
[/quote]

Unfortunately I didn't get that working either, I can get the IR-led sending (flashing verified by phone camera) but the device is not reacting properly. I managed to decode the remote using LIRC and got the following results, but for the life of me I can really get any good information on how to convert it.

begin remote

  name  /home/pi/lircd.conf
  bits            3
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  one           204  7403
  zero          204  4867
  ptrail        204
  pre_data_bits   8
  pre_data       0x80
  gap          121717
  toggle_bit_mask 0x200

      begin codes
          KEY_UP                   0x1
          KEY_STOP                 0x3
          KEY_DOWN                 0x2
      end codes

end remote

So I just did a raw read with LIRC and it gave me the following.

begin remote

  name  /home/pi/lircd.conf
  flags RAW_CODES|CONST_LENGTH
  eps            30
  aeps          100

  gap          121716

      begin raw_codes

          name KEY_UP
              204    7399     205    7408     200    4869
              204    4874     195    4863     209    4872
              203    4864     203    4868     207    4868
              201    4870     203    7403     204

          name KEY_STOP
              192    7400     209    4865     208    4860
              208    4865     209    4865     204    4871
              203    4868     201    4869     203    4864
              209    7400     209    7399     209

          name KEY_DOWN
              205    7408     201    7405     202    4864
              209    4860     209    4864     210    4859
              210    4864     209    4871     199    4877
              199    7400     202    4864     209

      end raw_codes

The problem is that when I put in the numbers under irsend.sendRaw I still dot get the right signals sent from the Arduino platform.

#include <IRremote.h>
 
IRsend irsend;
 
// just added my own array for the raw signal
unsigned int powerOn[32] = {204,7399,205,7408,200,4869,204,4874,195,4863,209,4872,203,4864,203,4868,207,4868,201,4870,203,7403,204};
unsigned int powerOff[32] = {205,7408,201,7405,202,4864,209,4860,209,4864,210,4859,210,4864,209,4871,199,4877,199,7400,202,4864,209};
 
void setup()
{
  Serial.begin(9600);
}
 
void loop() {
 
      // altered the code just to send/test my raw code
        irsend.sendRaw(powerOn,32,38);
        delay(2000);
        irsend.sendRaw(powerOff,32,38);
        delay(2000);
}

Let me first say that i am an absolute beginner, but i have a similar problem and hence stumbled upon this thread.

In the code snippit directly above, the array is "32", but there are only 23 values in it??

cya
R

Yeah that is my mistake, the code is 23 not 32. I wrote it quickly by hand and slipped. ^^

Are you sure your device is 38 kHz?

Has the IR output worked on other devices?

What IR sender are you using and how is it wired? Note that you can't run a 100 mA IR LED directly from an Arduino pin and expect it to work.

Ha! Ekman, i fixed my problem, and i think it might fix yours too.

Basically the device i was sending the IR code to was too far away. I moved a lot closer, and it worked.

Now I'm looking into some way to increase the LED output using a transistor, as johnwasser as hinted at above.

cya
R

Hi all - I literally signed-up just to thank everyone because my problem, too, was distance to/from transmitter. I just couldn't believe how close I had to be for it to work (10~20 cm!). Thanks again!

which pin uses the code?
thanks

RB:
Hey ekman,

Two things:

  1. The array needs to have the values separated by commas
  2. The array should be declared outside of that command.

Here's a program i got from THIS BLOG : Digitalduino: Use sonar to control a TV!

#include <IRremote.h>

IRsend irsend;

// just added my own array for the raw signal
unsigned int powerOn[148] = {4400,4250,550,1600,600,1550,600,1550,550,1600,550,500,550,550,550,1550,600,500,550,500,600,500,550,500,600,450,600,1550,600,1550,550,500,600,1550,550,550,550,500,600,500,550,500,550,500,600,500,550,1600,550,1550,600,1550,600,1550,600,1550,600,1550,550,1600,550,1550,600,500,550,500,600,500,550,500,550,550,550,500,600,450,600,500,550,500,550,1600,550,1600,550,500,600,500,550,1600,550,500,550,500,550,550,550,500,600,500,550,500,600,450,600,500,550,500,550,550,550,500,600,1550,600,450,600,500,550,500,550,550,550,500,600,450,600,500,550,500,600,1550,550,500,600,500,600,1550,550,500,600,500,550,500,550,500,600};

void setup()
{
  Serial.begin(9600);
}

void loop() {

// altered the code just to send/test my raw code
        irsend.sendRaw(powerOn,148,38);
        delay(2000);
}




**NOTE that you'll have to change "148" to "16" in TWO places in the code...**
**Also, i hope you removed the first received raw value from the array ([more info](http://"http://dduino.blogspot.in/2011/11/improved-ir-code-reciever.html"))**

Hi sir
Iam looking for arduino tricks and method to send IR led on cell battery signals to IR RECEIVER connected to arduino
is it possible or not
i have had been used following sketch from Arduino Sketch recording raw IR signal and sending it through an infrared LED again every 2 seconds · GitHub
#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

boolean recording = true;
decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}

void loop() {
if (recording) {
if (irrecv.decode(&results)) {
Serial.println("IR code recorded!");
//irrecv.resume(); // Receive the next value
Serial.print("Recorded ");
Serial.print(results.rawlen);
Serial.println(" intervals.");
recording = false;
}
} else {
// replay mode
Serial.println("Sending recorded IR signal!");
irsend.sendRaw((unsigned int*) results.rawbuf, results.rawlen, 38);
delay(2000);
}
}

but i could not detect any signals

Hi, i have got same problem try everything that came into my mind and cant manage to work.
I am unable to turn on my AC Fujitsu
I am sure, that my system can send ir signal (tested and it works on my tv).

What i can receive from IRDump2 is raw data code for powerOn and other settings.

uint16_t rawData[57] = {450,450, 500,450, 450,450, 450,450, 450,450, 450,450, 450,450, 450,450, 450,450, 450,450, 450,450, 450,450, 450,450, 450,450, 500,450, 450,450, 450,450, 500,1300, 450,450, 450,1300, 500,1300, 500,450, 450,1300, 450,1300, 500,1300, 500,1300, 450,1300, 450,450, 450}; // UNKNOWN 68979EDA

Then i try to re-send with:
irsend.sendRaw(rawData, 57, 38);

Code is same every time, my device is 5-10 cm from AC unit so distance is not a problem.
Signal is send every 5 second, but device do not response.

Please HELP !!!

Hi neykovt,

I'm using an ESP8266 but this should work for you.
I'm sending this once every 5 seconds for testing purposes.
It succesfully starts my Ariston air conditioner.

Regards!

#include <IRremoteESP8266.h> //this might be IRremote.h for you
#include <IRsend.h> //you might not need this

#define RAWBUF 400 //check your board for memory on this one

IRsend irsend(4); // this is pin D2 on my esp

int khz = 38; //most common
uint16_t irSignal[] = {4401, 4289, 613, 1548, 609, 475, 609, 1552, 612, 1548, ........}

void setup()
{
Serial.begin(9600);
irsend.begin();
}

void loop() {

irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz);
delay(5000); // Wait 5 sec
}

Hi , change uint16_t to unsigned int