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. Development
  3. Most reliable light switch

Most reliable light switch

Scheduled Pinned Locked Moved Development
4 Posts 3 Posters 2.1k Views 3 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.
  • A Offline
    A Offline
    Alexander Ivanov
    wrote on last edited by
    #1

    I'm moving to Vera+MySensors and will do all light management under MySensors.
    Months before I raised a discussion to allow node to be operated individually, even if it's not connected to MySensor network. Unfortunately, it will not happen - once node is not connected - it will stop working.

    I definitely don't want to put my house in the dark because something went wrong. Does anybody created a reliable switch, based (maybe) on MySensor node + (say) Arduino ? Can anybody share good experience?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DavidZH
      wrote on last edited by
      #2

      I am working on such a node, but am still in the programming and testing stage. I will come back here when I have positive results!

      A 1 Reply Last reply
      1
      • D DavidZH

        I am working on such a node, but am still in the programming and testing stage. I will come back here when I have positive results!

        A Offline
        A Offline
        Alexander Ivanov
        wrote on last edited by
        #3

        @DavidZH, sounds promising. Give me something for tests, I will spend next few months on this.

        Boots33B 1 Reply Last reply
        0
        • A Alexander Ivanov

          @DavidZH, sounds promising. Give me something for tests, I will spend next few months on this.

          Boots33B Offline
          Boots33B Offline
          Boots33
          Hero Member
          wrote on last edited by
          #4

          @Alexander-Ivanov

          The information in these posts may be of use.

          mys-library-startup-control-after-onregistration

          my_transport_dont_care_mode

          In mySensors V2.1 the basic sketch for a switch that will work even if the controller/gateway is down would look something like this

          // Enable debug prints to serial monitor
          #define MY_DEBUG
          
          // Enable and select radio type attached
          #define MY_RADIO_NRF24
          
          #define MY_TRANSPORT_WAIT_READY_MS 3000     //set how long to wait for transport ready.
          
          #include <SPI.h>
          #include <MySensors.h>
          #include <Bounce2.h>
          
          #define RELAY_PIN  4  // Arduino Digital I/O pin number for relay 
          #define BUTTON_PIN  3  // Arduino Digital I/O pin number for button 
          #define CHILD_ID 1   // Id of the sensor child
          #define RELAY_ON 1
          #define RELAY_OFF 0
          
          Bounce debouncer = Bounce();
          int oldValue = 0;
          bool state;
          
          MyMessage msg(CHILD_ID, V_STATUS);
          
          void setup()
          {
            pinMode(BUTTON_PIN, INPUT);              // Setup the button pin  
            digitalWrite(BUTTON_PIN, HIGH);           // Activate internal pull-up
          
            // After setting up the button, setup debouncer
            debouncer.attach(BUTTON_PIN);
            debouncer.interval(5);
           
            pinMode(RELAY_PIN, OUTPUT);               // set relay pin in output mode  
            digitalWrite(RELAY_PIN, RELAY_OFF);      // Make sure relay is off when starting up
          }
          
          void presentation()  {
            // Send the sketch version information to the gateway and Controller
            sendSketchInfo("Relay & Button", "1.0");
          
            // Register all sensors to gw (they will be created as child devices)
            present(CHILD_ID, S_BINARY);
          }
          
          
          void loop()
          {
            debouncer.update();
            // Get the update value
            int value = debouncer.read();
            if (value != oldValue && value == 0) {                          // check for new button push
              state =  !state;                                               //Toggle the state
              send(msg.set(state), false);                                   // send new state to controller, no ack requested
              digitalWrite(RELAY_PIN, state ? RELAY_ON : RELAY_OFF);         // switch the relay to the new state
            }
           
            oldValue = value;
          }
          
          
          void receive(const MyMessage &message) {
            // We only expect one type of message from controller. But we better check anyway.
            
            if (message.type == V_STATUS) {
              
              state = message.getBool();                                  // get the current state
              digitalWrite(RELAY_PIN, state ? RELAY_ON : RELAY_OFF);      // switch relay to current state
          
              // Write some debug info
              Serial.print("Incoming change for sensor:");
              Serial.print(message.sensor);
              Serial.print(", New status: ");
              Serial.println(message.getBool());
          
            }
          }
          
          1 Reply Last reply
          1

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          43

          Online

          12.0k

          Users

          11.2k

          Topics

          113.4k

          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