Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 36 of 36

Thread: Duff's Snooze Library - Setup Questions

  1. #26
    I notice in the _all_wakeups.ino examples, the RTC alarm is used but the RTC is never set with the date and time. I assume it's able to do relative time keeping, such as "wake up in 10s" even if it doesn't know what the current date/time is?

    The issue I had using the RTC to wake up is that it would correctly wake up in 15s when I set it for 15s, but then it doesn't process the passage of time while asleep. It'd only move the clock forward by the few seconds when the system was awake. So for example if it spent 9 out of every 10s asleep, the clock would only move forward by 1s for every 10s of real time.

    RTC is listed as "Full Functionality" across all sleep modes in the datasheet (table 7.2) so that shouldn't happen in any of the three modes, correct?

  2. #27
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    899
    Quote Originally Posted by distro_inferno View Post
    I notice in the _all_wakeups.ino examples, the RTC alarm is used but the RTC is never set with the date and time. I assume it's able to do relative time keeping, such as "wake up in 10s" even if it doesn't know what the current date/time is?
    It uses whatever the RTC hardware time is set to. So even if the time is "wrong" it will still work for waking up.

    Quote Originally Posted by distro_inferno View Post
    The issue I had using the RTC to wake up is that it would correctly wake up in 15s when I set it for 15s, but then it doesn't process the passage of time while asleep. It'd only move the clock forward by the few seconds when the system was awake. So for example if it spent 9 out of every 10s asleep, the clock would only move forward by 1s for every 10s of real time.
    Yes, if your using the time library you need to resync the time.

    Quote Originally Posted by distro_inferno View Post
    RTC is listed as "Full Functionality" across all sleep modes in the datasheet (table 7.2) so that shouldn't happen in any of the three modes, correct?
    Yes it works on all power modes.

  3. #28
    Quote Originally Posted by duff View Post
    It uses whatever the RTC hardware time is set to. So even if the time is "wrong" it will still work for waking up.


    Yes, if your using the time library you need to resync the time.


    Yes it works on all power modes.
    So you're saying that the RTC will always keep an accurate second-to-second count in all power modes, however it will lose it's state and need to retrieve the actual date/time? The datasheet is misleading because I would have thought that "Full Functionality" in all modes means that it keeps the date/time.

  4. #29
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    899
    Quote Originally Posted by distro_inferno View Post
    So you're saying that the RTC will always keep an accurate second-to-second count in all power modes, however it will lose it's state and need to retrieve the actual date/time? The datasheet is misleading because I would have thought that "Full Functionality" in all modes means that it keeps the date/time.
    I'm talking about if you use the Time Library with the Snooze library. Then you have to resync the Time Library to get the correct time when you wakeup, the RTC will work in all power modes and keep the correct time its just the Time library needs to be resynced.

  5. #30
    Quote Originally Posted by duff View Post
    I'm talking about if you use the Time Library with the Snooze library. Then you have to resync the Time Library to get the correct time when you wakeup, the RTC will work in all power modes and keep the correct time its just the Time library needs to be resynced.
    Ooohhh thank you. This is really helpful. I didn't know I needed to call setSyncProvider(getTeensy3Time); upon wakeup.

  6. #31
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    899
    Quote Originally Posted by distro_inferno View Post
    Ooohhh thank you. This is really helpful. I didn't know I needed to call setSyncProvider(getTeensy3Time); upon wakeup.
    Yes, I need to really need to write some better documentation!

  7. #32
    Senior Member
    Join Date
    Aug 2016
    Posts
    102
    Hello,
    i tried the example "deepsleep-->button_hold_wakeup",i measured 5ma current consumption with the multimeter.
    I have nothing connected in this,it's just the teensy board.
    Normally consumption should not be less?I use the teensy 3.6.

    Code:
    #include <Snooze.h>
    #include <Bounce.h>
    
    // Load drivers
    SnoozeDigital digital;// this is the pin wakeup driver
    // configures the lc's 5v data buffer (OUTPUT, LOW) for low power
    Snoozelc5vBuffer lc5vBuffer;
    
    // use bounce for pin 13, debounce of 5ms
    Bounce button = Bounce(13, 5);
    
    // install driver into SnoozeBlock
    #if defined(__MK66FX1M0__) || defined(__MK64FX512__) || defined(__MK20DX256__)
    SnoozeBlock config_teensy3x(digital);
    #elif defined(__MKL26Z64__)
    SnoozeBlock config_teensyLC(digital, lc5vBuffer);
    #endif
    
    void setup() {
        // Configure pin 2 for bounce library
        pinMode(13, INPUT_PULLUP);
        // debug led
        pinMode(LED_BUILTIN, OUTPUT);
        while (!Serial);
        delay(100);
        Serial.println("start...");
        delay(20);
        //pin, mode, type
        digital.pinMode(13, INPUT_PULLUP, FALLING);
    }
    
    void loop() {
        // if not held for 3 sec go back here to sleep.
    SLEEP:
        // you need to update before sleeping.
        button.update();
        
        // returns module that woke processor after waking from low power mode.
    #if defined(__MK66FX1M0__) || defined(__MK64FX512__) || defined(__MK20DX256__)
        Snooze.deepSleep( config_teensy3x );
    #elif defined(__MKL26Z64__)
        Snooze.deepSleep( config_teensyLC );
    #endif
        
        // indicate the button woke it up, hold led high for as long as the button
        // is held down.
        digitalWrite(LED_BUILTIN, HIGH);
        
        elapsedMillis timeout = 0;
        // bounce needs to call update longer than the debounce time = 5ms,
        // which is set in constructor.
        while (timeout < 6) button.update();
        
        // now check for 3 second button hold
        bool awake = threeSecondHold();
        
        // if not held for 3 seconds go back to sleep
        if (!awake) goto SLEEP;
        
        // the button was held for at least 3 seconds if
        // you get here do some stuff for 7 seconds then
        // go to sleep.
        elapsedMillis time = 0;
        
        while (1) {
            unsigned int t = time;
            Serial.printf("doin stuff for: %i milliseconds\n", t);
            
            // back to sleep after 7 seconds
            if (time > 7000) {
                Serial.println("sleeping now :)");
                
                // little delay so serial can finish sending
                delay(5);
                
                goto SLEEP;
            }
            digitalWrite(LED_BUILTIN, HIGH);
            delay(50);
            digitalWrite(LED_BUILTIN, LOW);
            delay(50);
        }
    }
    
    bool threeSecondHold() {
        // this is the 3 sec button press check
        while (button.duration() < 3000) {
            
            // get the current pin state, must have this!
            button.update();
            
            // check the pin 2 state, if button not
            // pressed before 3 seconds go back to
            // sleep. We read 0 since pin 2 is
            // configured as INPUT_PULLUP.
            if (button.read() != 0) {
                digitalWrite(LED_BUILTIN, LOW);
                // let go of button before 3 sec up
                return false;
            }
        }
        digitalWrite(LED_BUILTIN, LOW);
        
        // button was held for 3 seconds so now we are awake
        return true;
    }
    Last edited by thanos; 12-04-2017 at 09:52 AM.

  8. #33
    Senior Member
    Join Date
    Aug 2016
    Posts
    102
    Some help?

  9. #34
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,445
    Pin 13 is the Teensy’s LED pin. Thus, if you configure this pin as input pull-up, constant parasitic current will flow through the internal pull-up resistor and the LED. Just try any other pin.

  10. #35
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    899
    Yep pin 13 is probably why your seeing the 5mA.

  11. #36
    Does anyone know the mapping between the various low power modes in the Snooze (sleep, deepsleep, hibernate) and the various low power modes (wait mode, very low power run mode, very low power wait mode, stop mode, very low power stop mode, low leakage stop mode, very low leakage stop mode 3, 2, and 1)?

    In other words, which modes are utilized by the snooze library?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •