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. Troubleshooting
  3. only wake on interupt..

only wake on interupt..

Scheduled Pinned Locked Moved Troubleshooting
17 Posts 4 Posters 645 Views 2 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.
  • markjgabbM Offline
    markjgabbM Offline
    markjgabb
    wrote on last edited by
    #8

    Perfect. Tha is for that works great... Interesting thought though with how sensitive it is...

    I was actually just waving my hand near it. Possibly 2-3 inches away from the wires....

    Could be used as something like a plate you slap with your hand

    mfalkviddM 1 Reply Last reply
    0
    • markjgabbM markjgabb

      Perfect. Tha is for that works great... Interesting thought though with how sensitive it is...

      I was actually just waving my hand near it. Possibly 2-3 inches away from the wires....

      Could be used as something like a plate you slap with your hand

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #9

      @markjgabb yes, that's exactly how touch-based buttons work (and your phone's touchscreen)

      1 Reply Last reply
      0
      • markjgabbM Offline
        markjgabbM Offline
        markjgabb
        wrote on last edited by markjgabb
        #10

        ok stuck now...

        it works once...
        it wakes up each time and send the command
        but in domoticz im using a push on button with a off delay.....
        domoticz is ignoring the sensor after the first on, because the sensor isnt available anymore to receive the command....

        do i possibly need the sensor to send an on command, wait a moment then send its own off command again?

        zboblamontZ 1 Reply Last reply
        0
        • markjgabbM markjgabb

          ok stuck now...

          it works once...
          it wakes up each time and send the command
          but in domoticz im using a push on button with a off delay.....
          domoticz is ignoring the sensor after the first on, because the sensor isnt available anymore to receive the command....

          do i possibly need the sensor to send an on command, wait a moment then send its own off command again?

          zboblamontZ Offline
          zboblamontZ Offline
          zboblamont
          wrote on last edited by
          #11

          @markjgabb Domoticz should display a binary On/Off according to what it is sent, so suggest looking at the Domoticz log for incoming messages, I suspect the OFF is not being sent. Why you are using a Domoticz switch with an off delay I don't understand, a simple on/off is what I use.
          In your modified @skywatch sketch the loop contains battery measurement batM() which itself incorporates a half second delay and Serial.print, suggest rem that out in the loop for now leaving the main loop to work with perhaps a 5 or 10ms delay if the switch is not debounced electrically.

          A momentary rather than latching switch allows a very fast change of state in the region of milliseconds, quite different to a real world device running seconds/minutes/hours in one state or the other.
          In your case you are looking at the interrupt as CHANGE, then reporting the digital state of the pin, any old toggle or light switch would do.

          1 Reply Last reply
          0
          • markjgabbM Offline
            markjgabbM Offline
            markjgabb
            wrote on last edited by markjgabb
            #12

            yeah i possibly havent been ecactly clear on that

            Scenario is that when i walk into a room i dont always want to ask google to turn on or off all the lights in the room.
            so i plan on having wall mounted momentary switches, which their sole purpose is to if the lights are on, turn them off and if they are off turn them on....

            so i had planned to use a momentary switch so that no one in the house became focused on if they were off or on, but just push them to get the opposite of current state

            In domoticz i was going to use a push on button with a dzvents script so that any time the push on on button became on it would toggle the opposite of whatever the state of lights in the room in...

            obviously a bit more logic is needed in case some lights are on and others off....

            As per advice i have shortened off the times for delays and have taken out the serial prints on the battery monitor

            
            // Enable debug prints
            #define MY_DEBUG
            
            // Enable and select radio type attached
            #define MY_RADIO_RF24
            
            
            #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
            #define CHILD_ID 1   // Id of the sensor child
            
            #include <MySensors.h>
            
            unsigned long SLEEP_TIME = 298000; // Sleep time between reports (in milliseconds)
            //=========================
            // BATTERY VOLTAGE DIVIDER SETUP
            // 1M, 470K divider across battery and using internal ADC ref of 1.1V
            // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
            // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
            // 3.44/1023 = Volts per bit = 0.003363075
            #define VBAT_PER_BITS 0.003363075  
            #define VMIN 1.9                                  //  Vmin (radio Min Volt)=1.9V (564v)
            #define VMAX 3.0                                  //  Vmax = (2xAA bat)=3.0V (892v)
            int batteryPcnt = 0;                              // Calc value for battery %
            int batLoop = 0;                                  // Loop to help calc average
            int batArray[3];                                  // Array to store value for average calc.
            int BATTERY_SENSE_PIN = A0;                       // select the input pin for the battery sense point
            //=========================
            
            // Initialize motion message
            MyMessage msg(CHILD_ID, V_LIGHT);
            
            void setup()
            {
                pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
              analogReference(INTERNAL);
            }
            
            void presentation()
            {
              sendSketchInfo("Lounge multi button", "1.1");
              wait(100);
              present(CHILD_ID, S_LIGHT, "Lounge Light Switch", true);
            }
            
            void loop()
            {
              // Read digital motion value
               bool tripped = digitalRead(DIGITAL_INPUT_SENSOR);
               //Software debounce.....
               //wait(25);
               //bool tripped1 = digitalRead(DIGITAL_INPUT_SENSOR);
               //if (tripped == tripped1){}
               //send(msg.set(tripped?"1":"0"),true);  // Send tripped value to gw
               
               if (tripped == HIGH){
               send(msg.set(tripped = 1),true);
               wait(100);
               send(msg.set(tripped = 0),true);
               }
              batM();
              // Sleep until interrupt on motion sensor. Send update every ten minutes.
              sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
            }
            
            void batM() //The battery calculations
            {
               delay(5);
               // Battery monitoring reading
               int sensorValue = analogRead(BATTERY_SENSE_PIN);    
               delay(5);
               
               // Calculate the battery in %
               float Vbat  = sensorValue * VBAT_PER_BITS;
               int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);
               //Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");  
               
               // Add it to array so we get an average of 3 (3x20min)
               batArray[batLoop] = batteryPcnt;
              
               if (batLoop > 2) {  
                 batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]);
                 batteryPcnt = batteryPcnt / 3;
             
               if (batteryPcnt > 100) {
                 batteryPcnt=100;
             }
             
                 Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %");
                   sendBatteryLevel(batteryPcnt);
                   batLoop = 0;
                  }
                 else 
                 {
                 batLoop++;
                 }
            }
            
            mfalkviddM zboblamontZ 2 Replies Last reply
            0
            • markjgabbM markjgabb

              yeah i possibly havent been ecactly clear on that

              Scenario is that when i walk into a room i dont always want to ask google to turn on or off all the lights in the room.
              so i plan on having wall mounted momentary switches, which their sole purpose is to if the lights are on, turn them off and if they are off turn them on....

              so i had planned to use a momentary switch so that no one in the house became focused on if they were off or on, but just push them to get the opposite of current state

              In domoticz i was going to use a push on button with a dzvents script so that any time the push on on button became on it would toggle the opposite of whatever the state of lights in the room in...

              obviously a bit more logic is needed in case some lights are on and others off....

              As per advice i have shortened off the times for delays and have taken out the serial prints on the battery monitor

              
              // Enable debug prints
              #define MY_DEBUG
              
              // Enable and select radio type attached
              #define MY_RADIO_RF24
              
              
              #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
              #define CHILD_ID 1   // Id of the sensor child
              
              #include <MySensors.h>
              
              unsigned long SLEEP_TIME = 298000; // Sleep time between reports (in milliseconds)
              //=========================
              // BATTERY VOLTAGE DIVIDER SETUP
              // 1M, 470K divider across battery and using internal ADC ref of 1.1V
              // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
              // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
              // 3.44/1023 = Volts per bit = 0.003363075
              #define VBAT_PER_BITS 0.003363075  
              #define VMIN 1.9                                  //  Vmin (radio Min Volt)=1.9V (564v)
              #define VMAX 3.0                                  //  Vmax = (2xAA bat)=3.0V (892v)
              int batteryPcnt = 0;                              // Calc value for battery %
              int batLoop = 0;                                  // Loop to help calc average
              int batArray[3];                                  // Array to store value for average calc.
              int BATTERY_SENSE_PIN = A0;                       // select the input pin for the battery sense point
              //=========================
              
              // Initialize motion message
              MyMessage msg(CHILD_ID, V_LIGHT);
              
              void setup()
              {
                  pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
                analogReference(INTERNAL);
              }
              
              void presentation()
              {
                sendSketchInfo("Lounge multi button", "1.1");
                wait(100);
                present(CHILD_ID, S_LIGHT, "Lounge Light Switch", true);
              }
              
              void loop()
              {
                // Read digital motion value
                 bool tripped = digitalRead(DIGITAL_INPUT_SENSOR);
                 //Software debounce.....
                 //wait(25);
                 //bool tripped1 = digitalRead(DIGITAL_INPUT_SENSOR);
                 //if (tripped == tripped1){}
                 //send(msg.set(tripped?"1":"0"),true);  // Send tripped value to gw
                 
                 if (tripped == HIGH){
                 send(msg.set(tripped = 1),true);
                 wait(100);
                 send(msg.set(tripped = 0),true);
                 }
                batM();
                // Sleep until interrupt on motion sensor. Send update every ten minutes.
                sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
              }
              
              void batM() //The battery calculations
              {
                 delay(5);
                 // Battery monitoring reading
                 int sensorValue = analogRead(BATTERY_SENSE_PIN);    
                 delay(5);
                 
                 // Calculate the battery in %
                 float Vbat  = sensorValue * VBAT_PER_BITS;
                 int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);
                 //Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");  
                 
                 // Add it to array so we get an average of 3 (3x20min)
                 batArray[batLoop] = batteryPcnt;
                
                 if (batLoop > 2) {  
                   batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]);
                   batteryPcnt = batteryPcnt / 3;
               
                 if (batteryPcnt > 100) {
                   batteryPcnt=100;
               }
               
                   Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %");
                     sendBatteryLevel(batteryPcnt);
                     batLoop = 0;
                    }
                   else 
                   {
                   batLoop++;
                   }
              }
              
              mfalkviddM Offline
              mfalkviddM Offline
              mfalkvidd
              Mod
              wrote on last edited by
              #13

              @markjgabb when the node is sleeping, it cannot receive messages from Domoticz.

              1 Reply Last reply
              0
              • markjgabbM markjgabb

                yeah i possibly havent been ecactly clear on that

                Scenario is that when i walk into a room i dont always want to ask google to turn on or off all the lights in the room.
                so i plan on having wall mounted momentary switches, which their sole purpose is to if the lights are on, turn them off and if they are off turn them on....

                so i had planned to use a momentary switch so that no one in the house became focused on if they were off or on, but just push them to get the opposite of current state

                In domoticz i was going to use a push on button with a dzvents script so that any time the push on on button became on it would toggle the opposite of whatever the state of lights in the room in...

                obviously a bit more logic is needed in case some lights are on and others off....

                As per advice i have shortened off the times for delays and have taken out the serial prints on the battery monitor

                
                // Enable debug prints
                #define MY_DEBUG
                
                // Enable and select radio type attached
                #define MY_RADIO_RF24
                
                
                #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
                #define CHILD_ID 1   // Id of the sensor child
                
                #include <MySensors.h>
                
                unsigned long SLEEP_TIME = 298000; // Sleep time between reports (in milliseconds)
                //=========================
                // BATTERY VOLTAGE DIVIDER SETUP
                // 1M, 470K divider across battery and using internal ADC ref of 1.1V
                // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
                // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
                // 3.44/1023 = Volts per bit = 0.003363075
                #define VBAT_PER_BITS 0.003363075  
                #define VMIN 1.9                                  //  Vmin (radio Min Volt)=1.9V (564v)
                #define VMAX 3.0                                  //  Vmax = (2xAA bat)=3.0V (892v)
                int batteryPcnt = 0;                              // Calc value for battery %
                int batLoop = 0;                                  // Loop to help calc average
                int batArray[3];                                  // Array to store value for average calc.
                int BATTERY_SENSE_PIN = A0;                       // select the input pin for the battery sense point
                //=========================
                
                // Initialize motion message
                MyMessage msg(CHILD_ID, V_LIGHT);
                
                void setup()
                {
                    pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
                  analogReference(INTERNAL);
                }
                
                void presentation()
                {
                  sendSketchInfo("Lounge multi button", "1.1");
                  wait(100);
                  present(CHILD_ID, S_LIGHT, "Lounge Light Switch", true);
                }
                
                void loop()
                {
                  // Read digital motion value
                   bool tripped = digitalRead(DIGITAL_INPUT_SENSOR);
                   //Software debounce.....
                   //wait(25);
                   //bool tripped1 = digitalRead(DIGITAL_INPUT_SENSOR);
                   //if (tripped == tripped1){}
                   //send(msg.set(tripped?"1":"0"),true);  // Send tripped value to gw
                   
                   if (tripped == HIGH){
                   send(msg.set(tripped = 1),true);
                   wait(100);
                   send(msg.set(tripped = 0),true);
                   }
                  batM();
                  // Sleep until interrupt on motion sensor. Send update every ten minutes.
                  sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
                }
                
                void batM() //The battery calculations
                {
                   delay(5);
                   // Battery monitoring reading
                   int sensorValue = analogRead(BATTERY_SENSE_PIN);    
                   delay(5);
                   
                   // Calculate the battery in %
                   float Vbat  = sensorValue * VBAT_PER_BITS;
                   int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);
                   //Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");  
                   
                   // Add it to array so we get an average of 3 (3x20min)
                   batArray[batLoop] = batteryPcnt;
                  
                   if (batLoop > 2) {  
                     batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]);
                     batteryPcnt = batteryPcnt / 3;
                 
                   if (batteryPcnt > 100) {
                     batteryPcnt=100;
                 }
                 
                     Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %");
                       sendBatteryLevel(batteryPcnt);
                       batLoop = 0;
                      }
                     else 
                     {
                     batLoop++;
                     }
                }
                
                zboblamontZ Offline
                zboblamontZ Offline
                zboblamont
                wrote on last edited by
                #14

                @markjgabb Wasn't thinking about shortening the battery read but // it out in the loop meantime as it is only a local serial output. Whatever..

                Ok on the intent, then what you are doing is "illogical", you are reporting the state of the switch not the condition of the light.
                What you need to do is toggle a separate logic parameter on the Node for a LOW interrupt at the Node, switching ON/OFF the light, report that separate logic state to Domoticz then go to sleep... The interrupt only initiates the action, the Node reports and stores the current state until the next interrupt, Domoticz tells you the last reported state.
                Whether you control the light at at the button switch Node with a latching relay or command a separate Node is up to you, but Domoticz only reports the last known state...

                1 Reply Last reply
                1
                • markjgabbM Offline
                  markjgabbM Offline
                  markjgabb
                  wrote on last edited by
                  #15

                  @zboblamont
                  haha ok so i went right back to the begining of what you said and got it working now (code below)

                  cut back all unneccicary steps and really locked down what was going on... i can always add back battery part later

                  however now when it comes back online after 5 minutes for heart beat it keep sending a switch command to domoticz...

                  im guessing this is due to the issue where the state is being reported differently after it going to sleep as soon as action is performed....

                  // Enable debug prints
                  #define MY_DEBUG
                  
                  // Enable and select radio type attached
                  #define MY_RADIO_RF24
                  
                  #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
                  #define CHILD_ID 1   // Id of the sensor child
                  
                  
                  #include <MySensors.h>
                  
                  unsigned long SLEEP_TIME = 298000; // Sleep time between reports (in milliseconds)
                  
                  
                  // Initialize motion message
                  MyMessage msg(CHILD_ID, V_TRIPPED);
                  
                  void setup()
                  {
                      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
                  }
                  
                  void presentation()
                  {
                    sendSketchInfo("Lounge Multi", "3.0");
                    wait(100);
                    present(CHILD_ID, S_DOOR);
                  }
                  
                  void loop()
                  {
                    // Read digital motion value
                     bool tripped = digitalRead(DIGITAL_INPUT_SENSOR);
                     //Software debounce.....
                     //wait(25);
                     //bool tripped1 = digitalRead(DIGITAL_INPUT_SENSOR);
                     //if (tripped == tripped1){}
                     //send(msg.set(tripped?"1":"0"),true);  // Send tripped value to gw
                     
                     if (tripped == HIGH){
                     send(msg.set(tripped = 1),true);
                     }
                     else if (tripped == LOW){
                     send(msg.set(tripped = 0),true);
                     }
                    
                    // Sleep until interrupt on motion sensor. Send update every ten minutes.
                    sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
                  }
                  
                  
                  skywatchS zboblamontZ 2 Replies Last reply
                  0
                  • markjgabbM markjgabb

                    @zboblamont
                    haha ok so i went right back to the begining of what you said and got it working now (code below)

                    cut back all unneccicary steps and really locked down what was going on... i can always add back battery part later

                    however now when it comes back online after 5 minutes for heart beat it keep sending a switch command to domoticz...

                    im guessing this is due to the issue where the state is being reported differently after it going to sleep as soon as action is performed....

                    // Enable debug prints
                    #define MY_DEBUG
                    
                    // Enable and select radio type attached
                    #define MY_RADIO_RF24
                    
                    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
                    #define CHILD_ID 1   // Id of the sensor child
                    
                    
                    #include <MySensors.h>
                    
                    unsigned long SLEEP_TIME = 298000; // Sleep time between reports (in milliseconds)
                    
                    
                    // Initialize motion message
                    MyMessage msg(CHILD_ID, V_TRIPPED);
                    
                    void setup()
                    {
                        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
                    }
                    
                    void presentation()
                    {
                      sendSketchInfo("Lounge Multi", "3.0");
                      wait(100);
                      present(CHILD_ID, S_DOOR);
                    }
                    
                    void loop()
                    {
                      // Read digital motion value
                       bool tripped = digitalRead(DIGITAL_INPUT_SENSOR);
                       //Software debounce.....
                       //wait(25);
                       //bool tripped1 = digitalRead(DIGITAL_INPUT_SENSOR);
                       //if (tripped == tripped1){}
                       //send(msg.set(tripped?"1":"0"),true);  // Send tripped value to gw
                       
                       if (tripped == HIGH){
                       send(msg.set(tripped = 1),true);
                       }
                       else if (tripped == LOW){
                       send(msg.set(tripped = 0),true);
                       }
                      
                      // Sleep until interrupt on motion sensor. Send update every ten minutes.
                      sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
                    }
                    
                    
                    skywatchS Offline
                    skywatchS Offline
                    skywatch
                    wrote on last edited by skywatch
                    #16

                    @markjgabb I used the trigger data for a 'heartbeat' so that it looked 'normal' on a graph and the graph updated regularly (otherwise it only updated on a change and that can be a long time indeed for some windows)!

                    The solution might be to immplement the MySensors Heartbeat instead.

                    Just put " sendHeartbeat(); " without the quotes in the sketch main loop. You may still get messages about status, I am not sure as I use MyController for my set-up and never used domoticz
                    .
                    If so you can try and set a memory for the status and only send the tripped message if the status of the last_tripped_status (or whatever you want to call it) has changed.

                    I believe that the relay sketches in 'build' page use a similar approach from memory.

                    Here is a strong hint of how to do it..... :)

                     if (tripped == HIGH && last_tripped == LOW){
                       send(msg.set(tripped = 1),true);
                    last_tripped = HIGH;
                       }
                       else if (tripped == LOW) && last_tripped==HIGH{
                       send(msg.set(tripped = 0),true);
                    last_tripped = LOW;
                       }
                    

                    You need to assign a type bool to last_tripped somewhere and initialise it.

                    1 Reply Last reply
                    0
                    • markjgabbM markjgabb

                      @zboblamont
                      haha ok so i went right back to the begining of what you said and got it working now (code below)

                      cut back all unneccicary steps and really locked down what was going on... i can always add back battery part later

                      however now when it comes back online after 5 minutes for heart beat it keep sending a switch command to domoticz...

                      im guessing this is due to the issue where the state is being reported differently after it going to sleep as soon as action is performed....

                      // Enable debug prints
                      #define MY_DEBUG
                      
                      // Enable and select radio type attached
                      #define MY_RADIO_RF24
                      
                      #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
                      #define CHILD_ID 1   // Id of the sensor child
                      
                      
                      #include <MySensors.h>
                      
                      unsigned long SLEEP_TIME = 298000; // Sleep time between reports (in milliseconds)
                      
                      
                      // Initialize motion message
                      MyMessage msg(CHILD_ID, V_TRIPPED);
                      
                      void setup()
                      {
                          pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
                      }
                      
                      void presentation()
                      {
                        sendSketchInfo("Lounge Multi", "3.0");
                        wait(100);
                        present(CHILD_ID, S_DOOR);
                      }
                      
                      void loop()
                      {
                        // Read digital motion value
                         bool tripped = digitalRead(DIGITAL_INPUT_SENSOR);
                         //Software debounce.....
                         //wait(25);
                         //bool tripped1 = digitalRead(DIGITAL_INPUT_SENSOR);
                         //if (tripped == tripped1){}
                         //send(msg.set(tripped?"1":"0"),true);  // Send tripped value to gw
                         
                         if (tripped == HIGH){
                         send(msg.set(tripped = 1),true);
                         }
                         else if (tripped == LOW){
                         send(msg.set(tripped = 0),true);
                         }
                        
                        // Sleep until interrupt on motion sensor. Send update every ten minutes.
                        sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
                      }
                      
                      
                      zboblamontZ Offline
                      zboblamontZ Offline
                      zboblamont
                      wrote on last edited by zboblamont
                      #17

                      @markjgabb "..cut back all unneccicary steps and really locked down what was going on.." was indeed the idea.

                      What I went on to explain is than you are reporting the state of D3 which goes HIGH/LOW/HIGH via the button, not the light. The critical difference between @skywatch and your install is movement detection maintains a value, your button does not.

                      If you create a variable before the loop, say boolean lightswitch=false; (presuming that the light is ON when you program it) this variable will be changed and reported to Domoticz in the loop.
                      Top of the loop you toggle the "lightswitch" value, first time it will switch false to true, report in the "lightswitch" value then go to sleep.
                      Bottom of the loop your " sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); should trigger on a LOW, as this is the momentary state of D3 ONLY when the button is pressed.
                      Your next button press activates the loop, toggles "lightswitch", reports and goes back to sleep, at least two years on a pair of AA cells.

                      Were it I doing this there would be a mains powered indicator on the switch plate which cuts out when the light is on, A- To find the switch in the dark, B-To provide an indicator which can be used to verify the actual state of the light to ensure it stays in sync (Murphy's Law).
                      I don't see the point of using heartbeat as it is not a security device, and only fire the battery reading mosfet every X loops.

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


                      12

                      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