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. Door Sensor / Mini Pro Clone Interrupt

Door Sensor / Mini Pro Clone Interrupt

Scheduled Pinned Locked Moved Troubleshooting
4 Posts 3 Posters 1.3k 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.
  • T Offline
    T Offline
    Takero
    Hardware Contributor
    wrote on last edited by
    #1

    Hello,

    i have some Trouble with my Door Sensor.
    The Sensor works fine, but if i use the gw.sleep function they don't wake up. I try D2 and D3. Nothing happens. . . .

    Herre is my Sketch:

    
    #include <SPI.h>
    #include <MySensor.h>
    #include <Bounce2.h>
    
    
    #define CHILD_ID 1
    #define CHILD_ID_BATT 3
    #define SENSOR_ID 30
    #define BUTTON_PIN 3
    #define INTERRUPT 1
    
    int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
    
    #define SLEEP_TIME 600000
    
    MySensor gw;
    
    Bounce debouncer = Bounce(); 
    int oldValue=-1;
     
    int batterie_check = 0;
    float normaldeltabatt = 0.400;
    float batteriezwischen = 0;
    int interrupt = 1;
    
    MyMessage msg(CHILD_ID,V_TRIPPED);
    MyMessage msgVolt(CHILD_ID_BATT, V_VOLTAGE);
    
    void setup() {
      
      // use the 1.1 V internal reference
      analogReference(INTERNAL);
      gw.begin(NULL, SENSOR_ID);
      pinMode(BUTTON_PIN,INPUT);
      gw.sendSketchInfo("WoZi_Window", "1.0");
      digitalWrite(BUTTON_PIN,HIGH);
      debouncer.attach(BUTTON_PIN);
      debouncer.interval(5);
      gw.present(CHILD_ID, S_DOOR);  
      
    }
    
    void loop() {
      
      debouncer.update();
      // Get the update value
      int value = debouncer.read();
       
      if (value != oldValue) {
         // Send in the new value
         gw.send(msg.set(value==HIGH ? 1 : 0));
         oldValue = value;
      }
    
      
    //  if (batterie_check >= 30 || batterie_check < 1) { 
    //    // get the battery Voltage
    //    int sensorValue = analogRead(BATTERY_SENSE_PIN);
    //    float batteryValue = sensorValue * 0.0033140756302521;
    //    //int batteryPcnt = sensorValue / 10;
    //    batteriezwischen = batteryValue - 2;
    //    //Serial.println(batteriezwischen);
    //    float batteryPcnt = (batteriezwischen/normaldeltabatt) * 100;
    //
    //    Serial.print("Batt: ");
    //    Serial.print(batteryValue);
    //    Serial.println(" V");
    //    gw.send(msgVolt.set(batteryValue, 1));
    //    Serial.print("Battery Prozent: ");
    //    Serial.print(batteryPcnt);
    //    Serial.println(" %");
    //    gw.sendBatteryLevel(batteryPcnt);
    //    batterie_check = 1;
    //  } else {
    //    batterie_check++;  
    //  }
     
    gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME);
    
    }
    
    1 Reply Last reply
    0
    • T Offline
      T Offline
      TheoL
      Contest Winner
      wrote on last edited by
      #2

      could you post a schematic you use for the provided sketch? It's a bit hard to tell what's wrong, just by looking at your sketch.

      1 Reply Last reply
      0
      • mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #3

        This will not affect the functionality of your sketch, but I suggest you change

        gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME);
        

        to

        gw.sleep(digitalPinToInterrupt(BUTTON_PIN) , CHANGE, SLEEP_TIME);
        

        and remove

        #define INTERRUPT 1
        

        to avoid mistakes if you change BUTTON_PIN but forget to change INTERRUPT.

        1 Reply Last reply
        2
        • T Offline
          T Offline
          Takero
          Hardware Contributor
          wrote on last edited by
          #4

          Thanks for help. . . i dont now why but it works now.

          I Think i had an Hardware issues :(

          Thanks!

          1 Reply Last reply
          0

          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


          19

          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