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. General Discussion
  3. Laser Christmas Light Control - 433MHZ

Laser Christmas Light Control - 433MHZ

Scheduled Pinned Locked Moved General Discussion
14 Posts 3 Posters 4.9k 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.
  • hekH Offline
    hekH Offline
    hek
    Admin
    wrote on last edited by
    #3

    IR sensor perhaps?

    https://github.com/mysensors/Vera/tree/development/IrRecordPlayback

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tbully
      wrote on last edited by
      #4

      @petewill Ah! I didn't think of exposing multiple sensors/devices! Ugh! I will think on this. The problem is, each button is momentary (not a switch/dimmer) so I'm not sure I have the experience to handle that. (good with electronics - not so good in the coding world) Although, I seem to remember others talking about momentary actions in the forums..... I'm sure it has been tackled.

      @hek I didn't know about that device..... I'm going to check in to that as well.

      Thanks!

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tbully
        wrote on last edited by
        #5

        Well, I made some progress today. I was able to sniff the traffic, determine the pulse width, and put together a simple sketch to test it. I had to modify the antenna on the transmitter as well as the one on the receiver inside the light. I'm now able to control it from anywhere in the house. Prior, only a few feet would work.

        However, I'm still not clear on how I'll present this to the controller.

        Here are the codes for the record:

        Power= 010101101010010100000001
        Red= 010101101010010100000010
        Green= 010101101010010100001000
        Blue= 010101101010010100001110
        down = 010101101010010100000100
        up= 010101101010010100010110

        Pulse width was measured at 310 ms. However, using my ear, it sounds and works better if set at 298ms.

        Any more thoughts on the controller side? Would really be helpful. I'm just not a very creative coder.

        Thanks!

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tbully
          wrote on last edited by tbully
          #6

          I'm forging ahead with multiple switches (lights) until someone can help me think through the best way to present to the controller. I'm trying to work out the logic to simulate a button-press.

          When someone/something presses "on" in the controller, the sensor will determine which button/light was pressed, send the appropriate data and then toggle the device back off. I've never updated a switch status back to the controller. My use of "send" below is clearly invalid.

          #define MY_DEBUG 
          
          #define MY_RF24_PA_LEVEL RF24_PA_LOW
          // Enable and select radio type attached
          #define MY_RADIO_NRF24
          //#define MY_RADIO_RFM69
          
          // Enable repeater functionality for this node
          //#define MY_REPEATER_FEATURE
          
          #include <SPI.h>
          #include <MySensors.h>
          
          
          #define POWER_CONTROLLER 1
          #define RED_CONTROLLER 2
          #define GREEN_CONTROLLER 3
          #define BLUE_CONTROLLER 4
          
          void before() {}
          
          void setup() {}
          
          void presentation()  
          {   
            // Send the sketch version information to the gateway and Controller
            sendSketchInfo("Christmas Laser Control", "1.0");
            present (POWER_CONTROLLER, S_LIGHT);
            present (RED_CONTROLLER, S_LIGHT);
            present (GREEN_CONTROLLER, S_LIGHT);
            present (BLUE_CONTROLLER, S_LIGHT);
          }
          
          void loop() {}
          
          void receive(const MyMessage &message) {
            // We only expect one type of message from controller. But we better check anyway.
            if (message.type==V_LIGHT) {
          
               Serial.print("Incoming change for sensor:");
               Serial.print(message.sensor);
               Serial.print(", New status: ");
               Serial.println(message.getBool());
               
               if (message.getBool()){
                 //send data for appropriate "button" and then toggle controller back to "off"/false
                 Serial.println ("Get ready to send radio message");
                  //send appropriate data here
          
                if (message.sensor == POWER_CONTROLLER) {
                  Serial.println ("Sending POWER data");
                 //send 433 mhz RF data and turn switch back off
                }
                else if (message.sensor == RED_CONTROLLER) {
                  Serial.println ("Sending RED data");
                  //send 433 mhz RF data and turn switch back off
                }
                else if (message.sensor == GREEN_CONTROLLER) {
                  Serial.println ("Sending GREEN data");
                  //send 433 mhz RF data and turn switch back off
                }
                else if (message.sensor == BLUE_CONTROLLER) {
                  Serial.println ("Sending BLUE data");
                  //send 433 mhz RF data and turn switch back off
                }
                  
              //   delay (1000);
              //   send(message.set(0));   
               }
          
              // Store state in eeprom
             // saveState(message.sensor, message.getBool()); 
             } 
          }
          
          petewillP 1 Reply Last reply
          0
          • T tbully

            I'm forging ahead with multiple switches (lights) until someone can help me think through the best way to present to the controller. I'm trying to work out the logic to simulate a button-press.

            When someone/something presses "on" in the controller, the sensor will determine which button/light was pressed, send the appropriate data and then toggle the device back off. I've never updated a switch status back to the controller. My use of "send" below is clearly invalid.

            #define MY_DEBUG 
            
            #define MY_RF24_PA_LEVEL RF24_PA_LOW
            // Enable and select radio type attached
            #define MY_RADIO_NRF24
            //#define MY_RADIO_RFM69
            
            // Enable repeater functionality for this node
            //#define MY_REPEATER_FEATURE
            
            #include <SPI.h>
            #include <MySensors.h>
            
            
            #define POWER_CONTROLLER 1
            #define RED_CONTROLLER 2
            #define GREEN_CONTROLLER 3
            #define BLUE_CONTROLLER 4
            
            void before() {}
            
            void setup() {}
            
            void presentation()  
            {   
              // Send the sketch version information to the gateway and Controller
              sendSketchInfo("Christmas Laser Control", "1.0");
              present (POWER_CONTROLLER, S_LIGHT);
              present (RED_CONTROLLER, S_LIGHT);
              present (GREEN_CONTROLLER, S_LIGHT);
              present (BLUE_CONTROLLER, S_LIGHT);
            }
            
            void loop() {}
            
            void receive(const MyMessage &message) {
              // We only expect one type of message from controller. But we better check anyway.
              if (message.type==V_LIGHT) {
            
                 Serial.print("Incoming change for sensor:");
                 Serial.print(message.sensor);
                 Serial.print(", New status: ");
                 Serial.println(message.getBool());
                 
                 if (message.getBool()){
                   //send data for appropriate "button" and then toggle controller back to "off"/false
                   Serial.println ("Get ready to send radio message");
                    //send appropriate data here
            
                  if (message.sensor == POWER_CONTROLLER) {
                    Serial.println ("Sending POWER data");
                   //send 433 mhz RF data and turn switch back off
                  }
                  else if (message.sensor == RED_CONTROLLER) {
                    Serial.println ("Sending RED data");
                    //send 433 mhz RF data and turn switch back off
                  }
                  else if (message.sensor == GREEN_CONTROLLER) {
                    Serial.println ("Sending GREEN data");
                    //send 433 mhz RF data and turn switch back off
                  }
                  else if (message.sensor == BLUE_CONTROLLER) {
                    Serial.println ("Sending BLUE data");
                    //send 433 mhz RF data and turn switch back off
                  }
                    
                //   delay (1000);
                //   send(message.set(0));   
                 }
            
                // Store state in eeprom
               // saveState(message.sensor, message.getBool()); 
               } 
            }
            
            petewillP Offline
            petewillP Offline
            petewill
            Admin
            wrote on last edited by
            #7

            @tbully When you say controller, are you referring to the remote control or your home automation controller? If it's the remote control it will be difficult to get the commands from that. For my blinds, I don't use them. All controlling is done through my HA controller. If you do it this way your status will always be correct at your HA controller.

            My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

            T 1 Reply Last reply
            0
            • petewillP petewill

              @tbully When you say controller, are you referring to the remote control or your home automation controller? If it's the remote control it will be difficult to get the commands from that. For my blinds, I don't use them. All controlling is done through my HA controller. If you do it this way your status will always be correct at your HA controller.

              T Offline
              T Offline
              tbully
              wrote on last edited by tbully
              #8

              @petewill Good question. I meant the home controller. The remote is completely out of the picture now. Using your ideas, I was able to figure out all the codes and can send them successfully via a test script. The hard part is done, ironically!

              I'm just not a great code guy.....

              I haven't put that logic in to my script yet. Instead, I'm trying to figure out how to "bounce" a light switch. When the home automation controller sends an "on" for a certain function, I'll send the RF data and then switch it back "off" to be ready for the next command/"button press" later. That's the part I'm having trouble with....

              petewillP 1 Reply Last reply
              0
              • T tbully

                @petewill Good question. I meant the home controller. The remote is completely out of the picture now. Using your ideas, I was able to figure out all the codes and can send them successfully via a test script. The hard part is done, ironically!

                I'm just not a great code guy.....

                I haven't put that logic in to my script yet. Instead, I'm trying to figure out how to "bounce" a light switch. When the home automation controller sends an "on" for a certain function, I'll send the RF data and then switch it back "off" to be ready for the next command/"button press" later. That's the part I'm having trouble with....

                petewillP Offline
                petewillP Offline
                petewill
                Admin
                wrote on last edited by
                #9

                @tbully I'm not exactly sure what your lights require but why do you need to send the off command to be read for the next command? With my blinds I just send the Up command then wait for the next command to come in. When I receive the down command I send that.

                My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                T 1 Reply Last reply
                0
                • petewillP petewill

                  @tbully I'm not exactly sure what your lights require but why do you need to send the off command to be read for the next command? With my blinds I just send the Up command then wait for the next command to come in. When I receive the down command I send that.

                  T Offline
                  T Offline
                  tbully
                  wrote on last edited by
                  #10

                  @petewill Because when the V_LIGHT sensor is switched "on" in Vera, I will fall in to the proper "if" condition above. However, I need to switch it back off after I send the data so I can later toggle it again. I wish there was a "button device" so I didn't have to worry about it.

                  0_1475431621870_upload-cc34bba7-207c-436e-9228-da1beeb24bc8

                    else if (message.sensor == RED_CONTROLLER) {
                      Serial.println ("Sending RED data");
                      //send 433 mhz RF data and turn switch back off
                    }
                  
                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    tbully
                    wrote on last edited by
                    #11

                    With the help of @petewill in a chat session, I was able to figure out why I couldn't send messages back.

                    I was failing to instantiate:
                    MyMessage msg(RED_CONTROLLER,S_LIGHT);

                    I'm only concentrating on the "red" case at the moment. As you can see from the log, I'm sending a "0" back to Vera but Vera is not showing off in the console. ** Am I not resetting the state correctly?**

                    0_1475434817226_upload-514b4107-7699-4c4b-8239-77ef99d97078

                    Incoming change for sensor:2, New status: 1
                    Get ready to send radio message
                    Sending RED data
                    Turn RED_CONTROLLER off in Vera
                    TSP:MSG:SEND 1-1-6-0 s=2,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=ok:0
                    
                    // Enable debug prints to serial monitor
                    #define MY_DEBUG 
                    
                    #define MY_RF24_PA_LEVEL RF24_PA_LOW
                    // Enable and select radio type attached
                    #define MY_RADIO_NRF24
                    //#define MY_RADIO_RFM69
                    
                    // Enable repeater functionality for this node
                    //#define MY_REPEATER_FEATURE
                    
                    #include <SPI.h>
                    #include <MySensors.h>
                    
                    
                    #define POWER_CONTROLLER 1
                    #define RED_CONTROLLER 2
                    #define GREEN_CONTROLLER 3
                    #define BLUE_CONTROLLER 4
                    
                    bool state;
                    MyMessage msg(RED_CONTROLLER,S_LIGHT);
                    void before() {
                      
                      }
                    
                    void setup() {}
                    
                    void presentation()  
                    {   
                      // Send the sketch version information to the gateway and Controller
                      sendSketchInfo("Christmas Laser Control", "1.0");
                      present (POWER_CONTROLLER, S_LIGHT);
                      present (RED_CONTROLLER, S_LIGHT);
                      present (GREEN_CONTROLLER, S_LIGHT);
                      present (BLUE_CONTROLLER, S_LIGHT);
                    }
                    
                    void loop() {
                     // if (state) {
                     //   Serial.println("State is true");
                        //send(msg.set(state?false:true), false); // Send new state and request ack back
                       // send(msg.setSensor(RED_CONTROLLER).set(0));
                     //   state = false;
                      }
                      
                      }
                    
                    void receive(const MyMessage &message) {
                      // We only expect one type of message from controller. But we better check anyway.
                      if (message.isAck()) {
                         Serial.println("This is an ack from gateway");
                      }
                      
                      if (message.type==V_LIGHT) {
                    
                         Serial.print("Incoming change for sensor:");
                         Serial.print(message.sensor);
                         Serial.print(", New status: ");
                         Serial.println(message.getBool());
                         
                         if (message.getBool()){
                           //send data for appropriate "button" and then toggle controller back to "off"/false
                           Serial.println ("Get ready to send radio message");
                            //send appropriate data here
                    
                          if (message.sensor == POWER_CONTROLLER) {
                            Serial.println ("Sending POWER data");
                           //send 433 mhz RF data and turn switch back off
                          }
                          else if (message.sensor == RED_CONTROLLER) {
                            Serial.println ("Sending RED data");
                            
                            //send data here
                            
                            wait (5000);
                            Serial.println ("Turn RED_CONTROLLER off in Vera");
                            send(msg.setSensor(RED_CONTROLLER).set(0));
                           }
                          else if (message.sensor == GREEN_CONTROLLER) {
                            Serial.println ("Sending GREEN data");
                            //send 433 mhz RF data and turn switch back off
                          }
                          else if (message.sensor == BLUE_CONTROLLER) {
                            Serial.println ("Sending BLUE data");
                            //send 433 mhz RF data and turn switch back off
                          }
                            
                        }
                    
                        // Store state in eeprom
                       // saveState(message.sensor, message.getBool()); 
                       } 
                    }
                    
                    1 Reply Last reply
                    0
                    • petewillP Offline
                      petewillP Offline
                      petewill
                      Admin
                      wrote on last edited by
                      #12

                      You're almost there! You need to change this line:

                      MyMessage msg(RED_CONTROLLER,S_LIGHT);
                      

                      to this

                      MyMessage msg(RED_CONTROLLER,V_LIGHT);
                      

                      My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                      T 1 Reply Last reply
                      1
                      • petewillP petewill

                        You're almost there! You need to change this line:

                        MyMessage msg(RED_CONTROLLER,S_LIGHT);
                        

                        to this

                        MyMessage msg(RED_CONTROLLER,V_LIGHT);
                        
                        T Offline
                        T Offline
                        tbully
                        wrote on last edited by
                        #13

                        @petewill ARGH! Of course! That was it! OK, this should get me going for a bit. Thanks so much!

                        I will work on this more and report back! Love these forums and how helpful they are. Hopefully, I will be able to return the favor someday!

                        1 Reply Last reply
                        1
                        • T Offline
                          T Offline
                          tbully
                          wrote on last edited by
                          #14

                          I thought I'd report back with my code. The sensor is up and running. I don't like that I just had to present switches but I'm not skilled enough to use the "custom" field and make a control in Vera. (On/Off, Blue, Red, Green, Motion) So this will have to do for now. It's probably OK as I'm just going to use automation to actuate the switches.

                          /**
                           * 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.
                           *
                           *******************************
                           *
                           * 
                           *Power=  010101101010010100000001
                           *Red=  010101101010010100000010
                           *Green=  010101101010010100001000
                           *Blue= 010101101010010100001110
                           *down =  010101101010010100000100
                           *up= 010101101010010100010110
                          
                          Decimal: 5678338 (24Bit) Binary: 010101101010010100000010 Tri-State: not applicable PulseLength: 310 microseconds Protocol: 1
                          Raw data: 9624,192,1032,808,416,232,988,840,384,256,964,872,360,876,340,288,936,884,336,288,936,888,336,284,936,284,940,884,340,284,936,884,340,284,936,288,936,284,940,284,936,284,940,284,936,884,336,288,936,
                           * 
                           * 
                           * 
                           * 
                           * 
                           */ 
                          
                          // Enable debug prints to serial monitor
                          #define MY_DEBUG 
                          
                          #define MY_RF24_PA_LEVEL RF24_PA_LOW
                          // Enable and select radio type attached
                          #define MY_RADIO_NRF24
                          //#define MY_RADIO_RFM69
                          
                          // Enable repeater functionality for this node
                          //#define MY_REPEATER_FEATURE
                          
                          #include <SPI.h>
                          #include <MySensors.h>
                          #include <RCSwitch.h>
                          
                          #define POWER_BUTTON 1
                          #define RED_BUTTON 2
                          #define GREEN_BUTTON 3
                          #define BLUE_BUTTON 4
                          #define NoMotion_BUTTON 5
                          #define MedMotion_BUTTON 6
                          #define FastMotion_BUTTON 7
                          
                          unsigned long delay_time = 500;
                          
                          bool state;
                          MyMessage msg_power(POWER_BUTTON,V_LIGHT);
                          MyMessage msg_red(RED_BUTTON,V_LIGHT);
                          MyMessage msg_green(GREEN_BUTTON,V_LIGHT);
                          MyMessage msg_blue(BLUE_BUTTON,V_LIGHT);
                          MyMessage msg_NoMotion(NoMotion_BUTTON,V_LIGHT);
                          MyMessage msg_MedMotion(MedMotion_BUTTON,V_LIGHT);
                          MyMessage msg_FastMotion(FastMotion_BUTTON,V_LIGHT);
                          
                          RCSwitch mySwitch = RCSwitch();
                          
                          
                          void before() {
                            
                            }
                          
                          void setup() {
                            mySwitch.enableTransmit(8);
                            mySwitch.setPulseLength(298);
                            mySwitch.setRepeatTransmit(2);
                            }
                          
                          void presentation()  
                          {   
                            // Send the sketch version information to the gateway and Controller
                            sendSketchInfo("Christmas Laser Control", "1.0");
                            present (POWER_BUTTON, S_LIGHT);
                            present (RED_BUTTON, S_LIGHT);
                            present (GREEN_BUTTON, S_LIGHT);
                            present (BLUE_BUTTON, S_LIGHT);
                            present (NoMotion_BUTTON, S_LIGHT);
                            present (MedMotion_BUTTON, S_LIGHT);
                            present (FastMotion_BUTTON, S_LIGHT);
                          }
                          
                          void loop() {
                           // if (state) {
                           //   Serial.println("State is true");
                              //send(msg.set(state?false:true), false); // Send new state and request ack back
                             // send(msg.setSensor(RED_CONTROLLER).set(0));
                           //   state = false;
                          //  }
                            
                            }
                          
                          void receive(const MyMessage &message) {
                            // We only expect one type of message from controller. But we better check anyway.
                            if (message.isAck()) {
                               Serial.println("This is an ack from gateway");
                            }
                            
                            if (message.type==V_LIGHT) {
                          
                               Serial.print("Incoming change for sensor:");
                               Serial.print(message.sensor);
                               Serial.print(", New status: ");
                               Serial.println(message.getBool());
                               
                               if (message.getBool()){
                                if (message.sensor == POWER_BUTTON) {
                                  Serial.println ("Sending POWER data");
                          
                                  mySwitch.send("010101101010010100000001");
                           
                          
                                  Serial.println ("Turn POWER_BUTTON off in Vera");
                                  send(msg_power.setSensor(POWER_BUTTON).set(0), true);
                                }
                                else if (message.sensor == RED_BUTTON) {
                                  Serial.println ("Sending RED data");
                                  mySwitch.send("010101101010010100000010");
                             
                                  Serial.println ("Turn RED_BUTTON off in Vera");
                                  send(msg_red.setSensor(RED_BUTTON).set(0), true);
                          
                                 }
                                else if (message.sensor == GREEN_BUTTON) {
                                  Serial.println ("Sending GREEN data");
                                  mySwitch.send("010101101010010100001000");
                          
                                  Serial.println ("Turn GREEN_BUTTON off in Vera");
                                  send(msg_green.setSensor(GREEN_BUTTON).set(0), true);
                                }
                                else if (message.sensor == BLUE_BUTTON) {
                                  Serial.println ("Sending BLUE data");
                                  mySwitch.send("010101101010010100001110");
                          
                                  Serial.println ("Turn BLUE_BUTTON in Vera");
                                  send(msg_blue.setSensor(BLUE_BUTTON).set(0), true);
                                }
                                else if (message.sensor == NoMotion_BUTTON) {
                                  Serial.println ("Sending No Motion data");
                                  mySwitch.send("010101101010010100000100");
                                  delay(delay_time);
                                  mySwitch.send("010101101010010100000100");
                                  delay(delay_time);
                                  mySwitch.send("010101101010010100000100");
                                  Serial.println ("Turn No Motion in Vera");
                                  send(msg_blue.setSensor(NoMotion_BUTTON).set(0), true);
                                }
                                else if (message.sensor == MedMotion_BUTTON) {
                                  Serial.println ("Sending Medium Motion data");
                                  mySwitch.send("010101101010010100000100");//down
                                  delay(delay_time);
                                  mySwitch.send("010101101010010100000100");//down
                                  delay(delay_time);
                                  mySwitch.send("010101101010010100010110");//up
                                  Serial.println ("Turn Medium Motion in Vera");
                                  send(msg_blue.setSensor(MedMotion_BUTTON).set(0), true);
                                }       
                                else if (message.sensor == FastMotion_BUTTON) {
                                  Serial.println ("Sending Fast Motion data");
                                  mySwitch.send("010101101010010100010110");
                                  delay(delay_time);
                                  mySwitch.send("010101101010010100010110");
                                  delay(delay_time);
                                  mySwitch.send("010101101010010100010110");
                                  Serial.println ("Turn Fast Motion in Vera");
                                  send(msg_blue.setSensor(FastMotion_BUTTON).set(0), true);
                                }      
                                  
                              }
                          
                              // Store state in eeprom
                             // saveState(message.sensor, message.getBool()); 
                             } 
                          }
                          
                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          17

                          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