💬 Infrared Sender and Receiver
-
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.
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 -
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 ?@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 -
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? -
@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ş
Hi, I am having an issue compiling the sketch and was wondering if you had any input or could help me out, This is what I get back when I try to compile;
-
@Talat-Keleş
Hi, I am having an issue compiling the sketch and was wondering if you had any input or could help me out, This is what I get back when I try to compile;
@ramoncarranza
Compiler complains about not understanding decode_type_t. It should be defined in .h file or maybe you defined it in sketch but there is a problem definetly.
Can you post whole sketch and IR library and error message if any other so we can check and test.By the way, I installed IRremote.h (v2.1.0) via library manager, and default sketch compiled without error on IDE 1.6.5 win7 and IDE 1.6.10 linux mint 17.
-
Re: 💬 Infrared Sender and Receiver
How do you enter the raw IR codes, i.e. those that aren't covered in the sketch? I have one through the receiver in the format - 23784 1800 -800 950 -1700 1800 -850 900 -850 950 -1700 1800 -850 900 -850 900 -850 950 -800 950 -850 900
-
@Talat-Keleş
Hi, I am having an issue compiling the sketch and was wondering if you had any input or could help me out, This is what I get back when I try to compile;
@ramoncarranza When I went and looked where the library manager installed the IRremote lib(for me C:\Users\User\Documents\Arduino\libraries), it had given it an odd name like arduino_294267. I renamed it to IRremote and the issue went away.
-
ok i record ir code 240E4F17 from my AC remote hov can i sent this code from my controler to IR node and request from node to sent that code (on/off) AC i was trying with raw mesage but i dot know what to send (Type/ Sub type , Acknowledge/ Payload)