IR Struggles - IRLED and Receiver are not friends...Why?

I am trying to get an IR transmitter and receiver working but I keep running into a brick wall.
I am using a IR LED - TSAL6100 and a receiver TSOP38538. I believe they should be compatible (they operate at 38kHz) and I have kept the wiring as simple as possible to reduce any wiring issues.

The IR LED works fine as long as I define the HIGH and LOW manually but as soon as I try to incorporate the IRremote functions it stops working. I have changed the LED for a standard one and it flickers as expected but when I change it back I get nothing (on my camera which is what I am using to check when it lights) and the receiver just comes back with 0xFFFFFF.

Its my first attempt using IR so I'm very new to it but I can't seem to get past this and I don't know what to try next

#include <IRremote.h>

#define IR_LED_PIN 9  // Pin connected to the IR LED
#define IR_RECEIVER_PIN 3  // Pin connected to the IR receiver

IRsend irSender(IR_LED_PIN);
IRrecv irReceiver(IR_RECEIVER_PIN);
decode_results results;

void setup() {
  Serial.begin(9600);
  irReceiver.enableIRIn();  // Initialize the IR receiver
  pinMode(IR_LED_PIN, OUTPUT);  // Configure IR LED pin as output
}

void sendIRSignal(unsigned long data, int bits) {
  irSender.sendNEC(data, bits);
}

void loop() {
  // Example: Send a custom 32-bit value
  unsigned long data = 0x12345678;
  int bits = 32;
  
  sendIRSignal(data, bits);
  
  // Test the IR receiver by checking for received signals
  if (irReceiver.decode(&results)) {
    Serial.print("Received Value: 0x");
    Serial.println(results.value, HEX);
    irReceiver.resume();  // Enable the receiver to receive the next signal
  }
  
  delay(1000);  // Wait for 1 second before sending the next signal
}

Does the IRremote library have a function to send data without the 38kHz carrier?

I'd use a bare IR LED and the IRremote library.

There is not a way to my knowledge to use the library without using the carrier frequency. I am going to try a standard ir remote to see if it registers that but atm I have just plugged an led to the pin out

Manually bit banging out at 38KHz modulation is not hard. I've handled this sort o thing before, for custom protocols (not NEC/Philips/Sony) by doing 10 38KHz square wave pulses of the LED for a 0 and 20 such pulses for a 1. These sort of IR recievrs contain internal filtering circuitry to amplify 38KHz signals and damp out DC levels, 50Hz/100Hz/60Hz/120Hz room lighting and higher frequencies which may be present, you have to modulate at 38KHz for them to detect your signals, otherwise you'd need a plain phototransistor or diode as your reciver instead if you wanted to avoid having to modulate*. The modules are generally rated, TSOP38238 and TSOP38438 which I've used before, to detect a signal when there are atleast 10 consecutive 38KHz pulses.

*this is usually results in DC and room lighting effects drowning out your IR signal, so you end up having to modulate it at some frequency of your choice and use op amp filters on the photodiode/phototransistor's output to pre-process them before they can be read by a microcontroller.

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