IR sendRaw problem

Hello, recently I have been working on the IR library to replicate the signals from my remote control, and I have encountered some problems. I am using an Arduino NANO, and the library I am currently using is the IRremote by ArminJo version 4.4.3 (link:GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols). The following is my code to send the IR signal. As for the wiring diagram, I simply connected an IR led to pin 3 and a button to pin 10.(IR led 940nm 5mm)

#include <IRremote.h>

#define IR_SEND_PIN 3
#define FEEDBACK_LED_PIN LED_BUILTIN
#define Button_PIN 10

int ButtonState;
uint16_t rawData[] = {

1250,350,
1250,350,450,1250,1200,400,1250,350,
450,1200,400,1300,350,1250,450,1200,
450,1250,450,1200,1250,7150,1200,350,
1200,400,350,1300,1200,350,1200,400,
350,1300,350,1250,400,1250,350,1300,
350,1300,400,1250,1150,7200,1150,400,
1200,400,350,1250,1200,400,1150,450,
350,1250,350,1300,350,1250,350,1300,
350,1300,350,1300,1150

};

void setup() {
  Serial.begin(115200);
  pinMode(Button_PIN,INPUT_PULLUP);
  IrSender.begin(IR_SEND_PIN, true, FEEDBACK_LED_PIN);
  Serial.println("IR Ready");
}

void loop() {
  ButtonState=digitalRead(Button_PIN);
  if (ButtonState==0){
  IrSender.sendRaw(rawData, sizeof(rawData) / sizeof(rawData[0]), 38); 
  delay(2000);
  Serial.println("IR sent.");
  };
  
}

The rawData inside the code is the on/off signal for my fan (fan is from CHIMEI), and I collected the signal by using the IRremote example SimpleReceiver. The code worked when I tried to open and close my fan. However, when I changed the rawData to my AC signal, it won't work. The following is the signal for my AC. This is the signal that I have received from my serial monitor multiple times in the SimpleReceiver example, so I am pretty sure that this is the correct signal. (AC is from HITACHI)

3450,1500,
550,1050,600,350,600,300,600,300,
600,300,600,350,550,350,550,400,
500,400,500,450,450,450,450,450,
450,1200,450,450,450,450,500,450,
450,450,450,450,500,450,450,450,
450,500,450,450,450,450,450,500,
450,450,450,500,450,450,450,500,
400,500,450,450,450,1150,450,500,
450,1200,450,1150,450,1200,400,1200,
450,1200,400,1150,500,450,450,1200,
450,1150,450,1200,400,1200,450,1200,
400,1200,450,1150,450,1200,400,1200,
450,500,400,500,450,450,450,500,
400,500,450,450,450,500,400,500,
450,500,400,500,450,1150,450,1200,
400,500,450,450,450,1200,400,1200,
450,1200,400,1200,450,450,450,500,
400,1200,450,1200,400,500,400,500,
450,500,400,1200,450,500,400,500,
450,1150,450,500,400,500,450,1200,
400,1200,450,450,450,1200,400,1200,
450,500,400,1200,450,1150,450,500,
450,1200,400,1200,400,500,450,500,
400,1200,400,500,450,450,450,500,
450,450,450,500,400

I have considered that maybe the distance between me and my AC was too far, so I held my whole breadboard as close as possible to the AC, but it still didn't work. Much appreciated if anyone could answer my question.

Without a resistor or transistor this may overload the pin.

Your posted raw is 98bits. Hitachi uses many protocols but I have never seen anything short like this. So likely you didn't receive the complete signal.

Try to adjust the capture length:

#define RAW_BUFFER_LENGTH 450   // must come BEFORE including IRremote
#define RECORD_GAP_MICROS 20000  // also override the default gap

#include <IRremote.hpp>
...

And consider to build a transistor driver for your LED, direct pin drive (without resistor) is not ideal and can stress the pin.

Ps. if you have any Esp board, use this library:

Here's information on the Hitachi codes:

https://perhof.wordpress.com/2015/03/29/reverse-engineering-hitachi-air-conditioner-infrared-remote-commands/

I think @kmin is right that you haven't captured all of the transmission.

