Need help withI IR remote library reading IR sensor

Using a Teensy 4.1 and TSOP38238 to read signals from a generic mini IR controller

The IR protocol is NEC @ 38kHz.

I am using the Arduino IR library included with the TeensyDuino addon (doesn't seem to be a major difference between the teensy and standard arduino one)

The Teensy is known working. The standard on/off blink sketch works, in the sample code the serial print works.

In short, the Teensy 4.1 is not reading any IR signals. I tried using the host of IR receive examples given with the library (IR Dump, IR sample, simple IR receive, etc...) I don't know if I can dump a raw sensor output but I have no clue on how to access it.

I am trying to get the sample code working so I can implement the functions into the prebuilt code for this project, updating it and making it work on the Teensy 4.1.

I tried making my own completely stripped down code to no avail.

#define DECODE_NEC
#include <IRremote.h>

const int IR_RECEIVE_PIN = 1;

void setup() {
  Serial.begin(115200);
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}

void loop() {

if (IrReceiver.decode()){
  Serial.println("it works");
  delay(150);
}
IrReceiver.resume();
delay(100);
}

I read the output of the IR sensor using my o-scope and it is working. Although, I just got it and i'm still very much a novice so theres a possibility i'm misreading it.

Since I only have the one sensor and its already flush mounted to a PCB I tried to jump over the data pin to an arduino MEGA and it also had weird results (either false reads with empty data or just empty data).

I have been bashing my head on my keyboard for a week and my deadline is quickly approaching. I cannot use another board as the alternative is out of stock "temporarily" (until september, well and far beyond my deadline)

Please help.

I'm missing the wiring diagram. As you cannot read anything probably the hardware isn't wired correctly.

Thank you for the reply. Attached is the diagram.

I realized that the sensor was wired to port 20 instead of a power rail so I modified the code to write port 20 high. The output of the port is 3.3V which is within range of the sensor per the datasheet.

I checked port 21 with my oscilloscope during data transmission and the data is making it to the port, this time its coming out at 3.3V instead of 50mV.

There is still no output.

#define DECODE_NEC
#include <IRremote.h>

const int IR_RECEIVE_PIN = 1;

void setup() {
  Serial.begin(115200);
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
   pinMode(20, OUTPUT);
  digitalWrite(20, HIGH);
}

void loop() {

if (IrReceiver.decode()){
  Serial.println("it works");
  delay(150);
}
IrReceiver.resume();
delay(100);
}

Can you explain how this line of code correspond to your wiring diagram? In your wiring diagram the sensor isn't even powered by default.

I can't believe I missed that. That was supposed to be set to pin 21, the IR signal input pin.

I must have glanced over it many times.

In the main project the PLC will have to be in an ultra low power state most of the time so the power for the TSOP is set to a pin so it, and other hardware can be powered on only when needed.

It is now reading the remote signal and the console is responding it works, next i'll see if I can decode it and parse the data.

I think I should probably leave coding to be done during the day and not at 2am, or at the very least when I have access to coffee.

Thank you very much for your help Pylon, I greatly appreciate it.

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