Merging Lora.h and IRremote.h

I am trying to merge "include <LoRa.h>" and "include <IRremote.h>" so that I can use a remote control

to send specific information via Lora.

Seperately, both Sketches function exactly as expected , however when I merge them together the

merged sketch works fine until it receives the signal from the remote then it displays the data once

and stalls.

#include <LoRa.h>
byte localAddress = 0xAA;
byte destinationAddress = 0xBB;
int staT = 0;
long lastSendTime = 0;
unsigned int interval = 3000;
int reC = 0;
//................IR REMOTE
#define DECODE_NEC 1

#include <IRremote.h>

int IR_RECEIVE_PIN = 9;
unsigned int keycode = 0;
void setup() {
  Serial.begin(9600);
  //...   STARTING LORA   ................
  Serial.println("Start LoRa duplex  TX  Sender");
  if (!LoRa.begin(915E6)) {
    Serial.println("LoRa init failed. Check your connections.");
    while (true) {}
  }
  //................IR REMOTE
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN);
}
void senddatA()
{
  if (millis() - lastSendTime > interval) {
    String message = String(staT);

    sendMessage(message);
    Serial.println("                                                                           SENT            " + message);
    // Serial.print(" from 0x" + String(localAddress, HEX));
    // Serial.println(" to 0x" + String(destinationAddress, HEX));
    lastSendTime = millis();

  }
}


//...   VOID SEND MESSAGE   .............................
void sendMessage(String outgoing) {
  digitalWrite(3, HIGH);
  LoRa.beginPacket();
  LoRa.write(destinationAddress);
  LoRa.write(localAddress);
  LoRa.write(outgoing.length());
  LoRa.print(outgoing);
  LoRa.endPacket();
  delay(500);


}
void receiveMessage(int packetSize) {
  if (packetSize == 0) return;
  int recipient = LoRa.read();
  byte sender = LoRa.read();
  byte incomingLength = LoRa.read();

  String incoming = "";

  while (LoRa.available()) {
    incoming += (char)LoRa.read();
  }

  reC = incoming.toInt();

  digitalWrite(6, HIGH); delay(500); digitalWrite(6, LOW);

  Serial.print (" Received    "); Serial.println (reC);
}
void irremotE() {
  keycode = IrReceiver.decodedIRData.command;
  
  if (keycode != 0) {
    Serial.print(" INside Void IRRec     "); Serial.println(keycode, HEX);
delay(1000);
   
   
  
    Serial.print(" END of Void IRRec");    
    
   
  }
   
}
void loop() {
 IrReceiver.resume();
 
  staT = 220; senddatA();
  receiveMessage(LoRa.parsePacket());     //    RECEIVE MESSAGE
  Serial.print ("   START VOID LOOP   ");Serial.println(keycode);
  delay(1000);
  
  if (IrReceiver.decode() != 0);
   keycode = IrReceiver.decodedIRData.command;
  Serial.print ("   IN VOID LOOP after irDeCode   ");Serial.println(keycode, HEX);
  
  delay(1000);
 irremotE();

This is the Screen Print of the outputs.

Did you check which pins LoRa.h is using for the LoRa device ?

Thanks . That was the problem. I had forgoeen to chech the Pin allocations for Lora.

I can now receive the Remote input however I cant get it to stop.

The attached screen shot is from just one press of the Remote button.

Obviously I still have a coding problem.

Ant suggestions?

Seem to have accidentially fixed the problem by usinf an old V2.7.1 of IRremote and alls working just fine.

I cannot get it to work with any IRremote Library V3.0.0 and above.

Farticus:
I cannot get it to work with any IRremote Library V3.0.0 and above.

Have you studied the README at the GitHub site? It details the changes required to work with v3.x. You can also look at the updated examples that come with the library.
https://github.com/Arduino-IRremote/Arduino-IRremote

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