How to sleep the Arduino but still have it respond to the Vera?
-
attachInterrupt( ) -
@BulldogLowell Isn't that the part that the MySensors libs (should) take care of?
-
@BulldogLowell Isn't that the part that the MySensors libs (should) take care of?
@marceltrapman said:
@BulldogLowell Isn't that the part that the MySensors libs (should) take care of?
Good point.
Does gw.sleep( ) accept both interrupts?
-
Hi @hek and thanks for the info!
However, I'm not sure that I find anything regarding listening for both D2 and D3-pins in MySensors.h, I only find:
*/** * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change. * See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin * is assigned to what interrupt. On Nano/Pro Mini: 0=Pin2, 1=Pin3 * @param interrupt Interrupt that should trigger the wakeup * @param mode RISING, FALLING, CHANGE * @param ms Number of milliseconds to sleep or 0 to sleep forever * @return true if wake up was triggered by pin change and false means timer woke it up. */ bool sleep(int interrupt, int mode, unsigned long ms=0);Which is the same as the documentation, right?
-
Hi again!
I've tried different approaches now with the gw.sleep(); func without success, using CHANGE, RISING or FALLING. No reaction either from tag or the Vera.
// Wait for card/tag to leave reader while(nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], ¤tKeyLength)); // gw.sleep(2000); } gw.sleep(0, CHANGE, 1, CHANGE, 0); // int8_t sleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms=0); }I've also tried adding this to setup();
interrupts();as well as this:
attachInterrupt(0, loop, CHANGE); attachInterrupt(1, loop, CHANGE);Nothing happens. It just continues to sleep...
-
I'm back to choosing between no sleep, and the sleep(); function posted above. I can't get gw.sleep(); to work with either one or two interrupts, with or without declaring interrupts(); and/or attachInterrupt();.
I'm ready to try more stuff if anyone got any ideas, but with my own limited understanding of both hardware in general and arduino in particular it feels like I'm running on fumes here. :o
Thanks everyone for your contribution, and @hek - you've done a great job with MySensors! :clap: