IR Recv working only on D0 and D1


I am new to the forum, and have previously only been using the Photon to control relays.

Lately I am progressing to IR remotes and LCD. For the IR remote project, I found something wierd.

When I started the project, I was using a 2-pin IR receiver (not the 3 pin one that I was supposed to use).

To my pleasant surprise, it worked when I connected it to D0 or D1. I could decode results.

However, I can’t get the same results with other pins. In fact, they do not work at all. I started using the 3 pin IR-receiver after this.

I realise that when the 3 pin receiver is connected to D0 and D1, i could get a fairly stable results. When it is connected to any other pins, I am getting stray signals. Adding a capacitor across Vcc and Gnd helped, but it would still receive some stray signals (modulated ones).

I have reattempted this with another 3 x 3 pin receivers (but the same make and model) to no avail.

Can anyone help explain this phenomenon?

  1. Why would the 2 pin IR receiver work for only D0 and D1?
  2. Why would there be no stray signals for the 3 pin IR receiver only when connected to D0 and D1?

Thanks a lot!

Not really sure which code you are using, but if it is using some hardware specific code, that may cause the issue or when it’s relying on PWM features, you need to make sure your selected pins do also support PWM.
Also when using interrupts, you need to make an informed decission which pins to use.

The info about interrupt and PWM capabilities can be found in the docs.

1 Like

Thanks for the reply.

I am using IRrecv from IRremote. I have cleaned up the code to isolate the problem with the following:

#include "IRremote.h"

int RECV_PIN = D1;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
  irrecv.enableIRIn(); // Start the receiver

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value

The connection is a simple connection as follows:

for 2 PIN IR Receiver:

RECV_PIN -> Cathode of 2 Pin IR Receiver
Ground -> Anode of 2 Pin IR Receiver

for 3 PIN IR Receiver:

RECV_PIN -> S of 3 Pin IR Receiver
V++ -> V++ of 3 Pin IR Receiver
Ground -> Gnd of 3 Pin IR Receiver

I would get output from Serial only when RECV_PIN is D0 or D1 (for the 2 PIN IR receiver).

Did you have I2C pull-up resistors on D0 and D1? Perhaps you were using them with the LCD that you mentioned?

  1. You didn’t specify a part number, but it sounds like you were using a phototransistor wired as an open drain output (example datasheet: On Semi QSE113). If you had a pull-up on RECV_PIN, your phototransistor could give you an ~38kHz modulated signal that was inverted as IRRemote expects to see. For the mysterious demodulation, there’s some noise filtering code in timer_isr() in IRRemote.cpp that might be responsible.

  2. Assuming your 3 pin device is an IR demodulator with a push-pull output, the shape of its output waveform could be altered if the output driver was working against a pull-up. The result could potentially act like low pass filter.

    How have you wired your circuit? Are you using a breadboard with lots of 20cm “dupont wire” jumper cables? If so, you could potentially cut down on noise by switching to shorter pieces of hand cut 22 AWG solid hookup wire. Or, you could skip the wire and power your 3-pin demodulator from the GPIO pins adjacent to RECV_PIN.

    What’s the part number of the 3 pin demodulator that you’re using? Have you checked the datasheet to see if it’s appropriate for the lighting in your room and the modulation frequency and coding scheme of your IR remote? (example datasheet: Vishay TSOP184xx)

Thanks for the information.

I have solved the issue and it’s as what wsnook mentioned.

My photon was connected to a power shield which had internal connections for D0 and D1 to be utilised as I2C.

1 Like