IR Sender for stereo receiver


  • Hero Member

    Re: [IR Switch for Luminara Candle Automation (repost with video](photos and final sketch))
    @blacey Wanted to thank you for your sketch outline for 2 IR devices. Used it as model to create my two IR devices. One to turn stereo on and off and the other to switch between two preset stations. Only difficulty was finding the discrete on and off codes for the receiver which the remote for the receiver does not have.
    Works great! Only problem I had with what you called your quick and dirty example was that the call to gw.begin did not include the incomingMessage argument. Easy fix. Overall the example was a great help.



  • Can you share the code?


  • Hero Member

    @Tore-André-Rosander Yes, Will be glad to. Will post it later this evening.


  • Hero Member

    Here's the code you asked for. Turns receiver on and off and sends preset number for either of 2 stations that are on my FM HD tuner attached to the receiver. I put the hardware with the ir transmitter in the cabinet containing the receiver and tuner. Works great.

    /**
      *The code for discret on/off for my receiver could not be found in any of the online listings.
      *The code on line showed 46 and 47 for on and off respectively. Made an error in decoding from hex
      *that resulted in turning off the receiver. Thus I discovered that the on off codes for my receiver
      *are 93 and 94 respectively.
    */
      
    #include <MySensor.h>
    #include <SPI.h>
    #include <IRLib.h>
    
    #define NumChildDevices 2
    
    typedef struct IRCode {
      IRTYPES brand;
      unsigned long onIRcode;
      unsigned long offIRcode;
      unsigned int bits;
    } ir;
      
    ir childIR[NumChildDevices];
    IRsend iremitter;
    
    MySensor gw;
    MyMessage child1Msg(1, V_VAR1);
    MyMessage child2Msg(2, V_VAR2);
    
    void setup() {
      //specify node 7
      gw.begin(incomingMessage, 7);
      gw.sendSketchInfo("Radio IR", "0.1");
      
      // Initialize children devices  
      // 1. Sony Receiver: On power on, off power off
      gw.present(1, S_LIGHT);
      childIR[1] = {SONY, 0xBA0C, 0x7A0C, 15};
      
      // 2. HD Tuner: On select preset 4, off select preset 1
      gw.present(2, S_LIGHT);
      childIR[2] = {SONY, 0xC0BC8, 0xBC8, 20};
      
    }
    
    void loop() {
      gw.process();
    }
    
    void incomingMessage(const MyMessage &message) {
      
      //Determine the child device
      uint8_t child = message.sensor;
      
      //Get the relay status for the child device
      int incomingRelayStatus = message.getInt();
      
      //Emit the appropriate IR code to the child device
      iremitter.send( childIR[child].brand, incomingRelayStatus == 1 ? childIR[child].onIRcode : childIR[child].offIRcode, childIR[child].bits);
      //If sending to HD tuner, add "enter" code after preset code
      if (child == 2){
        //Don't send the enter command immediately after the number. Must wait a bit
        delay(500);
        iremitter.send (SONY,0xCBC8, 20);
      }
    }```

  • Hero Member

    I should add that I use a vera scene to turn the receiver on and select a particular preset for the Hd FM tuner. I just select device off for the receiver in vera to turn everything off.


Log in to reply
 

Suggested Topics

  • 8
  • 2
  • 2
  • 1
  • 1
  • 90

41
Online

11.2k
Users

11.1k
Topics

112.5k
Posts