IR to RF conversion using UNO issues

Hi all,

I’m trying to convert IR to RF signals combining and reusing code from

https://bitbucket.org/fuzzillogic/433mhzforarduino/get/latest_stable.zip

however with issues.

  • Able to receive IR signal, show them in serial monitor and depending on received code print some text.
  • Able to send RF signal, turning on and off lights succesfully.
  • Not able to make combination. When combining IR stil receives successfully, but RF signal is not sended properly.

From what I understand of all the library code it might be a timer / interrupt issue. I believe both libraries use the same timer (timer2), IR interrupts every 50 uS, RF every 260 uS. So i guess RF signal is broken every time by the shorter IR interrupt (but I might be wrong, as my programming skills are below average).

Sketch attached.

What would be the best way to overcome the issue?

Kind regards,
Bert

IRrecvDemo_JB.ino (1.03 KB)

Sketch attached.

Why? The code is small enough to post here:

/*
   IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
   An IR detector/demodulator must be connected to the input RECV_PIN.
   Version 0.1 July, 2009
   Copyright 2009 Ken Shirriff
   http://arcfn.com
*/

// based on IRremote and NewRemoteTransmitter code, this sketch tries to combine 
// receiving IR and sending RF

#include <IRremote.h>
#include <NewRemoteTransmitter.h>

IRrecv irrecv(11);
decode_results results;
NewRemoteTransmitter transmitter(7996130, 10, 260, 3);

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {


  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);

    switch (results.value)
    {

      case 0xA55A50AF:
        Serial.println("Plus");
        transmitter.sendGroup(true);
        // delay(5000);
        break;

      case 0xA55AD02F:
        Serial.println("Minus");
        transmitter.sendGroup(false);
        // delay(5000);
        break;
      default : break;
    }
    irrecv.resume(); // Receive the next value
  }
}

The NewRemoteTransmitter has a constructor that diddles with the hardware before the hardware is ready to be diddled with.

From what I understand of all the library code it might be a timer / interrupt issue.

The IR receiver uses a timer. The RF transmitter does not. It bit-bangs the timing.

If you comment out the irrecv stuff, and simply call transmitter.sendGroup() in loop(), does that work?