Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 35

Thread: Duff's Snooze Library - Setup Questions

  1. #1

    Duff's Snooze Library - Setup Questions

    Hey everybody!

    I'm have a battery powered project that I'm using the Teensy 3.1 in and I'm going to use Duff's Awesome Snooze library to put the Teensy 3.1 into Hibernate when the Battery Management chip's Sleep Pin signals LOW, and then wake from Hibernate when the Sleep Pin signals High.

    From what I'm seeing this should be pretty easy to do.

    I also want to wake from Hibernate via 2 additional sources also and I'm not sure if that's possible so I'm hoping @Duff can chime in with some advice.
    Here are the 2 additional wake sources I would like to setup.

    1. Wake via timer set for 24 hours. So Wake from Hibernate every 24 hours.

    2. Wake from a Cap Touch pin when touched. I plan on using Cap Touch buttons for LCD screen navigation anyways.


    Is it possible to use all 3 of these at the same time without problems?
    Last edited by solardude; 05-26-2015 at 02:35 AM.

  2. #2
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    897
    yes you can have all those wakeups, look at deepSleep_all_wakeups example.

  3. #3
    Quote Originally Posted by duff View Post
    yes you can have all those wakeups, look at deepSleep_all_wakeups example.
    Thanks for the reply Duff.

    I'm excited to finally be at the point of putting your low power modes to good use.

    I see that Deep Sleep only drops the current down to about 230 uA, I'm wanting to use Hibernate instead so I can take advantage of the 15 uA low power mode since this will be used in a portable battery application.

    So in Hibernate am I only able to use 1 mode to wake the Teensy 3.1?
    Last edited by solardude; 05-26-2015 at 07:49 AM.

  4. #4
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    897
    All work the same, just replace "deepSleep" with "hibernate"

  5. #5
    Great to hear that.

    So should my code look something like this to set the 3 different wake up sources at the same time?

    For some reason I assumed that only the first listed wake up would take effect and the other 2 would be left out.

    So the Config.pinMode lines are supposed to always be placed into the void setup area right?
    HTML Code:
    void setup() {  }
    And my code for using 3 different wake up pins should look like the code below?

    HTML Code:
    #include <Snooze.h>
    
    
    SnoozeBlock config;
    
    
    
    void setup() {
    
    config.pinMode(21, INPUT_PULLUP, RISING);      // * Define digital pins for waking the teensy up.
    config.pinMode(0, TSI, touchRead(0) + 250);     // * Values greater than threshold will trigger TSI wakeup.
    
    
    #ifdef KINETISK
    config.setAlarm(24, 0, 0);                          // * Set RTC alarm wake up in (hours, minutes, seconds).
    #endif
    
    }
    
    
    void loop() {
    
    Snooze.deepSleep( config ); 
    
    }
    

    Are the lines below required if I'm always using the Teensy 3.1 chip?

    #ifdef KINETISK
    &
    #endif
    Last edited by solardude; 05-26-2015 at 07:50 AM.

  6. #6
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    897
    Quote Originally Posted by solardude View Post
    Are the lines below required if I'm always using the Teensy 3.1 chip?

    #ifdef KINETISK
    &
    #endif
    You can remove ifdef's if you are using a Teensy 3.x. The RTC is not functional with the Teensy LC so thats why I have the ifdef in the example code.

  7. #7
    Quote Originally Posted by duff View Post
    You can remove ifdef's if you are using a Teensy 3.x. The RTC is not functional with the Teensy LC so thats why I have the ifdef in the example code.
    Cool, thank you very much for the guidance.

    So my code and config pin layout looks proper for using 3 wake up sources? If so your library sure does make these low power modes super duper simple to use.

    Thank you so much for putting the Snooze Library together.

  8. #8
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    897
    yep looks good, its best to configure the wakeups in the setup function.

  9. #9
    Sweet!

    I'll report back on how this all works out once I get further along with the product design, it's fairly complicated.

  10. #10
    Member
    Join Date
    Oct 2015
    Location
    Roma (IT, UE)
    Posts
    40
    Just wanted to say "Thank you" to Duff for his library.

    I'm using version 5.5 with a Teensy 3.2.

    I'm seeing 270uA (powering via USB 5V) while sleeping with

    Code:
    Snooze.deepSleep
    I don't think "Snooze.hibernate" exists on v5.5, at least for Teensy 3.2: am I right?

    Code:
    'class SnoozeClass' has no member named 'hibernate'

  11. #11
    Member
    Join Date
    Oct 2015
    Location
    Roma (IT, UE)
    Posts
    40
    Nevermind: uncommenting USE_HIBERNATE in Snooze.h allowed me to invoke Snooze.hibernate(config).
    I'm now down to 46uA @ 5V!

    Thanks Duff for the great work!!

  12. #12
    Senior Member
    Join Date
    Feb 2016
    Posts
    122
    Hi all,

    I have to run my code from morning 10 AM to night 10 PM and the remaining time it will be like off (suggest most suitable mode). kindly tell me first if i add the crystal i can able to use internal rtc for my concern and also how to set the current time using snooze library.

  13. #13
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    897
    Quote Originally Posted by npashine View Post
    Hi all,

    I have to run my code from morning 10 AM to night 10 PM and the remaining time it will be like off (suggest most suitable mode). kindly tell me first if i add the crystal i can able to use internal rtc for my concern and also how to set the current time using snooze library.
    Hmmm, thats interseting. Yes, you can do this but the library uses a relative time to wake, so you would have to call one of the sleep functions at 10pm and use 'setAlarm(12,0,0)' configuration to wake you up in 12 hours (10am).

    This makes me think that I could add some more rtc functionality to Snooze. I'll have to think about how to do that.

  14. #14
    Senior Member
    Join Date
    Feb 2016
    Posts
    122
    Hi duff,

    okay what u said is exactly right but my setAlarm is not working, I tried for setAlarm(0,0,12) and after 12 sec also led was not glowing.
    1 more thing I want to tell you is I have not included the 32khz crystal yet but my setTimer(5000) is working fine so my wondering is why setAlarm is not working if settimer is working.

    Also whether its possible if I set time via time.h library and set the alarm via snooze.h library.
    Last edited by npashine; 03-04-2016 at 06:15 AM.

  15. #15
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    897
    Quote Originally Posted by npashine View Post
    1 more thing I want to tell you is I have not included the 32khz crystal yet but my setTimer(5000) is working fine so my wondering is why setAlarm is not working if settimer is working.
    You must have that crystal installed to use the rtc!

    Also whether its possible if I set time via time.h library and set the alarm via snooze.h library.
    I was talking about making Snooze's time settings have more options but yes you can set the 'Time' library's time and set an alarm with Snooze. The Time libraries alarms are not wakeup alarms by the way.

  16. #16
    Senior Member
    Join Date
    Feb 2016
    Posts
    122
    Hi duff,

    I will just set the time via time.h library and I will set the alarm via snooze.h library.

  17. #17
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    897
    Quote Originally Posted by npashine View Post
    Hi duff,

    I will just set the time via time.h library and I will set the alarm via snooze.h library.
    Yep, that how it should be done, make sure you resync the time after waking up.

  18. #18
    Senior Member
    Join Date
    Feb 2016
    Posts
    122
    Hi all,

    while using hibernate function of snooze library I'm getting below error:

    error: 'class SnoozeClass' has no member named 'hibernate'
    'class SnoozeClass' has no member named 'hibernate'


    Also, how can I completely cut the power from teensy in deepSleep mode as I have seen voltage regulator still works which i don't want.
    Last edited by npashine; 03-10-2016 at 12:56 PM. Reason: missed something

  19. #19
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    897
    Quote Originally Posted by npashine View Post
    Hi all,

    while using hibernate function of snooze library I'm getting below error:

    error: 'class SnoozeClass' has no member named 'hibernate'
    'class SnoozeClass' has no member named 'hibernate'

    Un comment #define USE_HIBERNATE in the Snooze.h from the library.

    Also, how can I completely cut the power from teensy in deepSleep mode as I have seen voltage regulator still works which i don't want.
    You would need some type of circuit to do that, the low power modes can't do that.

  20. #20
    Senior Member
    Join Date
    Feb 2016
    Posts
    122
    Thanks, duff the hibernate worked..

    Also, kindly suggest me the best mode for power down extremely.

    And also, can you suggest me some circuit to cut the power from the regulator for all connections.

  21. #21
    I am trying to get the pin compare wakeup to work but it only seems to fire once:

    Code:
    #include <Snooze.h>
    #include <ADC.h>
    
    const int PGOODpin = 12;
    
    // Load snooze drivers
    SnoozeCompare compare;
    
    SnoozeBlock config_teensy32( compare );
    
    void setup() {
      pinMode(13,OUTPUT);
    
      digitalWriteFast(13,HIGH);
      delay(1000);
      digitalWriteFast(13,LOW);
    
      setupAlarms();
    }
    
    void loop() {
      Snooze.sleep( config_teensy32 );
    
      digitalWriteFast(13,HIGH);
      delay(1000);
      digitalWriteFast(13,LOW);
      delay(500);
    }
    
    void setupAlarms() {
      pinMode(PGOODpin, INPUT_PULLDOWN);
      compare.pinMode(PGOODpin, HIGH, 3.03); //pin, mode, threshold(v)
    }
    This blinks the LED once in setup, then sleeps. When I raise the voltage on pin 12 (the PGOOD pin) the light starts to blink for as long as I keep the wire in the air and the voltage is floating (so that PULLDOWN isn't working), but then if I ground pin 12 and touch 3.3V again, it does not fire again. So my compare wakeup is only working once, then never again...what am I doing wrong?

    EDIT: A few days later, I now can use pin 11 to do compare wakeups but not pin 12. I appear to have wrecked pin 12 on this board. I'm ordering a new Teensy 3.2 because I may have been too rough with this hardware at some point.
    Last edited by distro_inferno; 08-10-2017 at 08:02 PM.

  22. #22
    Quote Originally Posted by npashine View Post
    Thanks, duff the hibernate worked..

    Also, kindly suggest me the best mode for power down extremely.

    And also, can you suggest me some circuit to cut the power from the regulator for all connections.
    I think hibernate is the least power mode.

    To completely cut power to the Teensy, you'll need to use a switch like a MOSFET. I can't give you more advice on how to hook that up (like whether to have the gate controlled by the upstream power supply or the Teensy) until you explain your circuit and application in more detail.

  23. #23
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    897
    Quote Originally Posted by distro_inferno View Post
    I am trying to get the pin compare wakeup to work but it only seems to fire once:
    This blinks the LED once in setup, then sleeps. When I raise the voltage on pin 12 (the PGOOD pin) the light starts to blink for as long as I keep the wire in the air and the voltage is floating (so that PULLDOWN isn't working), but then if I ground pin 12 and touch 3.3V again, it does not fire again. So my compare wakeup is only working once, then never again...what am I doing wrong?
    Can you try deepSleep or hibernate instead?

  24. #24
    Quote Originally Posted by duff View Post
    Can you try deepSleep or hibernate instead?
    No luck with those- I can't get the LED to blink in the loop() function except with sleep.

    Am I setting up the pin correctly? It's only the two lines. I'm doing this on a "blank" breadboard, and for testing I'm taking a jumper wire that's plugged in to pin 12 on the Teensy 3.2 and alternating the connection between GND and 3.3V.

  25. #25
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    897
    Quote Originally Posted by distro_inferno View Post
    No luck with those- I can't get the LED to blink in the loop() function except with sleep.

    Am I setting up the pin correctly? It's only the two lines. I'm doing this on a "blank" breadboard, and for testing I'm taking a jumper wire that's plugged in to pin 12 on the Teensy 3.2 and alternating the connection between GND and 3.3V.
    Ok, my usb cable died this week and I just got my replacement in today so I can finally finish the Snooze update For testing the comparator wakeup I used a 10k trim pot connected to the 3.3v output of the Teensy, Gnd and either of the comparators inputs e.g. pin 11 or 12.

Posting Permissions

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