Building an IR Blaster
-
Problems I found when investigating this earlier.
- The IR codes (from the xml-files) is too large to fit in one message. They need to be splitted into 2-3 parts. The Pronto-codes also needs to be converted into something usable by the Arduino library. If a checksum is calculated they could perhaps be stored on the Arduino-side in EEPROM after transmission and be "executed" by just sending checksum to trigger IR-transmission.
- Blaster is only one-way. We might want to receive remote commands back to vera also right? Learn-mode?
SQBlaster plugin code http://code.mios.com/trac/mios_sqblaster/browser/trunk
I would be really happy if someone could pursue this and provide a PR.
-
This would be really cool and a great alternative to the 200$ SQBlaster, good luck!
-
@gregl Thanks for the link! It helps to be able to create custom IR codes, should help with Hek's problem.
@hek Would it be possible to store the IR codes on the Arduino and have them transmitted locally? Using GREGL's custom device creation, the xml could transmit a two or three-digit code that is then matched to a larger code in the Arduino.
If the received message = 001, then transmit the code. Each number represents a different remote button.
Problem or learning codes can be solved using an IR reciever, like http://www.radioshack.com/product/index.jsp?productId=2049727. Codes can be printed to the Serial and then copied into the Arduino's code.
Thank you!
-
@steets250 said:
@hek Would it be possible to store the IR codes on the Arduino and have them transmitted locally? Using GREGL's custom device creation, the xml could transmit a two or three-digit code that is then matched to a larger code in the Arduino.
If the received message = 001, then transmit the code. Each number represents a different remote button.
That's it!
If there are a lot of long codes, you may have a problem with memory. Look into PROGMEM if you are not already familiar with it, and store all the codes in flash.
-
A quick code that I made that should be able to work with MySensors, I just need S_IR to be set up. Any news, @hek ??
#include <IRremote.h>
#include <Sensor.h>
#include <SPI.h>
#include <EEPROM.h>
#include <RF24.h>
#define ID 1Sensor gw;
int recvLED = 13;
int numberBtns = 34; //The number of entries in irRECIEVE.
IRsend irsend;const unsigned long irTRANSMIT[] = {
0xA3C8EDDB, //Power
0xA3C8EDDB, //Volume Up
//Insert other codes.
};void setup()
{
pinMode(recvLED, OUTPUT);
digitalWrite(recvLED, LOW);gw.begin();
gw.sendSketchInfo("IR Sender and Reciever", "1.0");
gw.sendSensorPresentation(ID, S_IR);
}void loop() {
unsigned long recv_value;
if (gw.messageAvailable()) {
message_s message = gw.getMessage();if (message.header.type==V_IR_SEND) {
recv_value = atoi(message.data);
irsend.sendSony(irTRANSMIT[recv_value], 1);
Serial.println(recv_value);
}
}
}
-
@steets250 said:
A quick code that I made that should be able to work with MySensors, I just need S_IR to be set up. Any news, @hek ??
News? Me?
Sorry..
Someone need to create/design a new "urn:schemas-arduino-cc:device:ArduinoIr:1"- device on the Vera side. As I said earlier I would be glad if someone else looked into this as I'm working on other parts right now.
-
@hek I think I may have just found a solution!! (Or I might have done something useless).
I the L_Arduino.lua, you have IR = {20, "urn:schemas-arduino-cc:device:ArduinoIr:1", "D_ArduinoIr1.xml", "IR "},
I simply changed it to IR = {20, "urn:schemas-arduino-cc:device:ArduinoIr:1", "D_IrTransmitter1.xml", "IR "},
and I updated the plugin. Now see what happens when I present S_IR:
And, when I create an IR device:
.
MySensors doesn't crash like before, and all I had to do was change D_ArduinoIr1.xml to D_IrTransmitter.xml.
My next problem is that I can't get the Arduino to serial printout the IR message that it is receiving. I have this program set up (simplified version that I posted before):
#include <Sensor.h>
#include <SPI.h>
#include <EEPROM.h>
#include <RF24.h>
#define ID 2Sensor gw;
void setup()
{
gw.begin();
gw.sendSketchInfo("IR Transmitter", "1.0");
gw.sendSensorPresentation(ID, S_IR);
}void loop() {
if (gw.messageAvailable()) {
message_s message = gw.getMessage();
Serial.print(message.data);
}
}Seeing that I am not familiar as to how messages are sent from Vera to Arduino, I am not sure if there is something that I am missing.
Thanks for your help!
P.S. If you do not have time to further look into this, is there anyone else that would be able to help me with this? I saw that you mentioned that you are working on other things currently.
-
@steets250 said:
recv_value = atoi(message.data);
atoi means asci to int
so i presume if you are getting something back its just a number?
I had same issue, again in heater sketch.
http://forum.micasaverde.com/index.php/topic,24588.msg170887.html#msg170887try:
Serial.print(message.data);And see why you get... if its the data you expected then you should be able to use it directly???
-
@gregl Thanks for the correction, but still no serial data. I changed the code in my previous comment to reflect your suggestion. I will have to see what Hek says. I have a feeling that the Vera is not sending a message back to the Arduino.
-
@steets250 said:
P.S. If you do not have time to further look into this, is there anyone else that would be able to help me with this? I saw that you mentioned that you are working on other things currently.
try to use a simple binary switch first
try to use a change of state:
if (gw.messageAvailable())
to then trigger a get:
gw.getStatus(CHILD_ID, V_VAR1);
vera side, send a new variable to V_VAR1 (variable 1) and then toggle the switch
once you grab the number in the arduino,, toggle the switch off and you are ready for the next command
-
@BulldogLowell I have tested this with a binary switch. I was able to serial print the 1 and 0 as it turned on and off as well as print a variable...
Just remembered that there was a V_IR_SEND and V_IR_RECEIVE.I will check that out now and tell you what I see.
-
@BulldogLowell Ummm... How do I print gw.getStatus to Serial?
-
for an integer:
if (message.header.type==V_VAR1) { int yourNumber = atoi(message.data); Serial.println(yourNumber); }
For a string:
if (message.header.type==V_VAR1) { String yourText = String(message.data); Serial.println(yourText); }
-
@BulldogLowell Got it. Thanks!
-
Nothing... It must have to do with the MySensors plugin not relaying the message back to the Arduino. This is probably because Hek was not done with the IR part of MySensors. As you have seen from previous posts, I changed the Lua file, but something else probably needed to be changed in order to send the IR code back to Vera. BTW - Code I used: (I used both RECEIVE and SEND because I didn't know which was from Vera to Arduino.)
void loop() {
message_s message = gw.getMessage();
if (message.header.type==V_IR_RECEIVE) {
String yourText1 = String(message.data);
Serial.println(yourText1);
if (message.header.type==V_IR_SEND) {
String yourText2 = String(message.data);
Serial.println(yourText2);
}
}
}Thanks everyone for the support with the IR project!!
I think someone just needs to fiddle with the code some more.
-
@steets250 said:
someone
you?
Do you get anything back froom the plugin like "no implementation" or similar?
Any clues in the <verip>/cgi-bin/cmh/log.sh?Device=LuaUPnP log?
-
Unfortunately, I don't know Luup, the only change that I made to the .lua file was to change a file name.
The log gives me this when I send out an IR code:
08 06/05/14 22:04:32.359 JobHandler_LuaUPnP::HandleActionRequest argument ProntoCode=0000 0068 0000 000D 0060 0018 0018 0018 0030 0018 0030 0018 0030 0018 0018 0018 0030 0018 0018 0018 0030 0018 0018 0018 0018 0018 0018 0018 0018 03EC <0x2d18b680>
02 06/05/14 22:04:32.359 Device_LuaUPnP::HandleActionRequest 55 none of the 1 implementations handled it <0x2d18b680>
01 06/05/14 22:04:32.809 ZZZ-A2 2 <0x2d18b680>
01 06/05/14 22:04:32.809 ZZZ-1 2 <0x2d18b680>
01 06/05/14 22:04:32.809 ZZZ-1b 0xb52db8 <0x2d18b680>
08 06/05/14 22:04:32.810 JobHandler_LuaUPnP::HandleActionRequest device: 55 service: urn:micasaverde-com:serviceId:IrTransmitter1 action: SendProntoCode <0x2d18b680>I want to see 0x2d18b680 come up on the serial, but I get nothing. I did also test to make sure that the Arduino was sending out serial messages.
If any one want to give it a try, replace the existing file with the one below (one one small change, nothing else is affected), and then use the code I posted previously. After the IR device is added to Vera, go to Devices, Add Device, IR Device, Ok, Select the IR Transmitter, and Choose Guided Setup. Then pick a random brand and try a code.
I will sign off for now. Let me know if you get anything!
-
maybe tomorrow I can mess with it
thanks
-
@steets250 said:
I think you have to create your own implementation of SendProntoCode.
You must take care of and handle all actions in D_IrTransmitter1.xml. Edit the I_Arduino.xml where you will find the actions defined.
<action> <serviceId>urn:micasaverde-com:serviceId:IrTransmitter1</serviceId> <name>SendProntoCode</name> <run>if (p ~= nil) then p.sendProntoCode(lul_device, lul_settings.ProntoCode) end</run> </action>
And then implement sendProntoCode in L_Arduino.lua which sends the actual code using sendCommand to gateway for further processing.
function sendProntoCode(device, prontoCode) sendCommand(luup.devices[device].id,"IR_SEND",prontoCode) end
But as I said in an earlier post the normal ProntoCode is too large to fit in one message over the air. So either you have to send short codes or split them somehow.
ProntoCode=0000 0068 0000 000D 0060 0018 0018 0018 0030 0018 0030 0018 0030 0018 0018 0018 0030 0018 0018 0018 0030 0018 0018 0018 0018 0018 0018 0018 0018 03EC
-
@hek said:
But as I said in an earlier post the normal ProntoCode is too large to fit in one message over the air. So either you have to send short codes or split them somehow.
ProntoCode=0000 0068 0000 000D 0060 0018 0018 0018 0030 0018 0030 0018 0030 0018 0018 0018 0030 0018 0018 0018 0030 0018 0018 0018 0018 0018 0018 0018 0018 03ECYes, but I think creating a state machine on the Arduino and storing these long pronto chains in flash may work.
If we can get it to send a single CHAR, that will allow is almost the entire ASCII set (minus the not useable) nearly 250 commands.
-
Hek - Thanks for the advice with the sendProntoCode! I will work on it today.
Bulldoglowell and Hek - I was just testing to see if the code would go through. I plan to have the Vera send out a number that represents a larger code stored in the Arduino.
-
I changed the files, and am now testing it out. Log says:
08 06/06/14 10:25:29.361 JobHandler_LuaUPnP::HandleActionRequest argument ProntoCode=0000 0071 0000 001A 0080 0080 0020 0020 0020 0020 0020 0020 0020 0060 0020 0020 0020 0060 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0060 0020 0060 0020 0060 0020 0060 0020 0020 0020 0060 0020 0020 0020 0060 0020 0060 0020 0060 0020 0060 0020 0060 0020 0020 0020 04DF <0x2ca29680>
02 06/06/14 10:25:29.362 Device_LuaUPnP::HandleActionRequest 38 none of the 1 implementations handled it <0x2ca29680>
01 06/06/14 10:25:29.551 ZZZ-A2 83 <0x2ca29680>
01 06/06/14 10:25:29.551 ZZZ-1 83 <0x2ca29680>
01 06/06/14 10:25:29.551 ZZZ-1b 0xe1b888 <0x2ca29680>
08 06/06/14 10:25:29.552 JobHandler_LuaUPnP::HandleActionRequest device: 38 service: urn:micasaverde-com:serviceId:IrTransmitter1 action: SendProntoCode <0x2ca29680>Last line looks promising. I guess I will try a shorter code, and see what I get.
-
Still nothing... I changed the some of the TV's IR codes (channel number buttons 1-6) to single digit numbers so that it would not be too big for serial. I case anyone wants to give it a shot, I attached the modified files.
I_Codeset_2.xml
D_Codeset_2.xml
I_Arduino1.xml
L_Arduino.lua
S_IR_Serial.ino
-
Not sure if it matters but shouldn't deviceType be "urn:schemas-micasaverde-com:device:IrDevice:1" ?
IR = {20, "urn:schemas-micasaverde-com:device:IrDevice:1", "D_IrTransmitter1.xml", "IR "},
And what is the difference between "D_IrDevice1.xml" and "D_IrTransmitter1.xml"? (source: http://wiki.micasaverde.com/index.php/Luup_UPNP_Files)
-
I believe that Ir device is the tV or DVD that is created , and transmittersend out the ir codes.
-
Might this be the problem?
The IR transmitter has no implementation file.
How do I get MySensors to create a device with I_IrTransmitter1.xml?
-
If you create a IR device as a "child" to Arduino you must handle all implementation yourself (like we just did for sendprotocode in the Arduino plugin).
I would suggest you create a thread or PM guessed on the micsa-forum who has good experience with the IR-device and is a really nice chap.
-
@steets250 Hi there
I did not notice this interesting topic til today.This might help:
http://blog.univers-domotique.com/2013/10/plugin-vera-arduir/
Give it a google translate
-
@Dvbit said:
http://blog.univers-domotique.com/2013/10/plugin-vera-arduir/
Thanks for the suggestion, however, the project talked about is going the wrong way. I want signals from Vera to the transmitter, not transmitter to Vera.
I got an IR receiver and programmed my codes into an Arduino program. For anyone wondering, I had no storage issues (previously talked about).I haven't given up on this yet (saving $200 is a pretty good motivation)! Still trying to find out how to get Vera to send a message to Vera with Vera's IR remote UI. Seeing as how I have been trying with absolutely no luck for the past few days, I might have to make me own remote UI.
I haven't contacted guessed yet but I will soon, still playing around with it myself.
Has anyone tried this yet?? Instructions above.
-
Ok. Please note that the guy in the post above talks about bidirectional signal "easily doable" in his post.
You may want to ask him
Tx for your wrk
-
@Dvbit I didn't see anything talking about a bidirectional signal. Where did you see that? I am going to check out what it says as well as the plugin files to see what I can find.
FWI: The IR receiver I ordered from RadioShack came, so I am able to program in the codes. It was mentioned earlier that the codes would take up a lot of space on the Arduino, but using the IRRemote library, receiving a remote signal gives me a hex that will work with some of my devices, so I don't see a storage issue. I have to remotes set up so far.
-
If you need space, you could always attach external memory (SD card perhaps) .
Compressing the codes would be nice.
Cannot wait until you have this worked out!
-
So I got the Arduino side of it done! Did I make any mistakes?
-
@steets250 said:
So I got the Arduino side of it done! Did I make any mistakes?
the codes all do what they need to?
interesting that the length of the codes vary so much
TV 1 = B10000
TV 0 = B101110011101001
-
I was quite surprised when I saw that. All of the codes work properly when used with the send sony command. On my second remote, it uses the NEC protocol, and has a longer code. Another remote I tested was coming in as only raw code, so if someone tried to use remotes with only raw code it could be pretty space consuming.
The sd card was a good idea! The program could also possible use multiple ir LEDs in different locations to get the signal to multiple devices, which is when the sd card might be needed.
I'm now checking over what changes hek suggested earlier, and comparing it with some other mysensors devices. It seems like the vera is not sending a message through the send pronto code function that is described below.
@hek said:
I think you have to create your own implementation of SendProntoCode.
You must take care of and handle all actions in D_IrTransmitter1.xml. Edit the I_Arduino.xml where you will find the actions defined.
<action> <serviceId>urn:micasaverde-com:serviceId:IrTransmitter1</serviceId> <name>SendProntoCode</name> <run>if (p ~= nil) then p.sendProntoCode(lul_device, lul_settings.ProntoCode) end</run> </action>
And then implement sendProntoCode in L_Arduino.lua which sends the actual code using sendCommand to gateway for further processing.
function sendProntoCode(device, prontoCode) sendCommand(luup.devices[device].id,"IR_SEND",prontoCode) end
-
Trying to change the code that Vera transmits, I discover this:
Right after selecting it here:
I'm not sure why Vera refuses to accept the Arduino as an IR transmitter. I will give the SQ blaster plugin another look at to see what they have.
-
La librairie IRremote permet la reception et l’émission de codes IR (Infrarouges) selon différents protocoles, la rendant compatible avec la plupart des télécommandes IR, et des appareils télécommandés par IR disponibles sur le marché.
Dans ce plugin, seule la partie réception de la librairie est utilisée (rien n’empêche la réalisation d’une interface d’émission, sauf que je n’en ai pas l’usage J ).
Irrlib supports input and output...then
The last sentence is "nothing blocks from developing an output interface but I do not need it"Cheers
-
@Dvbit
The problem isn't really doing bi-directional sending of ir-codes between vera/arduino. The problem is getting a dynamic presentation on vera-side up and running. What @steets250 is trying to do is getting the built-in ir device working.. which probably is the most flexible solution.Cheerio
-
@steets250 said:
Trying to change the code that Vera transmits, I discover this:
Right after selecting it here:
I'm not sure why Vera refuses to accept the Arduino as an IR transmitter. I will give the SQ blaster plugin another look at to see what they have.
you could try to look at the TiVo plugin, too.
-
So about half of this topic got cut off. To catch people up: The main goal of this topic is to create an IR transmitter device in Vera that can be used to send IR codes to a TV, DVD, DVR, etc. The transmitter is easy to assemble by attaching an IR LED and IR receiver (for learning codes) to an Arduino. The cost of this is about $15. Normal IR blasters range from $50 (USB UIRT - not wireless) to over $100 (Global Cache WF2IR - wireless). Seeing that I could save $85, a MySensors IR blaster looked great.
When trying to connect the IR blaster to Vera, and get it to transmit, I encountered some problems. The MySensors program currently does not support IR blasters, so I tried to edit the code and make it work. After looking at the SQ Blaster plugin, it gave me an idea of how to get the IR blaster to work. I edited lump files in an attempt to create an IR blaster device. I have so far been able to have Vera create an IR blaster device that shows up on the devices page.
However, when trying to use it to create an IR device (TV) I can go through the initial setup
But then click on any of the remote's buttons gets me this error message.
I have been stuck with this for a while now. Also, the Vera appears to be sending the IR command:
08 06/06/14 10:25:29.361 JobHandler_LuaUPnP::HandleActionRequest argument ProntoCode=0000 0071 0000 001A 0080 0080 0020 0020 0020 0020 0020 0020 0020 0060 0020 0020 0020 0060 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0060 0020 0060 0020 0060 0020 0060 0020 0020 0020 0060 0020 0020 0020 0060 0020 0060 0020 0060 0020 0060 0020 0060 0020 0020 0020 04DF <0x2ca29680>
02 06/06/14 10:25:29.362 Device_LuaUPnP::HandleActionRequest 38 none of the 1 implementations handled it <0x2ca29680>
01 06/06/14 10:25:29.551 zzz-A2 83 <0x2ca29680>
01 06/06/14 10:25:29.551 zzz-1 83 <0x2ca29680>
01 06/06/14 10:25:29.551 zzz-1b 0xe1b888 <0x2ca29680>
08 06/06/14 10:25:29.552 JobHandler_LuaUPnP::HandleActionRequest device: 38 service: urn:micasaverde-com:serviceId:IrTransmitter1 action: SendProntoCode <0x2ca29680>
But the IR code never arrives at the Arduino. I am currently trying to fix this problem, and was wondering if anyone could help. Hek suggested I send guessed (from Vera forums) a message which I will do.If any one wants to give this a try, here are the files to upload and test: Please let me know if you see something wrong with the code!
L_Arduino.lua
Which contains:
function sendProntoCode(prontoCode, device)
sendCommand(luup.devices[device].id,"IR_SEND",prontoCode)
endI_Arduino1.xml
Which contains:
<action>
<serviceId>urn:micasaverde-com:serviceId:IrTransmitter1</serviceId>
<name>SendProntoCode</name>
<run>sendProntoCode(lul_settings.ProntoCode, lul_device)</run>
</action>D_Arduino1.xml
Which contains:
<service>
<serviceType>urn:schemas-micasaverde-com:service:IrTransmitter:1</serviceType>
<serviceId>urn:micasaverde-com:serviceId:IrTransmitter1</serviceId>
<SCPDURL>S_IrTransmitter1.xml</SCPDURL>
</service>MySensors_IR.ino
Which creates the IR device (S_IR) and then serial prints whatever message it receives.Quick side note:There are two IR codes that Vera might be sending right now. A short code, 0x2ca29680 (in Vera log), or 0000 0071 0000 001A 0080 0080 0020 0020 0020 0020 0020 0020 0020 0060 0020 0020 0020 0060 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0020 0060 0020 0060 0020 0060 0020 0060 0020 0020 0020 0060 0020 0020 0020 0060 0020 0060 0020 0060 0020 0060 0020 0060 0020 0020 0020 04DF (also in Vera log). In the event that Vera is sending the longer code which is too big to send over the air, my solution to that was to have Vera send a single digit representing a longer IR code to send, for example 1 = power button, 2 = volume up, 3 = volume down, etc. The single digit method is already in the Arduino program so that I can change the IR codes on the Arduino easily without needing to change them in Vera.
Let me know if you have any questions. Thanks for your help!
-
@steets250 said:
In the event that Vera is sending the longer code which is too big to send over the air, my solution to that was to have Vera send a single digit representing a longer IR code to send, for example 1 = power button, 2 = volume up, 3 = volume down, etc. The single digit method is already in the Arduino program so that I can change the IR codes on the Arduino easily without needing to change them in Vera.
How were you thinking to get Vera to use that shorter code?
Or asked another way - where does Vera find the PRONTO codes it sends? Can you edit some file to get it to send a short code instead?
As for what code to send to the IR blasting node. You are sending the IR library's 32 bit (or less) interpreted code when there is one.
When there isn't one, I think your approach of saving the raw values to PROGMEM should work well; you can also also save the 32 bit hash the IR library creates. Suggestion: send that hash from Vera, have the node look it up in your PROGMEM and send the corresponding raw values. That is, use the hash rather than sending an arbitrarily assigned digit.
xUnless you have a lot of buttons, and they create long raw codes, you can probably fit them into PROGMEM without needing an SD card.
-
Thanks! @Zeph
When you create an IR device in Vera, it uses two files:
D_Codeset_2.xml and I_Codeset_2.xml.
You can change the codes in the I_Codeset file to whatever you want (I think). The codes in the I_Codeset file would be the shorter code representing a longer one in the Arduino program.What I still have to figure out is if Vera sends short codes (0x153) or the RAW codes. I'm hoping raw so I can change the code send to different numbers. And if Vera does send pronto codes, I wonder if Vera will try and convert the single digits (representing a larger command) into a pronto code (I doubt it).
-
Did you manage to get this working?
-
@Dringie No... I've been trying to get it to work, but I am still having issues getting Vera to send IR commands to the Arduino. I think it's the implementation of the actual command that send the IR info to the arduino.
I will keep working, and I will send guessed another message.
-
This looks like a great idea!!
I wish I knew enough of this stuff to help out... I will start building over the weekend with the stuff I have collected, and maybe I might learn some stuff that I can use to help get this project working
fingers crossed lol
-
@Homer Awesome! Let me know what you find. Are you using mysensors 1.7?
-
I was also planning to make an arduino based IR blaster , since I thought it would be working.
I just want to switch off my mediabox , with that I allready would be happy , when I read this post it is not possible :-S , or do I interpret it wrong?
Thanks,
Cor
-
Very much possible to solve if it's just a few things you want to control. The MySensors provided example creates a "lightswitch" device which triggers ir-sending of a couple of ir codes.
Not a full fledged blaster but it should be enough to solve your particular problem.
-
@ Hek ,
Thanks, I will post a building log in a new thread, for me , since I am very new with arduino and maybe other people can have abenefit as well , since on vera/z-wave there are no (cheap) "IR" - blasters available .
Cor
-
This post is deleted!
Suggested Topics
-
Welcome
Announcements • • hek