IR Break Beam Sensor Not Responding with ESP32 (Adafruit P2167, 3mm LEDs)

Hello, I’m trying to get the Adafruit IR Break Beam Sensor (3mm LEDs, product ID: P2167) working with my ESP32 Dev Board (HiLetgo ESP-WROOM-32), and I can’t get it to respond.
Setup Details:
IR emitter and receiver are both powered via 5V (confirmed with multimeter)
Red → 5V,, Black → GND , White signal wire → GPIO14
I’m using the following basic test sketch:

const int beamPin = 14;

void setup() {
  Serial.begin(115200);
  pinMode(beamPin, INPUT_PULLUP);
}

void loop() {
  int val = digitalRead(beamPin);
  Serial.print("Pin value: ");
  Serial.println(val);  // Expect 0 when beam is broken
  delay(200);
}

What I’ve Tried:

  • Verified 5V on red/black wires with multimeter
  • Confirmed emitter and receiver are directly facing each other (~5–10cm apart)
  • Checked GPIO14 pin with other test code (works fine)
  • Tried disconnecting ESP32 and testing signal wire with LED/resistor
  • Used Serial Monitor to read values — always get Pin value: 1 even when beam is broken

Questions:

  • Is there something I’m missing in wiring or logic?
  • Does this sensor require any external pull-up or resistor?
  • Is it possible the sensor is defective?

What happens if you disconnect the detector and just ground that pin you think is GPIO14?

  • The inputs on an ESP32 are 3V ! Okay, we see you are using the internal pull-up resistor.

  • Those breadboard power supplies are not that good at supplying higher currents.

  • Best check the 5V breadboard supply and the resulting ESP 3V3 supply.

  • The receiver might be open collector, try a 10k resistor. Okay, we see you are using the internal pull-up resistor.

  • With just the XMTR and RCVR connected (no ESP), put a 10K on sensor output to 5V.

  • Measure output voltage, should be 0v to 5v as you block XMTR.

  • You are using internal PU on the ESP, RCVR out will be 0V to 3V.

  • Are you 100% sure white wire is on GPIO14; think 14 is on the other side of the board.

Post an annotated schematic, I cannot follow your word description as it is not clear. The link to the processor is just a sales point.