Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Building an IR Blaster

Building an IR Blaster

Scheduled Pinned Locked Moved My Project
60 Posts 10 Posters 36.7k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    steets250
    wrote on last edited by
    #15

    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 1

    Sensor 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);
    }
    }
    }

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #16

      @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.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        steets250
        wrote on last edited by steets250
        #17

        @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:

        Screen Shot 2014-06-05 at 6.13.42 PM.png

        And, when I create an IR device:

        Screen Shot 2014-06-05 at 6.13.56 PM.png .

        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 2

        Sensor 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.

        BulldogLowellB 1 Reply Last reply
        0
        • greglG Offline
          greglG Offline
          gregl
          Hero Member
          wrote on last edited by
          #18

          @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#msg170887

          try:
          Serial.print(message.data);

          And see why you get... if its the data you expected then you should be able to use it directly???

          1 Reply Last reply
          0
          • S Offline
            S Offline
            steets250
            wrote on last edited by
            #19

            @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.

            1 Reply Last reply
            0
            • S steets250

              @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:

              Screen Shot 2014-06-05 at 6.13.42 PM.png

              And, when I create an IR device:

              Screen Shot 2014-06-05 at 6.13.56 PM.png .

              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 2

              Sensor 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.

              BulldogLowellB Offline
              BulldogLowellB Offline
              BulldogLowell
              Contest Winner
              wrote on last edited by
              #20

              @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

              S 1 Reply Last reply
              0
              • BulldogLowellB BulldogLowell

                @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

                S Offline
                S Offline
                steets250
                wrote on last edited by
                #21

                @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.

                S 1 Reply Last reply
                0
                • S steets250

                  @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.

                  S Offline
                  S Offline
                  steets250
                  wrote on last edited by
                  #22

                  @BulldogLowell Ummm... How do I print gw.getStatus to Serial? :confused:

                  BulldogLowellB 1 Reply Last reply
                  0
                  • S steets250

                    @BulldogLowell Ummm... How do I print gw.getStatus to Serial? :confused:

                    BulldogLowellB Offline
                    BulldogLowellB Offline
                    BulldogLowell
                    Contest Winner
                    wrote on last edited by
                    #23

                    @steets250

                    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);
                    }
                    
                    S 1 Reply Last reply
                    0
                    • BulldogLowellB BulldogLowell

                      @steets250

                      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);
                      }
                      
                      S Offline
                      S Offline
                      steets250
                      wrote on last edited by
                      #24

                      @BulldogLowell Got it. Thanks!

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        steets250
                        wrote on last edited by
                        #25

                        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!! :smile: :clap: I think someone just needs to fiddle with the code some more.

                        1 Reply Last reply
                        0
                        • greglG Offline
                          greglG Offline
                          gregl
                          Hero Member
                          wrote on last edited by
                          #26

                          @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?

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            steets250
                            wrote on last edited by
                            #27

                            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.

                            L_Arduino.lua

                            I will sign off for now. Let me know if you get anything!

                            1 Reply Last reply
                            0
                            • BulldogLowellB Offline
                              BulldogLowellB Offline
                              BulldogLowell
                              Contest Winner
                              wrote on last edited by
                              #28

                              maybe tomorrow I can mess with it

                              thanks

                              1 Reply Last reply
                              0
                              • hekH Offline
                                hekH Offline
                                hek
                                Admin
                                wrote on last edited by
                                #29

                                @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

                                BulldogLowellB 1 Reply Last reply
                                0
                                • hekH hek

                                  @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

                                  BulldogLowellB Offline
                                  BulldogLowellB Offline
                                  BulldogLowell
                                  Contest Winner
                                  wrote on last edited by
                                  #30

                                  @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 03EC

                                  Yes, 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.

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    steets250
                                    wrote on last edited by
                                    #31

                                    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.

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      steets250
                                      wrote on last edited by
                                      #32

                                      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.

                                      1 Reply Last reply
                                      0
                                      • S Offline
                                        S Offline
                                        steets250
                                        wrote on last edited by
                                        #33

                                        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

                                        1 Reply Last reply
                                        0
                                        • hekH Offline
                                          hekH Offline
                                          hek
                                          Admin
                                          wrote on last edited by
                                          #34

                                          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)

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          22

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular