I have been trying for some time now to get my IR sensor to work together with my 1.3 inch OLED display.
Each device works by itself; I test the OLED using a push button to allow me to display the next integer from a counter on the display.
I’m using this display “#include <Adafruit_SH110X.h>” and “Adafruit_SH1106G display = Adafruit_SH1106G(128, 64, &Wire, -1);”
When I test the IR sensor by itself, I use “#include <IRremote.h>”. I use the IR transmitter I got with my addressable LED strip — its uses NEC codes and I can sucessfully display the codes. I note that I belive I am using an old version of the IRremote lib since it says so on the serial output and the include file is “h” as opposed to “hpp”.
My problem may be the old library — I don’t think the APIs are the same in the new lib as the old, so I’d have to redo the code to use th new IRremote lib.
I wonder if anyone has actually produced a working sketch where the IR sensor is used with the OLED display?
If so, which IRremoote lib was used?
What is exaclty the error message that you get related to the IR Remote library?
Sara, here is the text from the serial output when using “IRremote.h” as opposed to “IRremote.hpp”.
Thank you for using the IRremote library!
It seems, that you are using a old version 2.0 code / example.
This version is no longer supported!
Please use one of the new code examples from the library,
available at “File > Examples > Examples from Custom Libraries / IRremote”.
Or downgrade your library to version 2.6.0.
Start with the SimpleReceiver or SimpleSender example.
The examples are documented here:
A guide how to convert your 2.0 program is here:
I have tried using IRremote.hpp by following the guide “how to convert your 2.0 program”, but I failed to make it work.
I get output like this even when I don’t use the IR transmitter:
Protocol=UNKNOWN 1 bits (incl. gap and start) received
Received noise or an unknown (or not yet enabled) protocol
I even tried downgrading to the older lib version 2.6.0 as suggested but to no avail.
I’d be happy with any sketch that actually works, preferably with NEC codes.
I’m currently away from the office, so I cant test code at the moment.
But, have you tried their simplest example without any modifications?
Sometimes when lirbaries are deprecated they still work even though they produce a warning message… I’m not sure if that’s the case. But sometimes it’s just a warning message, but the code compiles anyways.
Thanks for the reply/suggestion. I have tried many of the so-called simple examples for IRremote.
Here are 2 things I find interesting about trying to use the IR detector with one of the many IR transmitters in order to trigger a task.
- I have yet to find any examples of the code necessary for reading the IR detector which do NOT produce output on the serial monitor when NOTHING is transmitted via the IR transmitter. They all produce output when NOTHING is being done except me breathing to stay alive.
- I was quite surprised when I put my scope on the output pin of the IR detector and observed a regularly occurring pulse train!!! It’s no wonder the example code produces output on the serial monitor when nothing is being done (except breathing).
I was hoping for an example piece of code which did NOT produce ANY output on the serial monitor EXCEPT when I pressed a button on the IR transmitter! Then, all I would have to do is determine which button produced which code and then write my piece of code to recognize that code and take whatever action I decided was appropriate for that code — seems pretty simple, doesn’t it?
At this point, I conclude one of two things; either my IR detector is faulty OR the use of an IR detector to trigger a task on my Arduino is far more involved, in terms of programming, than I was led to believe by reading the many articles I’ve read on-line about doing this kind of thing.
I’m quite discouraged and am thinking of abandoning the idea of using IR to trigger a task.
I don’t know what to make of the fact that my scope shows the IR detector emitting output when no IR signal is being sent to it — perhaps it’s so sensitive, it picks up IR from ambient room light from incandescent or LED bulbs??
Do either you or Rui know of a sample piece of code that produces output ONLY when an IR signal is directed to the IR detector? I would love to get hold of such a piece of code along with the necessary info on its use such as which version of which IR library to use.
Thanks for whatever help you can provide.
I thought it good for me to let you and any others interested, know of my progress.
As usual, your advice was good as I discovered upon taking it and looking closely at the example.
I selected “TinyReceiver.cpp” from the custom library “IRremote”. It worked, but gave me more than I wanted.
As I indicated in a previous posting, all I wanted was a single output of the code corresponding to the button I pressed on the IR transmitter.
I was able to acheive exactly that with some minor modification of the example.
I was also able to display the code on the 1.3 inch OLED display using the following icludes/code:
Adafruit_SH1106G display = Adafruit_SH1106G(128, 64, &Wire, -1);
I now have exactly what I was trying to accomplish and all it took was some persistence and your excellent advice, as usual.
As always, thanks for your help — you and Rui are the BEST!