Wakeup on Interrupt not working



  • Hi,

    I have an external system which outputs a signal (~2.5V) on one of its pins under certain circumstances. So I hooked up this output pin to the digital pin 3 on my arduino pro mini (and obviously GND from the external system to GND from the arduino), so that the arduino can tell me whether the external system triggered or not.

    Now, when I don't put gw.sleep() in my code, everything works as aspected.
    But when I put gw.sleep() in my code and tell it to wake on interrupt, it doesn not work (the arduino doesn't wake up when I trigger the external system)

    Does somebody has an idea why this is the case? Here's my code:

    #include <MySensor.h>  
    #include <SPI.h>
    
    //unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
    #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
    #define CHILD_ID 1   // Id of the sensor child
    
    MySensor gw;
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup()  
    {  
      gw.begin(NULL,35,false,AUTO);   //Henry Node-ID anpassen!
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("SmokeRF", "1.0");
    
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the  sensor digital pin as input
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID, S_DOOR);
      
    }
    
    void loop()     
    {     
      if (digitalRead(DIGITAL_INPUT_SENSOR)==HIGH) {
        Serial.println("Alarm");
        gw.send(msg.set(1));  // Send value to gw 
      }
     
      // Sleep until interrupt comes in on sensor. Send update every two minute. 
      gw.sleep(INTERRUPT,CHANGE,SLEEP_TIME);
    }
    


  • Did you already try applying 5V on the interrupt pin manually?
    Maybe the 2.5V is not enough to trigger the interrupt.



  • @NickB149 said:

    Did you already try applying 5V on the interrupt pin manually?
    Maybe the 2.5V is not enough to trigger the interrupt.

    I'm using a 3.3v arduino pro mini, so the 2.5v should be enough i think?



  • Try this:
    gw.sleep(1, CHANGE, 0);



  • Problem solved!
    First, I forgot to activate the internal Pullup:
    digitalWrite(DIGITAL_INPUT_SENSOR, HIGH);
    Besides that, every signal greater than 0.5V is recognized as interrupt, BUT digitalRead only recognizes signals greater than 1.5V!

    When my external system triggers, it starts to slowly increase the voltage from 0.5V up to 3.3V. It reaches 1.5V after 5 seconds triggering. I cancelled the test every time after 3-4 seconds, so that's the problem why nothing worked.


Log in to reply
 

Suggested Topics

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts