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. Custom Interrupt routine for door sensor

Custom Interrupt routine for door sensor

Scheduled Pinned Locked Moved Development
interrupttemperaturearduinohumiditydoor sensors
4 Posts 3 Posters 3.8k Views 1 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.
  • F Offline
    F Offline
    funksoulbrother
    wrote on last edited by funksoulbrother
    #1

    Dear guys, i'm approaching a problem similar to the one presented in this topic: http://forum.mysensors.org/topic/271/interrupt-driven-contact-sensor/2
    I have a node with a DHT11 and a magnetic reed switch to control a door movement. My node sleeps for a determined time interval with the gw.sleep method. And iìd like to wake it up when the timer runs out or when an interrupt is received ( easy to do) . My problem is that i want to perform a specific action when the interrupt is received. Something like : Node Sleeping ---> pin Interrupt ---> Custom action performed ---> other routine in the loop ----> sleep again.
    In particular when the door is opened or closed, i'd like to start a routine that reads the door interrupt pin and reports its status.
    Using instead the defined gw.sleep(IntPin,TypeOfInt,SleepTime) command
    with CHANGE i could catch the door movement but i cannot know the status of the door. Using RISING or FALLING i can get only one of the 2 moves ( open or close) , and with LOW, when door is closed, my node stucks.

    My ideal routine should be something like : interrupt received -->wake up node ---> read interrupt pin ---> send to gateway the value that has been read and blink a led--> put the node back to sleep.
    Can someone help me? i'm attaching the sketch i wrote that's not working well ( freezes). In this sketch the led blinking is missing ( but that's secondary)
    DoorAndTempAndHumIntVer2.ino

    BulldogLowellB 1 Reply Last reply
    0
    • F funksoulbrother

      Dear guys, i'm approaching a problem similar to the one presented in this topic: http://forum.mysensors.org/topic/271/interrupt-driven-contact-sensor/2
      I have a node with a DHT11 and a magnetic reed switch to control a door movement. My node sleeps for a determined time interval with the gw.sleep method. And iìd like to wake it up when the timer runs out or when an interrupt is received ( easy to do) . My problem is that i want to perform a specific action when the interrupt is received. Something like : Node Sleeping ---> pin Interrupt ---> Custom action performed ---> other routine in the loop ----> sleep again.
      In particular when the door is opened or closed, i'd like to start a routine that reads the door interrupt pin and reports its status.
      Using instead the defined gw.sleep(IntPin,TypeOfInt,SleepTime) command
      with CHANGE i could catch the door movement but i cannot know the status of the door. Using RISING or FALLING i can get only one of the 2 moves ( open or close) , and with LOW, when door is closed, my node stucks.

      My ideal routine should be something like : interrupt received -->wake up node ---> read interrupt pin ---> send to gateway the value that has been read and blink a led--> put the node back to sleep.
      Can someone help me? i'm attaching the sketch i wrote that's not working well ( freezes). In this sketch the led blinking is missing ( but that's secondary)
      DoorAndTempAndHumIntVer2.ino

      BulldogLowellB Offline
      BulldogLowellB Offline
      BulldogLowell
      Contest Winner
      wrote on last edited by BulldogLowell
      #2

      @funksoulbrother

      this is how the BinarySwitchSleepSensor example works, I believe that's what you want from your description...

      note it uses CHANGE mode for the interrupt...

      1 Reply Last reply
      0
      • F Offline
        F Offline
        funksoulbrother
        wrote on last edited by
        #3

        Damn, didn't have that sketch in my folder, maybe i had an old release. Just found it in the latest release. Gonna try it soon and test if does the job that i need to be done. Thank you for your advice

        1 Reply Last reply
        0
        • V Offline
          V Offline
          viking
          wrote on last edited by
          #4

          I built a trip wire for the post box that I'm connecting. It's however based on a mercury tilt sensor so I'm really not sure whether I think it's a great idea putting it to use (at least not with a sturdy case...). However, I can share my code:

          #define DIGITAL_INPUT_SENSOR 2 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
          #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)

          MyMessage msgTripped(CHILD_ID_TRIPPED, V_TRIPPED);
          void setup()
          {
          gw.sendSketchInfo("Postal", "1.0");
          gw.present(CHILD_ID_TRIPPED, S_MOTION);

          pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input
          }

          void loop()
          {
          boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == LOW;

          if(tripped) {
          gw.send(msgTripped.set("1")); // Send tripped value to gw
          }

          gw.sleep(INTERRUPT,FALLING, SLEEP_TIME);
          }

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


          21

          Online

          11.7k

          Users

          11.2k

          Topics

          113.0k

          Posts


          Copyright 2019 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