IR interference

I have HOT (Israel) streamer and a Samsung TV, I am trying to build an Arduino Nano repeater so when I press the of button in the streamer remote, the Arduino receives the code and send the on/off code for the Samsung TV so i won't need two remotes every time, I've got the codes and the circuit works perfectly, on the workbench I get the results in the serial monitor but the moment I move the room where the streamer is, the circuits stops receiving. As if the streamer itself interferes Any Ideas?

this is the code:

#include <IRremote.h>
#include <avr/wdt.h> // Include the library for resetting Arduino
const int RECV_PIN = 2; // IR receiver pin
const int SAMSUNG_SIGNAL = 0xE0E040BF; // Samsung IR signal code
const unsigned long NEC_SIGNAL = 0x10EF50AF; // NEC IR signal code
IRrecv irrecv(RECV_PIN);
decode_results results;
IRsend irsend;
bool samsungSignalSent = false;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (!samsungSignalSent && irrecv.decode(&results)) { // If IR signal is received and Samsung signal has not been sent
if (results.value == NEC_SIGNAL) { // If received signal is NEC: 10EF50AF
Serial.println("NEC signal received. Sending Samsung signal.");
delay(1000); // Delay to avoid repeated signals (adjust as needed)
irsend.sendSAMSUNG(0xE0E040BF, 32); // Samsung: E0E040BF;
Serial.println("Samsung signal sent.");
samsungSignalSent = true; // Set the flag to indicate Samsung signal sent
}
irrecv.resume(); // Receive the next IR signal
}
// Reset IR receiver state after sending Samsung signal
if (samsungSignalSent) {
irrecv.enableIRIn(); // Restart IR receiver
samsungSignalSent = false; // Reset flag
Serial.println("IR receiver state reset.");
}
}

What do you mean with "stops receiving"? No "NEC signal received" appears on the serial monitor?

I created a similar project (in my case it was more complex, a SkyQ remote repeater via WiFi/UDP, with a code translation between local NEC and remote SKYQ codings) and it looks you do what is needed. Except for the second call to "irrecv.enableIRIn();" I see at the end of loop(): you don't need to do that, just call it once on "setup()" and get rid of that "samsungSignalSent" flag.

And please learn how to make a good code formatting with proper indentation (press IDE command Ctrl-T to let it do it for you before posting here!).

So, try this (note I formatted your code and removed some other unnecessary elements like the unused SAMSUNG_SIGNAL variable you could restore later):

#include <IRremote.h>
#include <avr/wdt.h> // Include the library for resetting Arduino

const byte RECV_PIN = 2; // IR receiver pin

IRrecv irrecv(RECV_PIN);
decode_results results;
IRsend irsend;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println("An IR signal received, decoding...");
    if (results.decode_type == NEC { // If received signal is NEC
      Serial.println("  it's NEC!");
      if (results.value == 0x10EF50AF) { // If received signal is NEC: 10EF50AF
        Serial.println("  NEC signal good!");
        delay(1000); // Delay to avoid repeated signals (adjust as needed)
        Serial.print("  Sending Samsung signal...");
        irsend.sendSAMSUNG(0xE0E040BF, 32); // Samsung: E0E040BF;
        Serial.println("  sent.");
      }
    }
    irrecv.resume(); // Receive the next IR signal
  }
}

Thanks for your fast response!
Nothing on the monitor, it hangs, if i disconnect the power in the streamer i get response in serial monitor and I see signal sent to the TV set (i can check the IR with the laptop camera)
--the indentation broke in copy and paste :frowning:
I'll check you code...

Yeah, but you should see if the MCU won't start at all (means some hardware issue, but I don't think this is the case), or starts the setup but on loop the ".decode()" call always fails (I suspect you can't/shouldn't call ".enableIRIn()" more than once, and that's my first possible culprit) or decodes but the deteceted value isn't the expected one (in this case either another IR source is interfering or other kind of interference occours).

Give my code a try and let me know. You could just add to it a couple of prints on the setup() to make sure it started correctly:

void setup() {
  Serial.begin(9600);
  Serial.print("Starting...");
  irrecv.enableIRIn(); // Start the receiver
  Serial.println(" STARTED!");
}

Just as a side note, I understand your point (and in this case isn't a big problem :wink: ) but no, the "CODE" tag always keeps everything you paste inside exactly how you have on the clipboard.
In your case it happened because on the first time you pasted the code without any "CODE" tag, loosing any indentation information, and saved. When you realized the code doesn't show how you expected, you modified your post but as you just added "CODE" tag to the "damaged" code, it was still "damaged" even if inside the "CODE". The simplest way to paste your code is to click on the "CODE" editor button then paste your code replacing the placeholder "type or paste code here".

Water molecules absorb IR strongly. Your signal may be degraded.

your code is OK (just missing a bracket here: if (results.decode_type == NEC {
but the same results, i'm giving up for the time being, i am using old components, ordered new arduinos an diodes and will try again with the new ones.

Ok, update us as soon as you'll get new hardware, but in the meantime: exactly what are the "same results" you've got? Nothing appears on the Serial monitor at all? No "An IR signal received"? And not even the "Starting..." messages?

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