Navigation

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

    DrJeff

    @DrJeff

    10
    Reputation
    92
    Posts
    1071
    Profile views
    2
    Followers
    3
    Following
    Joined Last Online
    Website http:// Location USA

    DrJeff Follow

    Best posts made by DrJeff

    • RE: RGB LED strip

      @maghac Oh yes by the way the code above works great just added some code for Motion sensor and Now I have a much better light.

      /**
       * 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.
       *
       * LED STRIP sketch for Mysensors
       *******************************
       *
       * REVISION HISTORY
       * 1.0 
       *   Based on the example sketch in mysensors
       * 1.1
       *   fadespeed parameter (send as V_VAR1 message)
       *   HomeAssistant compatible (send status to ack)
       * 1.2
       *   OTA support
       * 1.3
       *   Power-on self test
       * 1.4
       *   Bug fix
       * 1.5
       *   Other default values
       * 1.6
       *   Repeater feature
       * 1.7
       *   Multitasking. Alarm, Relax and normal modes.
       */
      
      #define MY_OTA_FIRMWARE_FEATURE
      #define MY_REPEATER_FEATURE
      #define MY_NODE_ID 31
      
      // added all the motion stuff DrJeff September 10, 2017
      #define MOTION_1 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define MOTION_ID 90   // Id of the sensor child
      uint8_t lastMotion_1 = 0;
      unsigned long previousMillis1 = 0;
      unsigned long motionDelay1 = 10000; // interval at which to keep motion sensor trippped (milliseconds).  Used to prevent too frequent updates to Vera.
      ///
      
      #define MY_RADIO_NRF24
      
      #define MY_DEBUG
      
      #include <MySensors.h>
      
      #define CHILD_ID_LIGHT 1
      
      #define SN "LED Strip"
      #define SV "1.7"
      
      MyMessage lightMsg(CHILD_ID_LIGHT, V_LIGHT);
      MyMessage rgbMsg(CHILD_ID_LIGHT, V_RGB);
      MyMessage dimmerMsg(CHILD_ID_LIGHT, V_DIMMER);
      
      // added all the motion stuff DrJeff September 10, 2017
      MyMessage motion(MOTION_ID, V_TRIPPED);
      //
      
      int current_r = 255;
      int current_g = 255;
      int current_b = 255;
      int target_r = 255;
      int target_g = 255;
      int target_b = 255;
      int save_r;
      int save_g;
      int save_b;
      
      
      float delta_r = 0.0;
      float delta_g = 0.0;
      float delta_b = 0.0;
      
      char rgbstring[] = "ffffff";
      
      int on_off_status = 0;
      int dimmerlevel = 100;
      int fadespeed = 20;
      unsigned long last_update = 0;
      int tick_length = 10;
      int fade_step = 0;
      
      int program_timer;
      int program_cycle;
      
      #define REDPIN 6
      #define GREENPIN 4
      #define BLUEPIN 5
      
      #define LIGHT_NORMAL 0
      #define LIGHT_FADING 1
      
      #define PROGRAM_NORMAL 0
      #define PROGRAM_ALARM 1
      #define PROGRAM_RELAX 2
      
      int light_mode = LIGHT_NORMAL;
      int program_mode = PROGRAM_NORMAL;
      
      #define RELAX_SPEED 50
      #define MAX_CYCLES_RELAX 7
      const int program_param_RELAX[MAX_CYCLES_RELAX][3] = {
        {255, 32, 0},
        {255, 32, 16},
        {255, 16, 32},
        {255, 128, 0},
        {255, 32, 00},
        {255, 32, 32},
        {255, 0, 32}
      };
      
      void setup()
      {
        // Fix the PWM timer. Without this the LEDs will flicker.
        TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);
      
        // Output pins
        pinMode(REDPIN, OUTPUT);
        pinMode(GREENPIN, OUTPUT);
        pinMode(BLUEPIN, OUTPUT);
        // added all the motion stuff DrJeff September 10, 2017
        pinMode(MOTION_1, INPUT);  
      //
        
      }
      
      void presentation()
      {
        // Send the Sketch Version Information to the Gateway
        sendSketchInfo(SN, SV);
        present(CHILD_ID_LIGHT, S_RGB_LIGHT);
        // added all the motion stuff DrJeff September 10, 2017
        present(MOTION_ID, S_MOTION);
      //
      
      }
      
      void selftest() {
        on_off_status = 1;
        current_r = 255;
        current_g = 0;
        current_b = 0;
        set_hw_status();
        wait(100);
        current_r = 0;
        current_g = 255;
        set_hw_status();
        wait(100);
        current_g = 0;
        current_b = 255;
        set_hw_status();
        wait(100);
        current_r = 255;
        current_g = 255;
        set_hw_status();
        wait(100);
        on_off_status = 0;
      }
      
      
      void loop()
      {
        static bool first_message_sent = false;
        if ( first_message_sent == false ) {
          selftest();
          set_hw_status();
          send_status(1, 1, 1);
          first_message_sent = true;
        }
          // added all the motion stuff DrJeff September 10, 2017//loop for motion
         unsigned long currentMillis = millis();
      
       if(currentMillis - previousMillis1 > motionDelay1)
        {
      
          uint8_t motionDetect1 = digitalRead(MOTION_1);
      
          if(motionDetect1 != lastMotion_1)
          {
            Serial.print("Motion 1 = ");
            Serial.println(motionDetect1);
            //  gw.send(motionStatus_1.set(motionDetect1 ? "1" : "0")); // Send tripped value to gw
            send(motion.set(motionDetect1));
            if(motionDetect1 == 1)
            {
              previousMillis1 = currentMillis;  //"Tripped" delay
            }
            else
            {
              previousMillis1 = currentMillis - motionDelay1 + 1000; //"Not tripped" delay for 1 second to stop rapid "not tripped" and "tripped" updates to Vera
            }
      
            lastMotion_1 = motionDetect1;
          }
        }
      
      //end of motion loop
      
        unsigned long now = millis();
        
        if (now - last_update > tick_length) {
          last_update = now;
      
          if (light_mode == LIGHT_FADING) {
            calc_fade();
          }
      
          if (program_mode > PROGRAM_NORMAL) {
            handle_program();
          }
          
        }
        set_hw_status();
        
      }
      
      void receive(const MyMessage &message)
      {
        int val;
        
        if (message.type == V_RGB) {
          Serial.print( "V_RGB: " );
          Serial.println(message.data);
          long number = (long) strtol( message.data, NULL, 16);
      
          // Save old value
          strcpy(rgbstring, message.data);
          
          // Split it up into r, g, b values
          int r = number >> 16;
          int g = number >> 8 & 0xFF;
          int b = number & 0xFF;
      
          init_fade(fadespeed, r, g, b); 
          send_status(0, 0, 1);
      
        } else if (message.type == V_LIGHT || message.type == V_STATUS) {
          Serial.print( "V_LIGHT: " );
          Serial.println(message.data);
          val = atoi(message.data);
          if (val == 0 or val == 1) {
            on_off_status = val;
            send_status(1, 0, 0);
          }
          
        } else if (message.type == V_DIMMER || message.type == V_PERCENTAGE) {
          Serial.print( "V_DIMMER: " );
          Serial.println(message.data);
          val = atoi(message.data);
          if (val >= 0 and val <=100) {
            dimmerlevel = val;
            send_status(0, 1, 0);
          }
          
        } else if (message.type == V_VAR1 ) {
          Serial.print( "V_VAR1: " );
          Serial.println(message.data);
          val = atoi(message.data);
          if (val >= 0 and val <= 2000) {
            fadespeed = val;
          }
      
        } else if (message.type == V_VAR2 ) {
          Serial.print( "V_VAR2: " );
          Serial.println(message.data);
          val = atoi(message.data);
          if (val == PROGRAM_NORMAL) {
            stop_program();
          } else if (val == PROGRAM_ALARM || val == PROGRAM_RELAX) {
            init_program(val);
          }
      
        } else {
          Serial.println( "Invalid command received..." );
          return;
        }
      
      }
      
      void set_rgb(int r, int g, int b) {
        analogWrite(REDPIN, r);
        analogWrite(GREENPIN, g);
        analogWrite(BLUEPIN, b);
      }
      
      void init_program(int program) {
        program_mode = program;
        program_cycle = 0;
        save_rgb();
        
        if (program == PROGRAM_ALARM) {
          light_mode = LIGHT_NORMAL;
          current_r = 255;
          current_g = 255;
          current_b = 255;
          program_timer = 50;
        } else if (program == PROGRAM_RELAX) {
          program_timer = 300;
          init_fade(fadespeed,
                    program_param_RELAX[program_cycle][0],
                    program_param_RELAX[program_cycle][1],
                    program_param_RELAX[program_cycle][2]);
        }
      }
      
      void handle_program() {
        program_timer--;
        if (program_mode == PROGRAM_ALARM) {
          if (program_timer == 0) {
            program_timer = 50;
            if (program_cycle == 0) {
              program_cycle = 1;
              current_r = 0;
              current_g = 0;
              current_b = 0;
            } else {
              program_cycle = 0;
              current_r = 255;
              current_g = 255;
              current_b = 255;
            }
          }
        } else if (program_mode == PROGRAM_RELAX) {
          if (light_mode == LIGHT_NORMAL) {
            program_cycle = (program_cycle+1) % MAX_CYCLES_RELAX;
            Serial.print("Next cycle step ");
            Serial.println(program_cycle);
            init_fade(fadespeed * RELAX_SPEED,
                      program_param_RELAX[program_cycle][0],
                      program_param_RELAX[program_cycle][1],
                      program_param_RELAX[program_cycle][2]);
          
          }
          
        }
      }
      
      void stop_program() {
        restore_rgb();
        light_mode = LIGHT_NORMAL;
        program_mode = PROGRAM_NORMAL;
      }
      
      void save_rgb() {
        save_r = current_r;
        save_g = current_g;
        save_b = current_b;
      }
      
      void restore_rgb() {
        current_r = save_r;
        current_g = save_g;
        current_b = save_b;
      }
      void init_fade(int t, int r, int g, int b) {
        Serial.print( "Init fade" );
        light_mode = LIGHT_FADING;
        target_r = r;
        target_g = g;
        target_b = b;
        fade_step = t;
        delta_r = (target_r - current_r) / float(fade_step);
        delta_g = (target_g - current_g) / float(fade_step);
        delta_b = (target_b - current_b) / float(fade_step);
      }
      
      void calc_fade() {
        if (fade_step > 0) {
          fade_step--;
          current_r = target_r - delta_r * fade_step;
          current_g = target_g - delta_g * fade_step;
          current_b = target_b - delta_b * fade_step;
        } else {
          Serial.println( "Normal mode" );
          light_mode = LIGHT_NORMAL;
        } 
      }
      
      void set_hw_status() {
        int r = on_off_status * (int)(current_r * dimmerlevel/100.0);
        int g = on_off_status * (int)(current_g * dimmerlevel/100.0);
        int b = on_off_status * (int)(current_b * dimmerlevel/100.0);
      
        set_rgb(r, g, b);
        
      }
      
      
      void send_status(int send_on_off_status, int send_dimmerlevel, int send_rgbstring) {
        if (send_rgbstring) send(rgbMsg.set(rgbstring));
        if (send_on_off_status) send(lightMsg.set(on_off_status));
        if (send_dimmerlevel) send(dimmerMsg.set(dimmerlevel));
      }
      posted in My Project
      DrJeff
      DrJeff
    • RE: 💬 Building a Raspberry Pi Gateway

      The line above
      ./examples_linux/mysGatewaymsyGateway -h
      needs to be corrected to
      ./examples_linux/mysGateway -h
      Thanks for all the hard work! Awesome!

      posted in Announcements
      DrJeff
      DrJeff
    • RE: 110v-230v AC to Mysensors PCB board

      @Oitzu said:

      my badly soldered dimmer.

      No way that is just like mine! 🙂 It's Perfect!

      Just Kidding I need to get my dimmers working properly also. You got the zerocross working right? 220v 110v? share sketch? will yours work locally with gateway off?

      posted in Hardware
      DrJeff
      DrJeff
    • RE: 'MySensoring' a Kidde Smoke Detector. (Completed)

      Ok all is Good! I just used the octocoupler minus the perf board,also as a side note I changed the resistor you showed to a 4.7K to keep the current of the speaker from being drowned out, I also added a power header.

      Before Mod

      and here is the Modded One!

      4baX4D9.jpg

      Thanks again @ServiceXp for all the hard work you did to get us this mod. Now 9 more to go! But I will wait and test this one out for a couple of months or maybe I should just build 5 more for now. Any Ideas on how to make this run on external power until power is lost?

      posted in My Project
      DrJeff
      DrJeff
    • RE: Irrigation Controller (up to 16 valves with Shift Registers)

      @BulldogLowell Sorry For not giving the credit where it is due! Major Props @BulldogLowell !

      posted in My Project
      DrJeff
      DrJeff
    • RE: my first weather station

      @Andy-Pep said:

      yes its going to be a learning curve ..but after finding mysensors my mind has woken up

      Got to love Sites like this one that challenge your brain and you have fun with physical items to show what you have been doing!

      posted in My Project
      DrJeff
      DrJeff
    • Pool Pressure Sensor

      Ok Time to build a sensor to measure my pool filter pressure. This is what I will be using.
      http://www.amazon.com/dp/B00RCPDPRQ

      Connect Pressure Transducer to filter with a little plumbing.

      dYJXPZx.jpg

      Now time to make the board and set the code. I need a little help with the code I have some sample code I found online here.

      
      
      
      
      
      void loop() {
      
      float sensorVoltage = analogRead(0);   // read the sensor voltage
      int psi = ((sensorVoltage-95)/204)*50; //change to *25 for 100PSI Transducer I think
      Serial.println (psi);
      
      delay (1000);
      } 
      

      I think the Transducer I have is 25 psi per 1V.

      But how to send Serial.println (psi);
      into MySensors I need the help that, type of unit? Same as the barometer?

      Thanks in advance for any help! 🙂

      posted in My Project
      DrJeff
      DrJeff
    • RE: Wateringsystem

      @Lars65

      Put your pants back on! No working Naked!!
      I laughed when I say the jeans in the picture. Have fun building!

      posted in My Project
      DrJeff
      DrJeff
    • RE: RGB LED strip

      @maghac Wow! I guess I haven't been around here for a while.

      Thanks

      posted in My Project
      DrJeff
      DrJeff

    Latest posts made by DrJeff

    • RE: Ceiling fan/light node

      @dbemowsk Any progress I want to do this as well?

      posted in My Project
      DrJeff
      DrJeff
    • RE: RGB LED strip

      @maghac Oh yes by the way the code above works great just added some code for Motion sensor and Now I have a much better light.

      /**
       * 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.
       *
       * LED STRIP sketch for Mysensors
       *******************************
       *
       * REVISION HISTORY
       * 1.0 
       *   Based on the example sketch in mysensors
       * 1.1
       *   fadespeed parameter (send as V_VAR1 message)
       *   HomeAssistant compatible (send status to ack)
       * 1.2
       *   OTA support
       * 1.3
       *   Power-on self test
       * 1.4
       *   Bug fix
       * 1.5
       *   Other default values
       * 1.6
       *   Repeater feature
       * 1.7
       *   Multitasking. Alarm, Relax and normal modes.
       */
      
      #define MY_OTA_FIRMWARE_FEATURE
      #define MY_REPEATER_FEATURE
      #define MY_NODE_ID 31
      
      // added all the motion stuff DrJeff September 10, 2017
      #define MOTION_1 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define MOTION_ID 90   // Id of the sensor child
      uint8_t lastMotion_1 = 0;
      unsigned long previousMillis1 = 0;
      unsigned long motionDelay1 = 10000; // interval at which to keep motion sensor trippped (milliseconds).  Used to prevent too frequent updates to Vera.
      ///
      
      #define MY_RADIO_NRF24
      
      #define MY_DEBUG
      
      #include <MySensors.h>
      
      #define CHILD_ID_LIGHT 1
      
      #define SN "LED Strip"
      #define SV "1.7"
      
      MyMessage lightMsg(CHILD_ID_LIGHT, V_LIGHT);
      MyMessage rgbMsg(CHILD_ID_LIGHT, V_RGB);
      MyMessage dimmerMsg(CHILD_ID_LIGHT, V_DIMMER);
      
      // added all the motion stuff DrJeff September 10, 2017
      MyMessage motion(MOTION_ID, V_TRIPPED);
      //
      
      int current_r = 255;
      int current_g = 255;
      int current_b = 255;
      int target_r = 255;
      int target_g = 255;
      int target_b = 255;
      int save_r;
      int save_g;
      int save_b;
      
      
      float delta_r = 0.0;
      float delta_g = 0.0;
      float delta_b = 0.0;
      
      char rgbstring[] = "ffffff";
      
      int on_off_status = 0;
      int dimmerlevel = 100;
      int fadespeed = 20;
      unsigned long last_update = 0;
      int tick_length = 10;
      int fade_step = 0;
      
      int program_timer;
      int program_cycle;
      
      #define REDPIN 6
      #define GREENPIN 4
      #define BLUEPIN 5
      
      #define LIGHT_NORMAL 0
      #define LIGHT_FADING 1
      
      #define PROGRAM_NORMAL 0
      #define PROGRAM_ALARM 1
      #define PROGRAM_RELAX 2
      
      int light_mode = LIGHT_NORMAL;
      int program_mode = PROGRAM_NORMAL;
      
      #define RELAX_SPEED 50
      #define MAX_CYCLES_RELAX 7
      const int program_param_RELAX[MAX_CYCLES_RELAX][3] = {
        {255, 32, 0},
        {255, 32, 16},
        {255, 16, 32},
        {255, 128, 0},
        {255, 32, 00},
        {255, 32, 32},
        {255, 0, 32}
      };
      
      void setup()
      {
        // Fix the PWM timer. Without this the LEDs will flicker.
        TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);
      
        // Output pins
        pinMode(REDPIN, OUTPUT);
        pinMode(GREENPIN, OUTPUT);
        pinMode(BLUEPIN, OUTPUT);
        // added all the motion stuff DrJeff September 10, 2017
        pinMode(MOTION_1, INPUT);  
      //
        
      }
      
      void presentation()
      {
        // Send the Sketch Version Information to the Gateway
        sendSketchInfo(SN, SV);
        present(CHILD_ID_LIGHT, S_RGB_LIGHT);
        // added all the motion stuff DrJeff September 10, 2017
        present(MOTION_ID, S_MOTION);
      //
      
      }
      
      void selftest() {
        on_off_status = 1;
        current_r = 255;
        current_g = 0;
        current_b = 0;
        set_hw_status();
        wait(100);
        current_r = 0;
        current_g = 255;
        set_hw_status();
        wait(100);
        current_g = 0;
        current_b = 255;
        set_hw_status();
        wait(100);
        current_r = 255;
        current_g = 255;
        set_hw_status();
        wait(100);
        on_off_status = 0;
      }
      
      
      void loop()
      {
        static bool first_message_sent = false;
        if ( first_message_sent == false ) {
          selftest();
          set_hw_status();
          send_status(1, 1, 1);
          first_message_sent = true;
        }
          // added all the motion stuff DrJeff September 10, 2017//loop for motion
         unsigned long currentMillis = millis();
      
       if(currentMillis - previousMillis1 > motionDelay1)
        {
      
          uint8_t motionDetect1 = digitalRead(MOTION_1);
      
          if(motionDetect1 != lastMotion_1)
          {
            Serial.print("Motion 1 = ");
            Serial.println(motionDetect1);
            //  gw.send(motionStatus_1.set(motionDetect1 ? "1" : "0")); // Send tripped value to gw
            send(motion.set(motionDetect1));
            if(motionDetect1 == 1)
            {
              previousMillis1 = currentMillis;  //"Tripped" delay
            }
            else
            {
              previousMillis1 = currentMillis - motionDelay1 + 1000; //"Not tripped" delay for 1 second to stop rapid "not tripped" and "tripped" updates to Vera
            }
      
            lastMotion_1 = motionDetect1;
          }
        }
      
      //end of motion loop
      
        unsigned long now = millis();
        
        if (now - last_update > tick_length) {
          last_update = now;
      
          if (light_mode == LIGHT_FADING) {
            calc_fade();
          }
      
          if (program_mode > PROGRAM_NORMAL) {
            handle_program();
          }
          
        }
        set_hw_status();
        
      }
      
      void receive(const MyMessage &message)
      {
        int val;
        
        if (message.type == V_RGB) {
          Serial.print( "V_RGB: " );
          Serial.println(message.data);
          long number = (long) strtol( message.data, NULL, 16);
      
          // Save old value
          strcpy(rgbstring, message.data);
          
          // Split it up into r, g, b values
          int r = number >> 16;
          int g = number >> 8 & 0xFF;
          int b = number & 0xFF;
      
          init_fade(fadespeed, r, g, b); 
          send_status(0, 0, 1);
      
        } else if (message.type == V_LIGHT || message.type == V_STATUS) {
          Serial.print( "V_LIGHT: " );
          Serial.println(message.data);
          val = atoi(message.data);
          if (val == 0 or val == 1) {
            on_off_status = val;
            send_status(1, 0, 0);
          }
          
        } else if (message.type == V_DIMMER || message.type == V_PERCENTAGE) {
          Serial.print( "V_DIMMER: " );
          Serial.println(message.data);
          val = atoi(message.data);
          if (val >= 0 and val <=100) {
            dimmerlevel = val;
            send_status(0, 1, 0);
          }
          
        } else if (message.type == V_VAR1 ) {
          Serial.print( "V_VAR1: " );
          Serial.println(message.data);
          val = atoi(message.data);
          if (val >= 0 and val <= 2000) {
            fadespeed = val;
          }
      
        } else if (message.type == V_VAR2 ) {
          Serial.print( "V_VAR2: " );
          Serial.println(message.data);
          val = atoi(message.data);
          if (val == PROGRAM_NORMAL) {
            stop_program();
          } else if (val == PROGRAM_ALARM || val == PROGRAM_RELAX) {
            init_program(val);
          }
      
        } else {
          Serial.println( "Invalid command received..." );
          return;
        }
      
      }
      
      void set_rgb(int r, int g, int b) {
        analogWrite(REDPIN, r);
        analogWrite(GREENPIN, g);
        analogWrite(BLUEPIN, b);
      }
      
      void init_program(int program) {
        program_mode = program;
        program_cycle = 0;
        save_rgb();
        
        if (program == PROGRAM_ALARM) {
          light_mode = LIGHT_NORMAL;
          current_r = 255;
          current_g = 255;
          current_b = 255;
          program_timer = 50;
        } else if (program == PROGRAM_RELAX) {
          program_timer = 300;
          init_fade(fadespeed,
                    program_param_RELAX[program_cycle][0],
                    program_param_RELAX[program_cycle][1],
                    program_param_RELAX[program_cycle][2]);
        }
      }
      
      void handle_program() {
        program_timer--;
        if (program_mode == PROGRAM_ALARM) {
          if (program_timer == 0) {
            program_timer = 50;
            if (program_cycle == 0) {
              program_cycle = 1;
              current_r = 0;
              current_g = 0;
              current_b = 0;
            } else {
              program_cycle = 0;
              current_r = 255;
              current_g = 255;
              current_b = 255;
            }
          }
        } else if (program_mode == PROGRAM_RELAX) {
          if (light_mode == LIGHT_NORMAL) {
            program_cycle = (program_cycle+1) % MAX_CYCLES_RELAX;
            Serial.print("Next cycle step ");
            Serial.println(program_cycle);
            init_fade(fadespeed * RELAX_SPEED,
                      program_param_RELAX[program_cycle][0],
                      program_param_RELAX[program_cycle][1],
                      program_param_RELAX[program_cycle][2]);
          
          }
          
        }
      }
      
      void stop_program() {
        restore_rgb();
        light_mode = LIGHT_NORMAL;
        program_mode = PROGRAM_NORMAL;
      }
      
      void save_rgb() {
        save_r = current_r;
        save_g = current_g;
        save_b = current_b;
      }
      
      void restore_rgb() {
        current_r = save_r;
        current_g = save_g;
        current_b = save_b;
      }
      void init_fade(int t, int r, int g, int b) {
        Serial.print( "Init fade" );
        light_mode = LIGHT_FADING;
        target_r = r;
        target_g = g;
        target_b = b;
        fade_step = t;
        delta_r = (target_r - current_r) / float(fade_step);
        delta_g = (target_g - current_g) / float(fade_step);
        delta_b = (target_b - current_b) / float(fade_step);
      }
      
      void calc_fade() {
        if (fade_step > 0) {
          fade_step--;
          current_r = target_r - delta_r * fade_step;
          current_g = target_g - delta_g * fade_step;
          current_b = target_b - delta_b * fade_step;
        } else {
          Serial.println( "Normal mode" );
          light_mode = LIGHT_NORMAL;
        } 
      }
      
      void set_hw_status() {
        int r = on_off_status * (int)(current_r * dimmerlevel/100.0);
        int g = on_off_status * (int)(current_g * dimmerlevel/100.0);
        int b = on_off_status * (int)(current_b * dimmerlevel/100.0);
      
        set_rgb(r, g, b);
        
      }
      
      
      void send_status(int send_on_off_status, int send_dimmerlevel, int send_rgbstring) {
        if (send_rgbstring) send(rgbMsg.set(rgbstring));
        if (send_on_off_status) send(lightMsg.set(on_off_status));
        if (send_dimmerlevel) send(dimmerMsg.set(dimmerlevel));
      }
      posted in My Project
      DrJeff
      DrJeff
    • RE: RGB LED strip

      @maghac Wow! I guess I haven't been around here for a while.

      Thanks

      posted in My Project
      DrJeff
      DrJeff
    • RE: RGB LED strip

      @maghac What board is that?

      posted in My Project
      DrJeff
      DrJeff
    • RE: How To: Make a Simple/Cheap Scene Controller (with video)

      Never mind part of the code was commented out. I wasn't sure because I just started to use OTA. But it's all good now its working fine. Here it is:

      #define MY_DEBUG
      #define MY_RADIO_NRF24
      #define MY_OTA_FIRMWARE_FEATURE
      
      #include <SPI.h>
      #include <MySensors.h>
      #include <Keypad.h>
      
      #define NODE_ID AUTO // or set to AUTO if you want gw to assign a NODE_ID for you.
      #define SN "Scene Controller"
      #define SV "2.0"
      #define KEYPAD_CHILD_ID 95
      
      MyMessage scene(KEYPAD_CHILD_ID, V_SCENE_ON); //scene ON
      MyMessage scene2(KEYPAD_CHILD_ID, V_SCENE_OFF); //scene OFF
      
      const byte ROWS = 4; //four rows
      const byte COLS = 1; //one column
      char keys[ROWS][COLS] = {
        {'1'},
        {'2'},
        {'3'},
        {'4'}
      };
      
      byte rowPins[ROWS] = {6, 7, 4, 5}; //connect to the row pinouts of the keypad
      byte colPins[COLS] = {8}; //connect to the column pinouts of the keypad
      
      Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
      byte lastState;
      
      
      void setup() {
        
        sendSketchInfo(SN, SV);
        present(KEYPAD_CHILD_ID, S_SCENE_CONTROLLER);
        keypad.addEventListener(keypadEvent);
      }
      
      void loop() {
        char key = keypad.getKey();
      }
      
      void keypadEvent(KeypadEvent key) {
        switch (keypad.getState()) {
      
          case PRESSED:
            lastState = 1;
            break;
      
          case HOLD:
            lastState = 2;
            break;
      
          case RELEASED:
            int keyInt = key - '0'; //Quick way to convert Char to Int so it can be sent to controller
            if (lastState == 2) {
              keyInt = keyInt + 4; //If button is held, add 4.  If using more than 4 buttons this number will need to be changed
              send(scene2.set(keyInt));
            } else {
            send(scene.set(keyInt));
            }
            break;
       }
      }
      
      posted in My Project
      DrJeff
      DrJeff
    • RE: How To: Make a Simple/Cheap Scene Controller (with video)

      @rechin304

      Not getting the Hold on buttons working, everything else works. Any ideas why the long press doesn't work?

      posted in My Project
      DrJeff
      DrJeff
    • RE: How To: Make a Simple/Cheap Scene Controller (with video)

      @hek
      Yes I read but was soooo lazy! I just wanted it already done 😬

      I just update one of my old sensors it was a simple single relay. My others are way more complicated! I will give this a try.

      posted in My Project
      DrJeff
      DrJeff
    • RE: How To: Make a Simple/Cheap Scene Controller (with video)

      @petewill Have you updated this code to 2.0 yet? What is different?

      posted in My Project
      DrJeff
      DrJeff
    • RE: 💬 Building a Raspberry Pi Gateway

      The line above
      ./examples_linux/mysGatewaymsyGateway -h
      needs to be corrected to
      ./examples_linux/mysGateway -h
      Thanks for all the hard work! Awesome!

      posted in Announcements
      DrJeff
      DrJeff
    • RE: Wateringsystem

      @Lars65
      Good times! 😆
      Yes I meant "saw" thanks for the good laugh. Did you finish yet?

      posted in My Project
      DrJeff
      DrJeff