­čĺČ Infrared Sender and Receiver


  • Admin

    This thread contains comments for the article "Infrared Sender and Receiver" posted on MySensors.org.



  • is this a learning mode module ?
    how use this module for learn my ir codes ?



  • @Reza said:

    is this a learning mode module ?
    how use this module for learn my ir codes ?

    This node decodes IR remote codes, print protocol and hex value to serial monitor and send it to gateway. Then controller can do logic on that to do some stuff.
    The sample code also receive on/off command from controller and emits IR signal depending on it.

    I use this node to turn on/off sony sound system (15bit sony protocol) and benq projector (NEC protocol) together beside htpc(via wol). Openhab rule send 8byte IR codes as V_IR_Send to node and node emits the required IR codes.



  • @Talat-Kele┼č
    I mean that every ir codes ( each brand for TV , audio . . . ) can learn to this node ( similar to zwave IR extender) and use OR in sketch we most write every codes that i will use ?!
    if this is a learning mode module !how many codes can learn to this ? ) for example zwave ir extender give 20 key ! or global cashe give many codes ?!



  • @Reza

    That node is simply IR to gateway (or vice versa) transfering medium. It doesn't learn just decodes or emits IR signals. This node is mostly dumb.

    To make it learn something like z-wave ir extender,

    Manually: Just manually decode and note down required codes then use them. Easy solution for known and used commands like on/off, vol +/-, numbers etc.

    • hard code it on node, however program space is tight. eeprom may be required.
    • hard code it on controller, easy for logic operations and automation needs.

    Automatic:

    • Write the code to learn and save it to eeprom. It requires some coding, at the end it might be a device like somehow z-wave ir extender. Howeer controller should know and send some kind of message to select right IR code. I didn't work on this solution yet.


  • @Talat-Kele┼č
    I am confused . i just want know if i want control my TV ( each switch for example on , off , vol + , vol - , number etc) with a domoticz and a IR sensor (mysensors) how i do it ?



  • @Reza

    Below is node sketch (v1.5.4) and openhab sitemap&items for simple control. More advanced control needs rules/scripts to make it more automation like.

    Set up the circuit, load below code or example code given and open serial monitor. Press buttons on IR remote and read hex values on serial. Note down values for buttons you need. (i.e. power off 0x184C, power on 0x104C, chanel up 0x1860 etc, RC5 protocol) If below sketch is uploaded to node, then adapt domoticz to send needed IR codes like i did in sitemaps part or use automation rules to send required commands to node to tv.

    Simple button based TV Control with OH

    Here is my node sketch:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik EKblad
     * Version 1.1 - V_IR_SEND / _RECEIVE 16.08.2016 Any hex command received over NRF is send with IR led
     * Version 1.2 - Don't send repeting codes - 19.08.2016 T. Keles
     * Version 1.3 - Repeating code blocking correction - 01.09.2016 T.Keles
     * 
     * DESCRIPTION
     * This sketch decodes IR remote and send to gateway.
     * Rules can interpret this or simpleused to find out button codes.
     * Controller sends string code values as V_IR_Send and incoming message is emitted by IR led.
     * An IR LED must be connected to Arduino PWM pin 3.
     * An optional ir receiver can be connected to PWM pin 8. 
     * All receied ir signals will be sent to gateway device stored in V_IR_RECEIVE
     *  http://www.mysensors.org/build/ir
     */
    
    #include <MySensor.h>
    #include <SPI.h>
    #include <IRLib.h>
    
    int RECV_PIN = 8;
    
    #define CHILD_1  3  // childId
    
    IRsend irsend;
    IRrecv irrecv(RECV_PIN);
    IRdecode decoder;
    unsigned int Buffer[RAWBUF];
    unsigned long prevMillis=0;
    MySensor gw;
    MyMessage msg(CHILD_1, V_IR_RECEIVE); //send decoded ir code
    
    void setup()  
    {  
      irrecv.enableIRIn(); // Start the ir receiver
      decoder.UseExtnBuf(Buffer);
      gw.begin(incomingMessage,2);
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("IR Remote", "1.3");
    
      // Register a sensors to gw. Use binary light for test purposes.
      gw.present(CHILD_1, S_IR);
    }
    
    
    void loop() 
    {
      gw.process();
      if (irrecv.GetResults(&decoder)) {
        unsigned long curMillis=millis();
        irrecv.resume(); 
        decoder.decode();
        decoder.DumpResults(); // dumresults print values to serial monitor
        
        if(curMillis-prevMillis>900){ // if last IR received less than 900ms pass it, otherwise send it to GW
        							  //This value is experimental and added to bypass rapidly repeating codes 
          prevMillis=curMillis;
          if(!(decoder.value==0 || decoder.value==0xffffff)){ // if value is valid
            char buffer[10];
            sprintf(buffer, "%08lX", decoder.value); //format it to 8byte Uppercase Hex format
            gw.send(msg.set(buffer));  // Send ir result to gw
          }
          
        }
      }
    }
    
    void incomingMessage(const MyMessage &message) {
    char ircode[11] = {0};  // in case your code takes the form of 0xE0E0FF0F
    //incoming ir code is string, however IRSend need unsigned long Below codes do the work 
       if (message.type == V_IR_SEND) {
          String hexstring = message.getString();
          hexstring.toCharArray(ircode, sizeof(ircode));
          // get the code as an unsigned long
          unsigned long code = strtoul(ircode, NULL, 0);
          if(code==0 || code ==0xFFFFFFFF) {} //if code is not valid, do nothing        
          irsend.send(RC5,code,13); // blast incoming hex code to IR device 
        }
        // Start receiving ir again...
        irrecv.enableIRIn(); 
    }
    

    In openhab .items file:

    String TV_power "TV" <television> (gHomeMedia) {mysensors="2;3;V_IR_SEND"}
    String TV_channel "Channel" <television> (gHomeMedia) {mysensors="2;3;V_IR_SEND"}
    String TV_volume "Volume" <television> (gHomeMedia) {mysensors="2;3;V_IR_SEND"}
    String IR_Receive "IR Code [%s]" <television> (gHomeMedia) {mysensors="2;3;V_IR_RECEIVE"}
    

    In openhab sitemap:

    Frame label="TV Control" {
    	Switch item=TV_power label="TV Power" mappings=[0x184C=OFF, 0x104C=ON]
    	Switch item=TV_channel label="Channel" mappings=[0x1860=UP, 0x1061=DOWN] visibility=[TV_power==0x104C]
    	Switch item=TV_volume label="Volume" mappings=[0x1850="V+", 0x1051="V-"] visibility=[TV_power==0x104C]
    	Text item=IR_Receive
    


  • @Talat-Kele┼č
    thank you my friend



  • This post is deleted!


  • is it possible to use with domoticz?



  • this module ( ir transmitter ) is weak in transmit . for more than 2 or 3 meter distance dont work . also for less than 1 meter we must direct connection exactly.
    i think this is related to power or noise or problem of module ?!
    can you guidance me ?



  • domoticz doesn't support this ?! i test this and i see domoticz wont detect this node



  • Hi @Reza ,
    Did you solve this problem?



  • @zhangzc

    hi , no . i can not use this device with domoticz



  • @Reza said:

    this module ( ir transmitter ) is weak in transmit . for more than 2 or 3 meter distance dont work . also for less than 1 meter we must direct connection exactly.
    i think this is related to power or noise or problem of module ?!
    can you guidance me ?

    I'm thinking of building this but am concerned about limited range. I'd like it to work 10ft/3m. Can someone confirm that this does not work at these distances? If so, is there a way to increase the range?



  • So how can is set this node in learnmode?? V_IR_RECORD in the Serial of Arduino?
    How do i store codes in the Eprom. SO i can use them in Domoticz



  • @Wackid

    I know how to read out the IR signals. And to put it in the sketch manually. But I really like to make use of the record function.
    Where and how do I make the node to set it in learn function.



  • I send command from remote control arduino read this command (i can see this in serial monitor) but this commands are not sending to gateway, my radio is working the sensor connect to gateway and controller. I use example Sketch given up in this page without changing anything.
    Any idea whats wrong in my setup?



  • This post is deleted!


  • I use this IR transmitter toward my LG Tv and it works at a distance of ~3.5 m, but IR LED must be well pointed to the Tv, otherwise it doesn't work.


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.