IRremote library is crashing my Photon

Hello there, this is my humble very first post here.
I’m having a problem with using an IR receiver with my Photon. I have imported the IRremote library in order to use the receiver. All fine until I write .enableIRIn(); in the setup() in order to start it. This line makes the Photon go into SOS.

Here is a little snippet of the initial part of the code:

int buzzer = D0;
int motion = D6;
int IRpin = D1;

IRrecv irrecv(IRpin);
decode_results cmd;

bool movementDetected = false;
bool isActive = false;
bool immediateAlarm = false;            // State of the immediate alarm, instantly triggers an alarm if true
int motionStatus = 0;                   // State of the motion sensor
int countdown = 9;                      // The alarms countdown starting value (10 seconds)
String password = "0000";               // The set standard password for activating/deactivating the alarm
String dangerPass = "0001";             // The silent alarm password (always +1 of the normal passwords last digit)

void setup() {
  irrecv.enableIRIn(); // This is apparently causing big problems


I saw another post about this, but it got closed without any visible replies. Any help would be greatly appreciated :slight_smile:

Haven’t had a look at the library, but could it be that it is trying to use detachInterrupt() inside the ISR? This has become disallowed some time after many libraries were already ported/contributed and hence may have broken them.

Also when stating that you experience an SOS panic it’s always good to also state how many slow blinks you see after the initial SOS code.
Additionally, when you cite a previous post/thread, could you link to that to for us to strap the two together.

what Device OS are you using?
Around two weeks ago I was able to compile and successfully run a project on a Photon with Device OS 2.0.0.-rc.4 and irrecv.enableIRIn() was not causing any trouble.

Side note: I configured my receiving pin on D6:

int RECV_PIN = D6;
IRrecv irrecv(RECV_PIN);

Also, I think the library is hardcoding a PWM output in A5, not sure if you are using it in your code:
line 488 of IRremoteInt.h

#define TIMER_PWM_PIN A5


Hello again, sorry I forgot to link to the mentioned post, I will look for it and link back to it. As for the number of blink it’s 14 blinks after the initial SOS.

Thanks for the reply both of you. The OS version seems to be 1.5.2. Could I just set the target OS to the one you mention to try and see if it works out? Also I notice you mention the library name as IRemoteInt.h while I have just IRremote.h
Also, can I just access the library and change the PWM output from A5?
Sorry for the many basic questions, but I just started out with the Photon.

but before changing it, are you using A5 in your project for another purpose?

that’s ok, IRemoteInt.h is a file contained in the library

yeah, please do and report back.

Good luck!

Ok! So I was able to make it work thanks to your advice! I only changed the target OS to 2.0.0.-rc.4 and changed the pin I used for RecvPin to D6 just to be sure and it just worked :slight_smile: So this seems to be an OS thing at this point. I didn’t change anything as far the A5 pin and I don’t even use it so wouldn’t matter :slight_smile: Thanks again for all the help!

It could be, but we do not have conclusive proof of that since you also changed D1 to D6.

Happy to hear all is good now nonetheless!!!

one last thing perhaps: best practices say that your Particle.function() declaration come on top of the setup() function, and specially not after a delay().
So you would want to do this instead:

void setup() {

  irrecv.enableIRIn(); // This is apparently causing big problems