I was using the IRremote.h library made by Ken Shirrif for a college project where I was simply sending an IR signal every 0.5 seconds and decoding it on the other side. There have apparently been some updates to the library recently and the code I was using is not working anymore. I have tried working through the instructions posted on the GitHub for converting programs but nothing I have tried has worked and I'm getting desperate now as my project deadline is fast approaching!
I am using an Elegoo Mega2560 to send the IR signal where the IR LED is connection to pin 9 (as per the instructions on GitHub). The code is being received on an ESP32. Currently no signal is being sent from the IR LED (I am checking using my phone camera and there is no blinking).
I was wondering if anyone on here has experienced the same problem with converting the old code and could help out?
I tried changing the library back to older versions but unfortunately I'm not sure what version I was originally using and none of the older versions have worked so far although I coded this in the last year.
Sorry, yes I am trying to work through the Readme but I can't seem to get it working.
I have made some progress now in that I believe a signal is being sent from the IR LED as I can now see a blinking when looking at it through my phone camera. Here is the updated IR Send code:
#include <IRremote.h>
const int IR_SEND_PIN = 9;
void setup() {
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); //Now included as per GitHub
}
void loop() {
IrSender.sendNECMSB(0x004efe71,32); //updated from sendNEC to sendNECMSB as per ReadMe
delay(500);
}
Unforuntaely i'm still having trouble receiving and decoding the IR Signal. This is the code I had tried to update for the receiver as per the Readme on GitHub:
#include <IRremote.h>
const int IR_RECEIVE_PIN = 4;
void setup() {
Serial.begin(115200); //Start Serial monitor in 115200
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}
void loop() {
if (IrReceiver.decode()) {
// value from receiver in Living room
if (IrReceiver.decodedIRData.decodedRawData == 0x004efe71) {
Serial.println("Living Room \r\n"); //sending to app
delay(1000);
}
else {
Serial.println("Out of sight");
}
delay(1000);
}
//irrecv.resume(); //This command isn't recognised in the updated version and I have yet to find a replacement in the new library
}
The current output I get for there receiver is just consistently "out of sight".
I realised that if my receiver was outputting "out of sight" then I must be at least receiving a signal so I put in some code to print the data being received in Hex value and I'm receiving the data: 8E7F7200.
It's good to know I am at least receiving something but that obviously isn't the hex value I am sending, at least not intentionally anyway. There are no other sources of IR around me at the moment so some how the value I am sending is being changed, I need to investigate further as I'm not sure why this is.
//irrecv.resume(); //This command isn't recognised in the updated version and I have yet to find a replacement in the new library
The example "IRrecvDemo" contains this:
/*
* !!!Important!!! Enable receiving of the next value,
* since receiving has stopped after the end of the current received data packet.
*/
IrReceiver.resume();