I had a quick look at Hitachi AC library, at least 264, 296, 344 and 424 bit protocols exist.

I wrote a raw capture sketch that will read up to 600 transitions over a period of two seconds:

https://github.com/gbhug5a/SimpleIRRaw/blob/main/IRCaptureRaw.ino

Connect your IR receiver module to D8. When you run it, you have to hit [enter] in the serial monitor to get it going. One short tap on the AC remote from about six feet away.

1 Like

Ok, I will try that Thx.

Hi, thanks again to everyone replying to my post. After testing the signal, I realized that the real signal is 899 bits as follows:

{3230,1670, 430,1220, 430,370, 430,370, 380,420, 380,370, 430,370, 430,370, 380,420, 
380,370, 430,420, 380,370, 430,370, 430,1220, 380,420, 430,320, 430,370, 430,370, 380,420, 
380,370, 430,370, 430,370, 380,420, 380,420, 380,370, 430,370, 430,370, 380,420, 380,420, 
380,420, 380,370, 380,1270, 380,420, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 
380,1270, 380,420, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 
380,1270, 380,1270, 380,370, 380,420, 380,420, 380,420, 380,370, 430,370, 380,420, 
380,420, 380,420, 380,370, 380,1270, 380,1270, 380,420, 380,420, 380,1270, 380,1270, 
380,1270, 380,1270, 380,420, 380,370, 380,1270, 380,1270, 380,420, 380,420, 380,420, 
380,1270, 380,370, 380,420, 380,1270, 380,420, 380,420, 380,1270, 380,1270, 380,370, 
380,1270, 380,1270, 380,420, 380,1270, 380,1270, 380,420, 380,1270, 380,1270, 380,420, 
380,370, 380,1270, 380,420, 380,420, 380,420, 380,420, 380,370, 380,1270, 380,1270, 
380,420, 380,1270, 380,1270, 380,1270, 380,420, 380,420, 380,1270, 330,1270, 380,420, 
380,1270, 380,1270, 380,420, 380,1270, 380,1270, 380,420, 380,420, 330,1320, 330,420,
 380,420, 380,1270, 380,420, 380,420, 380,370, 380,420, 380,420, 380,420, 380,370, 380,420, 
380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,420, 
380,420, 330,420, 380,420, 380,420, 330,470, 380,420, 330,420, 380,1270, 380,1270, 
380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,420, 330,470, 330,420, 
380,420, 380,420, 330,470, 330,470, 330,420, 380,1270, 380,1270, 380,1270, 380,1270, 
380,1270, 380,1270, 380,1270, 380,1270, 380,420, 330,470, 330,470, 330,420, 380,420, 
380,420, 330,470, 330,420, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 
380,1270, 380,1270, 380,420, 330,470, 330,470, 330,420, 380,420, 380,420, 330,470, 
330,420, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 380,1270, 
380,1270, 380,1270, 380,420, 380,420, 330,1320, 330,470, 330,1320, 330,420, 380,420, 
380,420, 330,1320, 330,1320, 330,470, 330,1320, 330,420, 380,1270, 380,1270, 380,420, 
380,420, 330,470, 330,1320, 330,420, 380,1270, 380,1270, 380,420, 380,1270, 380,1270, 
380,1270, 380,420, 330,1320, 330,470, 330,420, 380,420, 380,420, 330,470, 330,470, 
330,420, 380,420, 330,470, 330,470, 330,1320, 330,1320, 330,1320, 330,1320, 330,1320, 
330,1320, 330,1320, 330,1320, 330,420, 380,420, 330,470, 330,470, 330,420, 380,420, 
380,420, 330,470, 330,1320, 330,1320, 330,1320, 330,1320, 330,1320, 330,1320, 330,1320, 
330,1320, 330}; 

At first, I received the signal directly from my AC remote and the signal fluctuated between 450 bits ~ 500bits. After that, I used an app on my phone to send out the AC signal for my board to receive and the AC worked! Somehow the signal sent from my remote is weaker than the signal from the app on my phone so the AC won't turn on.

The code you posted is 264bits (not 899). Valid Hitachi protocol.

You mean your arduino? You need NPN transistor to drive your LED. Something like this:

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