Unstable signal from IR remote control

I have a project using IR receiver ky 022 and IR remote control. I used the code (IRremote library version 2.6.0) and wiring on the Internet:

#include <IRremote.h>
#define IRPin 2
IRrecv irrecv(IRPin); 
decode_results results; 
void setup() {
Serial.begin(9600); 
irrecv.enableIRIn(); 
}
void loop() {
if (irrecv.decode(&results)) { 
  Serial.println(results.value,HEX);
  irrecv.resume();
}
}


After uploading the code and press one button, the signal received on Serial Monitor was unstable. For example, when I press the 0 button twice, the first hex signal received was '98AD50CC'; however, the second signal was '13CF8905'.
Someone please gives me a favor and thank you for your help.

Which response is correct? What is received on the third, fourth press? Are all the other buttons correct?

1 Like

Compared to the signal list on the Internet I have found, non of the received signal was correct.
The situation repeated with each press was a different response.
It happened with all the buttons.

  • If that’s a regular NANO, use 5v to power the IR receiver.

First guess is to add a short delay in the loop function. Second guess would be correct your baud rate in the program. Try this code.

#include <IRremote.h>
#define IRPin 2
IRrecv irrecv(IRPin); 
decode_results results; 

void setup() {
Serial.begin(115200); 
irrecv.enableIRIn(); 
}

void loop() {
if (irrecv.decode(&results)) { 
  Serial.println(results.value,HEX);
  irrecv.resume();
}//End of IF  
delay (100);
}//End of Loop


Try this code:

#include <IRremote.hpp>
const int IRPin = 2;
IRrecv irrecv(IRPin); 
//-------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn(); 
}
//-------------------------------------------------------------------
void loop() {
  if (IrReceiver.decode()) {
    Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
    irrecv.resume();
  }
}

5V power made the situation worse. It seems like IR receiver with 5V power receive signals not only from my IR remote control but also other IR sources.

  • And it should.

  • I use that IR transmitter often with the supplied receiver @5V, never had a problem, about 20 foot range.

  • Show us an image of your receiver.

These are received signals with 5V power. The signals came from somewhere and my IR remote control.

These are signals with 3.3V power. they were responses from one button (button 0) of my remote control only but they were unstable.

Your sketch did not work with my situation either. The signals were still unstable.

@sharkk I can't see the full IR receiver board from your photograph but have you got any power supply decoupling on that sensor?

Apparently you weren't able to actually match the baud rate with your serial monitor. Pic related.

1 Like

To answer my own question, The module you are using is described here:-
https://www.phippselectronics.com/using-the-infrared-receiver-sensor-ky-022-with-arduino/

Now digging deeper the underlying sensor's recommended application diagram is this:-

I used to work with set top boxes, and one team missed out the power supply decoupling shown, and while it first appeared to work we got thousands of returns from the field, and the customer for the box they were making sued for epidemic failure.

So my conclusion is that the breakout board you have is a very poor implementation of what is needed.

This might be my computer fault at very first. I always use 2400 baud Serial Monitor when Serial.begin(9600) and it works better than 9600 baud Serial Monitor. If I change to 9600 baud, the received signals will go unrecognised like this.

So what do you set your serial monitor baud rate to if you want to use Serial.begin(115200)?

The most suitable baud rate at this point is 31250 baud. However, some unrecognized characters somtimes appear on the received signals' string.

Well, I can't tell you exactly what your problem is with the IR receiver then, but I would say that investigating your baud settings is a great place to start. It seems like something is seriously wrong here between your device, your Arduino, your computer, and your Arduino IDE. It's hardly worth trying anything else until you can your serial monitor baud rate to match your Serial.begin baud rate.

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