Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. tbully
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    tbully

    @tbully

    5
    Reputation
    74
    Posts
    1128
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online
    Email tbully@gmail.com

    tbully Follow

    Best posts made by tbully

    • RE: Relay actuator + water meter pulse sensor sketch

      Here's my code in case you're interested:

      //
      // Use this sensor to measure volume and flow of your house watermeter.
      // You need to set the correct pulsefactor of your meter (pulses per m3).
      // The sensor starts by fetching current volume reading from gateway (VAR 1).
      // Reports both volume and flow back to gateway.
      //
      // Unfortunately millis() won't increment when the Arduino is in 
      // sleepmode. So we cannot make this sensor sleep if we also want  
      // to calculate/report flow.
      //
      // Sensor on pin 3
      
      #include <MySensor.h>
      #include <SPI.h>
      
      
      #define DIGITAL_INPUT_SENSOR 3                  // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
      //#define PULSE_FACTOR 12500                       // Nummber of blinks per m3 of your meter (One rotation/liter)
      #define PULSE_FACTOR 288000
      #define SLEEP_MODE false                        // flowvalue can only be reported when sleep mode is false.
      #define MAX_FLOW 25                             // Max flow (l/min) value to report. This filetrs outliers.
      #define INTERRUPT DIGITAL_INPUT_SENSOR-2        // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 0                              // Id of the sensor child
      #define RELAY_1  4  // Arduino Digital I/O pin number for first relay
      #define NUMBER_OF_RELAYS 1 
      #define RELAY_ON 1
      #define RELAY_OFF 0
      unsigned long SEND_FREQUENCY = 10000;              // Minimum time between send (in miliseconds). We don't want to spam the gateway.
      
      MySensor gw;
      
      double ppl = ((double)PULSE_FACTOR)/1000;        // Pulses per liter
      
      volatile unsigned long pulseCount = 0;   
      volatile unsigned long lastBlink = 0;
      volatile double flow = 0;
      boolean pcReceived = false;
      unsigned long oldPulseCount = 0;
      unsigned long newBlink = 0;   
      double oldflow = 0;
      double volume;                     
      double oldvolume;
      unsigned long lastSend;
      unsigned long lastPulse;
      unsigned long currentTime;
      boolean metric;
      
      MyMessage flowMsg(CHILD_ID,V_FLOW);
      MyMessage volumeMsg(CHILD_ID,V_VOLUME);
      MyMessage pcMsg(CHILD_ID,V_VAR1);
      
      void setup()  
      {  
        //gw.begin(incomingMessage, AUTO, true);
        //gw.begin(incomingMessage, AUTO, false, AUTO, RF24_PA_LOW);
        gw.begin(incomingMessage, AUTO, false, AUTO);
        //  gw.send(pcMsg.set(0));
        //  gw.send(volumeMsg.set(0.000, 3));
        //Water meter setup
        //Serial.print("PPL:");
        //Serial.print(ppl);
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Water Meter and Valve", "1.0");
      
        // Register this device as Waterflow sensor
        gw.present(CHILD_ID, S_WATER);      
      
        // Fetch last known pulse count value from gw
        gw.request(CHILD_ID, V_VAR1);
        //pulseCount = oldPulseCount = 0;
      
        //Serial.print("Last pulse count from gw:");
        //Serial.println(pulseCount);
      
        attachInterrupt(INTERRUPT, onPulse, RISING);
        lastSend = millis();
      
        //RELAY SETUP
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          gw.present(sensor, S_LIGHT);
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      
      }
      
      
      void loop()     
      { 
        gw.process();
        currentTime = millis();
        bool sendTime = currentTime - lastSend > SEND_FREQUENCY;
        if (pcReceived && (SLEEP_MODE || sendTime)) {
          // New flow value has been calculated  
          if (!SLEEP_MODE && flow != oldflow) {
            // Check that we dont get unresonable large flow value. 
            // could hapen when long wraps or false interrupt triggered
            if (flow<((unsigned long)MAX_FLOW)) {
              gw.send(flowMsg.set(flow, 2));        // Send flow value to gw
            }
      
            //Serial.print("g/min:");
            // Serial.println(flow);
            oldflow = flow;
          }
      
          // No Pulse count in 2min 
          if(currentTime - lastPulse > 20000){
            flow = 0;
          } 
      
      
          // Pulse count has changed
          if (pulseCount != oldPulseCount) {
            gw.send(pcMsg.set(pulseCount));                  // Send  volumevalue to gw VAR1
            double volume = ((double)pulseCount/((double)PULSE_FACTOR)*264.172);
            //double volume = ((double)pulseCount/((double)PULSE_FACTOR));     
            oldPulseCount = pulseCount;
            if (volume != oldvolume) {
              gw.send(volumeMsg.set(volume, 3));               // Send volume value to gw
              oldvolume = volume;
            } 
          }
          lastSend = currentTime;
        } 
        else if (sendTime) {
          // No count received. Try requesting it again
          gw.request(CHILD_ID, V_VAR1);
          lastSend=currentTime;
        }
      
        if (SLEEP_MODE) {
          gw.sleep(SEND_FREQUENCY);
        } 	
      
      
      }
      
      
      void onPulse()     
      { 
        if (!SLEEP_MODE) {
          unsigned long newBlink = micros();   
          unsigned long interval = newBlink-lastBlink;
          lastPulse = millis();
          if (interval < 2080) {       // Sometimes we get interrupt on RISING,  500000 = 0.5sek debounce ( max 120 l/min)  WAS 2080
            return;   
          }
      
          flow = ((60000000.0 /interval) / ppl)*.264172;
          //flow = ((60000000.0 /interval) / ppl);
          // Serial.print("interval:");
          // Serial.println(interval);
          lastBlink = newBlink;
          // Serial.println(flow, 4);
        }
        pulseCount++;
      
      }
      
      void incomingMessage(const MyMessage &message) {
        if (message.type==V_VAR1) {  
          pulseCount = oldPulseCount = message.getLong();
          Serial.print("Received last pulse count from gw:");
          Serial.println(pulseCount);
          pcReceived = true;
        }
        if (message.type==V_LIGHT) {
          // Change relay state
          digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
          // Store state in eeprom
          gw.saveState(message.sensor, message.getBool());
          // Write some debug info
          Serial.print("Incoming change for sensor:");
          Serial.print(message.sensor);
          Serial.print(", New status: ");
          Serial.println(message.getBool());
        } 
      
      }
      
      posted in Development
      tbully
      tbully
    • RE: Iboard - Cheap Single board Ethernet Arduino with Radio

      To close the loop on this (and to help future dwellers), a new board solved the issue. Not sure what wasn't working properly on the old board but I'm up and running again (with the same old radio, supply, etc).

      Also, since I've learned a little and now understand a few of the configs better since my original iBoard build, I was able to do this WITHOUT the hardware mod.

      I set the following in MyConfig.H:

      const uint8_t SOFT_SPI_MISO_PIN = 6; 
      const uint8_t SOFT_SPI_MOSI_PIN = 5; 
      const uint8_t SOFT_SPI_SCK_PIN = 7;
      

      My failure from several months ago was not setting the CE and SS pins properly in my sketch. I also took @Dwalt 's advice and updated my inclusion and LED pins (even though I didn't use them):

      #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
      #define INCLUSION_MODE_PIN  14 // Digital pin used for inclusion mode button A0
      
      #define RADIO_CE_PIN        3  // radio chip enable
      #define RADIO_SPI_SS_PIN    8  // radio SPI serial select
      
      #define RADIO_ERROR_LED_PIN 15  // Error led pin A1
      #define RADIO_RX_LED_PIN    16  // Receive led pin A2
      #define RADIO_TX_LED_PIN    17  // the PCB, on board LED A3
      posted in Hardware
      tbully
      tbully
    • RE: Laser Christmas Light Control - 433MHZ

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

      posted in General Discussion
      tbully
      tbully
    • RE: [Tutorial] Raspberry Pi NRF24l01 direct connection

      @mfalkvidd said in Step-by-step procedure to connect the NRF24L01 to the GPIO pins and use the Raspberry as a Serial Gateway.:

      @Eawo Yes, it should work. I ran Domoticz and MySensors Gateway on my Raspberry Pi 1 when I first tried MySensors. If I remember correctly I had to connect CE to pin 15 instead of 22 but I am not sure why. Try using the same connections as on your Raspberry Pi 2 first, and switch CE pin if you get "check wires". Please report back here how it goes, so I can add the necessary information to the original post.

      For what it's worth, this is correct. I'm currently running on a Pi 1 and put CE on 15.

      I followed these instructions and it worked perfectly with no fuss: http://forum.mysensors.org/topic/1151/tutorial-raspberry-pi-nrf24l01-direct-connection

      posted in Controllers
      tbully
      tbully
    • RE: How to scan rf remote

      Echoing what @emc2 said. RCSwitch worked great for my 433 project a few months ago.

      https://forum.mysensors.org/topic/4962/laser-christmas-light-control-433mhz/14

      posted in Development
      tbully
      tbully

    Latest posts made by tbully

    • RE: How to scan rf remote

      Echoing what @emc2 said. RCSwitch worked great for my 433 project a few months ago.

      https://forum.mysensors.org/topic/4962/laser-christmas-light-control-433mhz/14

      posted in Development
      tbully
      tbully
    • RE: Missing Icons after UI5 -> UI7 Upgrade

      Yep. I think it's the default icon that's used when the JSON points to the wrong image, or the image is not available.

      Are you using UI7? Can you send me a screenshot of Temperature node? Maybe the XML/JSON behind it? I'd like to compare it to what I'm running.

      posted in Vera
      tbully
      tbully
    • RE: Missing Icons after UI5 -> UI7 Upgrade

      Hey Hek!

      Thanks for responding on a rather mundane issue. Browser connectivity is OK. In fact, your smiling guy (also your avatar here) loads OK on the "main" plugin. Also, the "integrated circuit" icon loads on each of the node definitions.

      However, the devices themselves (relays, meters, etc) don't appear to be loading. 😞

      posted in Vera
      tbully
      tbully
    • Missing Icons after UI5 -> UI7 Upgrade

      Hello All -

      I did download the newest Vera files and uploaded them. However, I'm missing icons on some of my devices. Can someone give me some ideas?!

      0_1482440375506_MySensors_Missing_Icon1.JPG

      0_1482440385504_MySensors_Missing_Icon2.JPG

      posted in Vera
      tbully
      tbully
    • RE: Laser Christmas Light Control - 433MHZ

      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()); 
         } 
      }
      
      posted in General Discussion
      tbully
      tbully
    • RE: Laser Christmas Light Control - 433MHZ

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

      posted in General Discussion
      tbully
      tbully
    • RE: Laser Christmas Light Control - 433MHZ

      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()); 
         } 
      }
      
      posted in General Discussion
      tbully
      tbully
    • RE: Laser Christmas Light Control - 433MHZ

      @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
        }
      posted in General Discussion
      tbully
      tbully
    • RE: Laser Christmas Light Control - 433MHZ

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

      posted in General Discussion
      tbully
      tbully
    • RE: Laser Christmas Light Control - 433MHZ

      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()); 
         } 
      }
      
      posted in General Discussion
      tbully
      tbully