IR Remote has same HEX value for every key

Hello,
I'm new to Arduino and wanted to learn IR remote related things. I just write below code and this code works well. But only the issue is I'm always getting same HEX code for small remote and my TV remote also provide same HEX code. Then I check with my phone's IR remote. (I have a fan that has a remote and I configure it to my phone) When I use my phone's IR remote it works well. May I know why this is happening? Anyone experience same?

#include <IRremote.h>

const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true);
}

void loop(){
  if (irrecv.decode(&results)){
      Serial.print(results.value);
      Serial.print(",");
      Serial.print(results.value, HEX);
      Serial.println("");
      irrecv.resume();
  }
}

Small remote this is the output for every key.

4294967295,FFFFFFFF
4294967295,FFFFFFFF
4294967295,FFFFFFFF
4294967295,FFFFFFFF
4294967295,FFFFFFFF
4294967295,FFFFFFFF
4294967295,FFFFFFFF
4294967295,FFFFFFFF
4294967295,FFFFFFFF
4294967295,FFFFFFFF

Below is the TV remote output

Key no 1
4294967295,FFFFFFFF
1253111734,4AB0F7B6

Key no 2
4294967295,FFFFFFFF
1253111734,4AB0F7B6

Key no 3
4294967295,FFFFFFFF
1253111734,4AB0F7B6

Key no 4
4294967295,FFFFFFFF
1253111734,4AB0F7B6

Key no 5
4294967295,FFFFFFFF
1253111734,4AB0F7B6

Key no 6
4294967295,FFFFFFFF
1253111734,4AB0F7B6

Key no 7
4294967295,FFFFFFFF
1253111734,4AB0F7B6

Key no 8
4294967295,FFFFFFFF
1253111734,4AB0F7B6

Key no 9
4294967295,FFFFFFFF
1253111734,4AB0F7B6

Key no 0
4294967295,FFFFFFFF
1253111734,4AB0F7B6

My phone's IR remote. (Fan is configured)

Speed button
338831067,143226DB
338831067,143226DB
338831067,143226DB
338831067,143226DB

Timer button
3768077238,E0984BB6
3768077238,E0984BB6
3768077238,E0984BB6
3768077238,E0984BB6

Mode button
924466310,371A3C86
924466310,371A3C86
243655727,E85E42F
924466310,371A3C86

Oscillation button
3606545071,D6F782AF
970202565,39D41DC5
970202566,39D41DC6
3051317709,B5DF69CD

Power off button
2737486129,A32AB931
2737486129,A32AB931
2737486129,A32AB931
2737486129,A32AB931

Here are the photos of remotes that I used.

In the IDE there's example code for a lot of things. Look there!

Check your connections, especially ground.

Thanks for the reply.
Could you be able to tell me where can I find those? Is it in tools section or anywhere else?

Thanks for the reply. I checked GND but no any loose connection. However I unplug it and again plug it, but still same result.

What type of sensor are you using to detect the InfraRed signals?

This one

Does it have any name, any designation? Google on a picture will not give any result I think.

In your IDE, FILE >> EXAMPLES >> will show all possible examples, the top 10 are Built-In examples, and the examples after that are the examples that were installed when you loaded your Library files.

Looking at your picture in Post #7, standard color coding is GND = black, VCC = red, OUT/SIG = any color. You do not need to follow that color code, but it looks strange and might be an indication of mis-wiring.

On second thought, it could not be a swapped GND and OUT. Too many things are working.

One note with IR Receivers, 0xFFFFFFFF could mean "key repeated"

Oh, wowo... 4294967295 is max int... Maybe use unsigned long for ??? your RECV_PIN?

Usually the KY-022 as a breakout board.

Pardon about that. It's not a google one. That photo taken from my phone. The name is "38KHz Infrared (IR) Receiver Module"

I just thought for a moment the module is defected and today I just bought new "VS 1838B IR receiver" sensor and it also gives the same result. :disappointed_relieved:

Doesn't look quite like the pictures of KY022 that I've seen.

However an image search seems to indicate that it is a 38kHz Infra Red receiver - Now confirmed by prasadweer in post #12.

@JohnLincoln - I agree... "amazon" sells non-"KY" products under the KY part number... for reference only?

To see if your receiver is producing a signal:

  • Connect a jumper wire from pin 7 to A0, then use analogRead(A0) and serial plotter to see if you have an input signal.
  • Use the scope to see the digital code (set trigger to falling edge)

In the simulator, here's what happens when 5 is pressed multiple times ...

A quick look at the examples here, most seem to work with timing in more detail ... perhaps your code is too basic to produce any results for your specific receiver.

3 Likes

Some how I could overcome this issue. Thanks everyone for helping me out. Here is the working code.

#include <IRremote.h>
#define LED1 8
#define RELAY 9

const long RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
unsigned long nowTime;
unsigned long considerTime;

void setup(){
	Serial.begin(9600);
	IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK);
	pinMode(LED1, OUTPUT);
	pinMode(RELAY, OUTPUT);
}

void loop(){
	nowTime = millis();

	if(IrReceiver.decode()){
		String irNum = String(IrReceiver.decodedIRData.command,HEX);
		Serial.println(irNum);
		Serial.println(nowTime);
		
		if(irNum=="c"){
			Serial.println("You pressed 1");			
			considerTime=0;
			onlight();
		}else if(irNum=="18"){
			Serial.println("You pressed 2");
			offlight();
		}else if(irNum=="5e"){
			Serial.println("You pressed 3");
			considerTime=nowTime + 10000;
			onlight();
		}else if(irNum=="8"){
			Serial.println("You pressed 4");
		}else{
			Serial.println("You pressed other key");
		}

		IrReceiver.resume();
	}

	if(considerTime==nowTime){
		digitalWrite(LED1, LOW);
		digitalWrite(RELAY, HIGH);
	}
}

void offlight(){
	digitalWrite(LED1, LOW);
	digitalWrite(RELAY, HIGH);
}

void onlight(){
	digitalWrite(LED1, HIGH);
	digitalWrite(RELAY, LOW);
}
3 Likes

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