Issues with IRremote.h library, not sending IR

I am trying to follow this guide: Detecting an IR Beam Break with the Arduino IR Library

The goal is to have one Arduino emit an IR signal, as well as indicate when an IR receiver connected to the same Arduino receives the signal.

I am using the following hardware:
Arduino MKR 1310
1838B infrared receiver
LTE-4206 940nm 60ma IR LED
46 ohm resistor
330 ohm resistor
generic green LED

It is connected as this:
PIN1(output) -> generic green LED -> 330 ohm resistor -> ground
PIN2(input) -> middle leg of 1838B
PIN3(output) -> IR LED -> 46 ohm resistor -> ground
VCC -> right leg of 1838B
Ground -> middle leg of 1838B

The code used is:

#include <IRremote.h>

#define PIN_IR 3
#define PIN_DETECT 2
#define PIN_STATUS 1

IRsend irsend;
void setup()
{
  pinMode(PIN_DETECT, INPUT);
  pinMode(PIN_STATUS, OUTPUT);
  irsend.enableIROut(38);
  irsend.mark(0);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(PIN_STATUS, !digitalRead(PIN_DETECT));
  Serial.println(digitalRead(PIN_DETECT));
}

Expectation: When the IR led shines on the IR receiver, the green LED should light up.
But this doesn't happen.

I have troubleshooted and tested the following:
Pointed a TV remote towards the receiver and pushed buttons. The receiver receives the signal and the green LED lights up. This should mean that the issue is either with the IR LED or in the code.
To verify the IR led I loaded the following code instead:

#define PIN_STATUS 3

void setup() {
  // put your setup code here, to run once:
  pinMode(PIN_STATUS, OUTPUT);
  digitalWrite(PIN_STATUS, HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:

}

This code makes the IR led shine all the time, and I then pointed a Android tablet agains the LED and I can see it shining. This means the LED is connected properly and working.

I then loaded the first sketch again and looked at the IR LED with the Android tablet but I did not see it shining.
The code from the article has multiple comments about it working for them so I am not sure why the IR doesn't emit any light. Finally I tested with my multimeter and found that there wasn't any current sent out toward the IR LED. Anyone know why?
While which PIN to use for the IR LED is not defined in the code, it seems the IRremote.h assumes it will send it out on PIN 3 which is what I am using.

All the components share the same ground, GND from the Arduino board.
I am using IRremote by shirriff, z3t0 2.8.0

Finally I tested with my multimeter and found that there wasn't any current sent out toward the IR LED. Anyone know why?

Post some close up images of your wiring. Also, 46 ohms in the IR LED circuit is too low, you may have blown the output pin. 220 is as low as you can safely go. Reload the test sketch to confirm it's okay. Then change the resistor before you do damage it. Most online tutorials are written by people who don't know very much.

Is the IR library you're using compatible with the processor used on the Arduino MKR 1310?

aarg:
Post some close up images of your wiring. Also, 46 ohms in the IR LED circuit is too low, you may have blown the output pin. 220 is as low as you can safely go. Reload the test sketch to confirm it's okay. Then change the resistor before you do damage it. Most online tutorials are written by people who don't know very much.

Is the IR library you're using compatible with the processor used on the Arduino MKR 1310?

Thanks for the reply
I got an error on the site when I tried to reply "entity to big" which lost my response, so I will give the response first and attach the pictures secondly.
About the resistor, I actually think it has a too high value. When I calculated what to use I incorrectly calculated on 5V. The LED has a 1,2V forward voltage, and 60ma, which should mean that with 3.3V output to it the resistor should be 35 ohms. But since it does give a bright light with my second sketch I think the current resistor is okay.
I have reloaded both sketches many times, and each time the sketch with IRremote.h gives not light, wheres my second sketch always gives a bright IR light.
The MKR1310 is listed here: IRremote - Arduino Reference so I think it should be compatible.
I have also tried older versions of the IRremote library, but no change.

60mA exceeds the safe output current of an Arduino. So your calculations were correct, but calculate a disaster.

aarg:
60mA exceeds the safe output current of an Arduino. So your calculations were correct, but calculate a disaster.

Ah I wasn't aware of that, good to know, thanks!
I have changed it to 100 ohms now, which gives 20ma current instead. Re-tested that the LED is emitting IR light with my second sketch, but still nothing with the IRremote.h library.
Had some issues uploading the pictures

Try loading the images in a paint program and exporting them as a different file, before uploading to the forum. But now I think it's a software problem. Check the library documentation - you probably have to make some configuration changes to the library to make it work with the MKR1310, or possibly use a different output pin.

Oh, wait... the Github lists this option for your processor:

SAMD21 (receive only)

So you're out of luck. I made a good guess in reply #1. :slight_smile:

aarg:
Try loading the images in a paint program and exporting them as a different file, before uploading to the forum. But now I think it's a software problem. Check the library documentation - you probably have to make some configuration changes to the library to make it work with the MKR1310, or possibly use a different output pin.

Oh, wait... the Github lists this option for your processor:

SAMD21 (receive only)

So you're out of luck.

I just saw that as well further down now, doh! But good in the sense that we understand the issue. I have many other Arduino boards so I will just use another tone. Thanks for pointing me in the right direction!

Sure, or you could create 38kHz on some MKR pin by some other means...

aarg:
Sure, or you could create 38kHz on some MKR pin by some other means...

Yeah perhaps, but would be nice to just use a ready library.

FYI if anyone sees this. I switched to an Arduino Uno and its working perfectly. I did have some inconsistencies with the 1838B IR received. It only indicated for a short time each time it got the IR after not having it. So I switched to a TSOP38238 which is working without issues.
Thanks again aarg!

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