IR sensor + remote giving trash data signals

Hello,
I have an IR-sensor module wired up that came with a remote.
Problem is that the serial monitor spits out very random data when i press any button, also a different message everytime i press the same button. I used my TV-remote, other peoples codes and also tried it in a dark room to omit all light, but always the same story. Just random messages like:
DBE32B75
7E1F9A15
13DB9E7A
3F47B298
The library i use: IRremote - Arduino Libraries
Anyone got any idea why this happens?
Please let me know!

The problem will either be in the code that you have not posted or in the circuit that you have not posted a schematic of

1 Like

Well gimme the gist then:

#include <IRremote.h>
#include <IRremoteInt.h>
int dataPin = 2;
IRrecv receiver(dataPin);
decode_results results;

//__________________________________

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

//__________________________________

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

Looks like a somewhat outdated example.

Here is one with a current IRRemote library:

Sorry but I can't do anything with this code/library. I'm very new to programming so imma keep my hands of cpp for a while, also I just want to receive consistent data corresponding to the remote inputs. How do you mean outdated? The library? the code?

The code you posted uses library instructions that are outdated.

On this page you will find a complete documentation of the library:

1 Like

Thank you so much! I have been playing around with the updated library instructions and it seems to at least give me the same value every time. Still not the full data message I was looking for so i'll be working on that but at least you fixed the main issue.

If anyone has the same issue as I had, here is the working code (simplest possible version of IR sensor reception) with the updated library protocol

#include <IRremote.hpp>
IRrecv receiver;
int sensorDataPin = 2;

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

void loop() {
  if (receiver.decode()) {
    Serial.println(receiver.decodedIRData.command);  // , hex); if preferred 
    receiver.resume();
  }
}

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