Node is rebooted by waking up from a sleep



  • Hi all,

    I have the following code which constantly reboots my node when Interrupted by PIR.
    Any idea why?

    //#define MY_DEBUG_VERBOSE_SIGNING
    //#define MY_SPLASH_SCREEN_DISABLED
    
    // Enable and select radio type attached
    #define MY_RADIO_RFM69
    #define MY_RFM69_NEW_DRIVER
    #define MY_RFM69_ATC_MODE_DISABLED
    #define MY_RFM69_FREQUENCY RFM69_868MHZ
    #define MY_PARENT_NODE_IS_STATIC
    #define MY_PARENT_NODE_ID 0
    #define MY_RFM69_NETWORKID (100)
    #define MY_NODE_ID 3
    
    #define INT_PIN 6
    #define INT_PINN 7
    #define SLEEP_TIME 9000000  // 15 min
    uint32_t sleepTime = SLEEP_TIME;
    int8_t wakeupReason = 0;
    
    #include <MySensors.h>
    
    void setup() {
      Serial.begin(115200);
      PCMSK2 |= bit(PCINT22);
      PCMSK2 |= bit(PCINT23);
      PCIFR |= bit(PCIF2);  // clear any outstanding interrupts
      PCICR |= bit(PCIE2);  // enable pin change interrupts for D0 to D7
      delay(2000);
      pinMode(INT_PIN, INPUT);
      pinMode(INT_PINN, INPUT);
    }
    
    
    void loop() {
      if (wakeupReason == digitalPinToInterrupt(INT_PIN) || wakeupReason == digitalPinToInterrupt(INT_PINN)) {
        Serial.println("Sleep Interrupted!");
        digitalWrite(9, HIGH);
        delay(20);
        digitalWrite(9, LOW);
        // Report sensor status here
      } else if (wakeupReason == MY_WAKE_UP_BY_TIMER) {
        Serial.println("MY_WAKE_UP_BY_TIMER");
        // Report battery level here
      }
      wakeupReason = sleep(digitalPinToInterrupt(INT_PIN), CHANGE, digitalPinToInterrupt(INT_PINN), CHANGE, sleepTime);
    }
    

Log in to reply
 

Suggested Topics

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts