Cash Bounty for IRRemote IRrecv Port! :) [SOLVED]

That’s weird - I could have sworn there was! lemme check!
Hmm… Right you are Moors7 - I had pasted the same file twice.

As you suggested I deleted the project and started again, carefully pasting all the code for IRremote.h, IRremote.cpp,IRremoteInt.h. I left IRremoteInt.cpp blank since there is no code for this file - do I remove it? Tried that before and it didn’t work so this time I left it in.
I included the SparkIntervalTimer library using the IDE… then changed all the includes to #include “SparkIntervalTimer/SparkIntervalTimer.h”

But it still throws errors at me. I was really hoping this would save me some time :smile:

Here are the errors:

In file included from iragain.cpp:5:0:
IRremoteInt.h: In function 'int MATCH(int, int)':
IRremoteInt.h:182:41: error: 'USECPERTICK' was not declared in this scope
 #define TICKS_LOW(us) (int) (((us)*LTOL/USECPERTICK))
                                         ^

IRremoteInt.h:186:58: note: in expansion of macro 'TICKS_LOW'
 int MATCH(int measured, int desired) {return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired);}
                                                          ^
IRremoteInt.h: In function 'int MATCH_MARK(int, int)':
IRremoteInt.h:187:96: error: 'MARK_EXCESS' was not declared in this scope
 int MATCH_MARK(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us + MARK_EXCESS));}
                                                                                                ^

IRremoteInt.h: In function 'int MATCH_SPACE(int, int)':
IRremoteInt.h:188:97: error: 'MARK_EXCESS' was not declared in this scope
 int MATCH_SPACE(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us - MARK_EXCESS));}
                                                                                                 ^

IRremoteInt.h: At global scope:
IRremoteInt.h:204:23: error: 'RAWBUF' was not declared in this scope
   unsigned int rawbuf[RAWBUF]; // raw data
                       ^

IRremoteInt.h: In function 'int MATCH(int, int)':
IRremoteInt.h:186:112: warning: control reaches end of non-void function [-Wreturn-type]
 int MATCH(int measured, int desired) {return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired);}
                                                                                                                ^
IRremoteInt.h: In function 'int MATCH_MARK(int, int)':
IRremoteInt.h:187:110: warning: control reaches end of non-void function [-Wreturn-type]
 int MATCH_MARK(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us + MARK_EXCESS));}
                                                                                                              ^
IRremoteInt.h: In function 'int MATCH_SPACE(int, int)':
IRremoteInt.h:188:111: warning: control reaches end of non-void function [-Wreturn-type]
 int MATCH_SPACE(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us - MARK_EXCESS));}
                                                                                                               ^
make[1]: *** [../build/target/user/platform-6iragain.o] Error 1
make: *** [user] Error 2

If I remove the empty file IRremoteInt.cpp and re-add the #include “IRremoteInt.h” which gets deleted when you remove the file it gives me other errors:

SparkIntervalTimer/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::interrupt_SIT(action)':
SparkIntervalTimer/SparkIntervalTimer.cpp:360:15: warning: variable 'TIMx' set but not used [-Wunused-but-set-variable]
  TIM_TypeDef* TIMx;
               ^
SparkIntervalTimer/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::start_SIT(intPeriod, bool)':
SparkIntervalTimer/SparkIntervalTimer.cpp:276:23: warning: 'TIMx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  TIM_Cmd(TIMx, ENABLE);
                       ^
SparkIntervalTimer/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::stop_SIT()':
SparkIntervalTimer/SparkIntervalTimer.cpp:346:18: warning: 'TIMx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  TIM_DeInit(TIMx);
                  ^
SparkIntervalTimer/SparkIntervalTimer.cpp: In member function 'void IntervalTimer::resetPeriod_SIT(intPeriod, bool)':
SparkIntervalTimer/SparkIntervalTimer.cpp:476:23: warning: 'TIMx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  TIMx->PSC = prescaler;
                       ^
../../../build/target/user/platform-6/libuser.a(iragain.o): In function `MATCH_SPACE(int, int)':
IRremoteInt.h:186: multiple definition of `MATCH(int, int)'
../../../build/target/user/platform-6/libuser.a(IRremote.o):IRremoteInt.h:186: first defined here
../../../build/target/user/platform-6/libuser.a(iragain.o): In function `MATCH_MARK(int, int)':
IRremoteInt.h:187: multiple definition of `MATCH_MARK(int, int)'
../../../build/target/user/platform-6/libuser.a(IRremote.o):IRremoteInt.h:187: first defined here
../../../build/target/user/platform-6/libuser.a(iragain.o): In function `MATCH_SPACE(int, int)':
IRremoteInt.h:188: multiple definition of `MATCH_SPACE(int, int)'
../../../build/target/user/platform-6/libuser.a(IRremote.o):IRremoteInt.h:188: first defined here
collect2: error: ld returned 1 exit status
make: *** [48f160b9402f2346b447fa07ef40c405990088653777ba7deff177956635.elf] Error 1

When I remove a .cpp file the .h file does not get removed with it.
As it seems you have an IRremoteInt.h and iragain.h in that project, both declaring the same stuff!

Well that's interesting - because every time I add file to the project in the web-based IDE two files appear: a .cpp and a .h - and every single time it adds an include statement automatically, but every single time I remove the .cpp file it removes the include statement. tested it just now.

Do you mean to say I only need IRremote.cpp and IRremote.h and not IRremoteInt.h? - tried that too and got a whole lot of "undeclared" errors.

Here's what my project looks like:

For me the problem is I don't know how to set up the project and the readme tells me nothing about how to use the libraries. I would have thought you just include them and the IRrecvDemo.ino would compile nice and easy, but I have set this project up again and again, documented my steps, followed suggestions as best as I can and it has never compiled for me. Obviously there is something small that I am not doing correctly and I am really not sure what that is.
Maybe a quick glance at the above picture will alert you to an obvious mistake - any help would be appreciated.

No, I meant you should not have the content of IRremoteInt.h in iragain.h as well - in other words double (as the error messages above suggested - but your screenshot clarify)

What browser are you using and on what OS?

You could add an #include "IRremoteInt.h" in your IRremote.h to get rid of some "not declared" errors.

And get rid of the double include for IRremote.h (once with <> and once with "") in your iragain.ino

Thank you ScruffR.
I am using Safari and OS X Yosemite.

Eventually I got it to work.
Honestly, I think it was the warning that knocked me off track each time

Telling me I wasn’t including the file so I would include it again. This time I just ignored the warning and it worked. Thanks and if anyone else is having trouble getting it to work I’ll probably be able to help.

@Lindsay, you can just drag and drop or copy-paste images into the post, you don’t need and shouldn’t use dodgy image hosters in this forum, please.

OK thanks, I did not know.
Maybe Particle could put a button on the toolbar for insert image.

There is

It’s an upload button

2 Likes

Fantastic :slight_smile:

@ScruffR Apologies if this is coming in at the wrong point of reply. I am trying to use the IRremote library to implement a simple IR based beacon/virtual tether. The idea being an IR beacon (emitter) is placed on a ceiling/wall in a room and if the tethered devices (receivers) stop detecting the IR beacon signal then they have been removed from the room and will publish an event/alarm message.

I have included the IRremote (0.0.1) library off the web IDE in a simple receiving test code and this works fine when driven by a keyes IR handset.

I have write a very simple sketch using IRremote again to transmit a Sony Power on code

#include <IRremote.h>

/*******************************************************
 * Simple IR LED Beacon demo
 * 9 March 2017
 * Note TX is the output pin hard baked in
 * *****************************************************/

#define LED_PIN D7
//
IRsend irsend;
//
void setup()
{
    Serial.begin(9600);
    pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, LOW);
    delay(2000);
    Serial.println("setup in IR Beacon");
}
//
void loop() 
{
    Serial.println("Transmit Data");
    for (int i = 0; i < 50; i++)
    { 
        irsend.sendSony(0xa90, 12); // Sony TV power code
        digitalWrite(LED_PIN, HIGH);
        delay(40);
        digitalWrite(LED_PIN, LOW);
    }
    Serial.println("Wait 5 seconds");
    delay(5000);
}

However, when I build this I get the following error:

/src/irbeacon.cpp:1:22: fatal error: IRremote.h: No such file or directory
 #include <IRremote.h>
                      ^

compilation terminated.
make[1]: *** [../build/target/user/platform-6src/irbeacon.o] Error 1
make: *** [user] Error 2

Clearly I am missing something here :grimacing:

Have you actually imported the library in your project or just added the #include statement?

Your project/code drawer (<>) would need to look like this

I have imported the library and I have tried removing it and adding it back again. I agree it appears as though I have not imported the library.

I have just tried copying the code into a new app and then importing the library and it worked!

I have one other question though - there is no parameter for the pin on the IRsend function - looking at the library which has had many authors is the output pin A5 or TX? I ask this because I am getting no response on my IR receiver. I guess I could put my DSO on each pin and see what is happening.

The output pin should be A5 (in code called TIMER_PWM_PIN)
Since this library is originally meant for a specific IR-Tranceiver board the TX pin wasn’t made selectable.

Thanks. That’s what I had originally thought and then saw TX was used in examples. It may be that the IR LED isn’t working or I have not wired it correctly - I am assuming that the LED is wired to GND via a 150ohm resistor? Another reason it may not work is that the IR code may not being recognised by the receiver side.

I have hooked up the DSO and I am getting a carrier signal - a nice sine wave (40kHz ish?) and spikes up and down which travel along the wave when there is a transmission.

I see that the (much) simpler IRTransmitter library has been used more than the IRremote - given I just want to send a simple and unique signal pulse rather than a TV remote code would it be better if I used that library?

Thanks

You should be able to use a visible light LED to check the output and when you use a web or phone camera they often can record IR signals to check whether your IR transmitter does anything at all.

It might be that the LED isn’t an IR emitter! I have some on order - can retest then.

Any thoughts about the IRTransmitter library - it is a lot simpler.

@AnalysIR I finally got a day off so went back to look at this (and because of recent troubles users were having using the github lib).

I ported the latest (v2.2.1) of the source but someone has published my first version using using the name IRremote (TommyB…are you reading this?). If they can remove it then I can publish this updated version in v2 format.

@mdoan7, can you post the most recent link to your repo?
If @tommy_boy is the member who contributed your library, you may open an issue on his repo, but he won’t be able to remove the lib once it was imported to someone else’s project.
But Particle can transfer ownership once we can establish the facts (ping @jvanier).

Meanwhile, have you migrated your lib to the v2.0 structure?
This also allows to set the secondary dependencies to rid users of the need to import SparkIntervalTimer manually.

Having the lib in a publishable v2.0 format is compulsory now.

The repos I found in your GitHub are not v2.0 compliant (yet)
https://github.com/babean/IRRemote
https://github.com/babean/Arduino-IRremote

@ScruffR,@patyork,@jerware, here’s the git for the updated lib (it’s V2.0 compliant). I renamed the root directory and made a wrapper (empty .h/.cpp) to test compile on webIDE.

@jvanier, here’s the link to the original port of the lib.