IRRemote Capture and resend with irsend.sendRaw

Hi All, Apologies for the cross post but I wasn’t able to make any progress (or yield a reply) to my other post (Sub-Forum)

I’m trying to capture a remote IR string to power on/off a TV. This has applicability to other projects but just focusing on the one that is “easy” and documented.

When I use this function to send the array, it does nothing (I’ve looked through my phone and can see nothing is transmitted)

irsend.sendRaw(powerIRout,68,38);

However, when I do this

for (int i = 0; i < 67; i++)
{
irsend.sendRaw(powerIRout, 1, 38); // 38 = kHz
delay(100);
}

It sends each array number but takes a good 3 seconds.

This is the first time i’ve used the IR transmit. I’m hoping to be able to do it with a remote power wall switch but that one seems more complex than the stereo power above.

Anyone? I'm not sure where else to ask for help...

If you post your code then perhaps someone could replicate your setup?

That’s a great idea :slight_smile:

Here it is. I was just testing to see if I can capture the code from my remote, then use the following to turn the TV on and off. My end goal is to turn the air conditioner (Daikin) but I figured i’d go the “simple” route first.

#include <IRremote.h>
#include <IRremoteInt.h>


#include <IRremoteInt.h>


//Turn Samsung TV on/off repeatedly to test program.
//IR LED connected to pin 3.

unsigned int powerIRout[68] = {4500,4450,650,1600,600,1650,550,1650,
600,500,600,550,550,550,550,550,550,550,600,1600,650,1600,600,
1650,600,500,550,550,550,550,600,550,500,600,550,550,550,1650,
650,500,550,550,550,550,550,600,500,600,500,600,500,1700,650,
500,500,1700,600,1600,650,1600,600,1600,650,1600,600,1600,650};

IRsend irsend;

void setup()
{
  Serial.begin(9600);
  pinMode (3, OUTPUT);  //output used in library
}

void loop() {
     digitalWrite(9,HIGH);   //Set Pin High for testing
     Serial.println("Waiting 500ms");
delay(500);
     digitalWrite(9,LOW);   //Set Pin Low after test
delay(500);
      Serial.println("About to send IR Signal");
      irsend.sendRaw(powerIRout, 68, 38);    //Sending the integer array above
      //irsend.sendRaw(Signal, sizeof(Signal)/sizeof(int), 38); //AnalysIR Batch Export - RAW  (from arduino forum) 
      Serial.println("Sent");
      Serial.println("Waiting 10 seconds"); 
delay (10000);  // Rest between power cycles
}//end of loop

I’m using Ken Shirriff’s library, v 2.0.1 June, 2015, and the following sends a burst of IR every ten seconds:

#include <IRremote.h>

//Turn Samsung TV on/off repeatedly to test program.
//IR LED connected to pin 3.

unsigned int powerIRout[68] = {
  4500,4450,650,1600,600,1650,550,1650,
  600,500,600,550,550,550,550,550,550,550,600,1600,650,1600,600,
  1650,600,500,550,550,550,550,600,550,500,600,550,550,550,1650,
  650,500,550,550,550,550,550,600,500,600,500,600,500,1700,650,
  500,500,1700,600,1600,650,1600,600,1600,650,1600,600,1600,650};

IRsend irsend;

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

void loop() {
  digitalWrite(9,HIGH);   //Set Pin High for testing
  Serial.println("Waiting 500ms");
  delay(500);
  digitalWrite(9,LOW);   //Set Pin Low after test
  delay(500);
  Serial.println("About to send IR Signal");
  irsend.sendRaw(powerIRout, 68, 38);    //Sending the integer array above
  //irsend.sendRaw(Signal, sizeof(Signal)/sizeof(int), 38); //AnalysIR Batch Export - RAW  (from arduino forum) 
  Serial.println("Sent");
  Serial.println("Waiting 10 seconds"); 
  delay (10000);  // Rest between power cycles
}//end of loop

Hi Dannable.

You were able to see the IR send or maybe your TV turned on/off

Couple of items I see missing

Items I’ve noticed

  1. #include <IRremoteInt.h> // removed
  2. Your array is slightly formatted differently.
  3. pinMode (3, OUTPUT); // was removed

I’m travelling at the moment but will take a look this weekend. I’m not sure which (if any) of those have broken my setup.

Thanks again!

I saw the led flicker every 10 seconds, I don't have a way to test the output unless I assemble a receiver/decoder!

Auto format reformatted the array, not I.

Tested a few things tonight and finally got it. Apparently, I have to have the LED a bit closer to my tv

But a couple of other weird things I noticed.

#1 - My array wouldn’t work until I used the array with a [68] despite having 68 numbers seperated by comma’s as seen in final code
unsigned int powerIRout

not

unsigned int powerIRout[68]

#2 - “E0E040BF” is indeed the hex code for Samsung On/Off

Here is the final working (atleast just power off)

#include <IRremote.h>

//Turn Samsung TV on/off repeatedly to test program.
//IR LED connected to pin 3.

unsigned int powerIRout[] = {4500,4450,650,1600,600,
1650,550,1650,600,500,
600,550,550,550,550,
550,550,550,600,1600,
650,1600,600,1650,600,
500,550,550,550,550,
600,550,500,600,550,
550,550,1650,650,500,
550,550,550,550,550,
600,500,600,500,600,
500,1700,650,500,500,
1700,600,1600,650,1600,
600,1600,650,1600,
600,1600,650};

IRsend irsend;

void setup()
{
  Serial.begin(9600);
  pinMode (3, OUTPUT);  //output used in library
}

void loop() {
     digitalWrite(9,HIGH);   //Set Pin High for testing
     Serial.println("Waiting 500ms");
     delay(500);
     digitalWrite(9,LOW);   //Set Pin Low after test
     delay(500);
     Serial.println("About to send IR Signal");
     irsend.sendRaw(powerIRout, 68, 38);    //Sending the integer array above
      //irsend.sendRaw(Signal, sizeof(Signal)/sizeof(int), 38); //AnalysIR Batch Export - RAW  (from arduino forum) 
      Serial.println("Sent");
      Serial.println("Waiting 10 seconds"); 
delay (10000);  // Rest between power cycles
}//end of loop