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?
