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); }
1 out of 1
Suggested Topics
-
Day 1 - Status report
Announcements • 23 Mar 2014, 22:45 • hek 24 Mar 2014, 20:12 -
Raspberry Pi 5: invalid GPIO 9
Troubleshooting • 27 Aug 2024, 13:20 • igo 27 Aug 2024, 13:20 -
JSN-SR04T-V3.0 Coax cable extended
Troubleshooting • 11 days ago • bocalexandru 10 days ago -
Can not compile MySensors on esp8266
Troubleshooting • 24 Aug 2024, 15:35 • TheoL 29 Aug 2024, 20:47 -
Getting system time from the controller
Troubleshooting • 27 Feb 2025, 01:39 • dpcons 28 days ago -
Compiling Sensor code using BME280 and ESP8266
Troubleshooting • 26 Feb 2025, 00:32 • dpcons 26 Feb 2025, 06:22