Duff's Snooze Library - Setup Questions

Status
Not open for further replies.

solardude

Well-known member
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:
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:
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:
void setup() {  }

And my code for using 3 different wake up pins should look like the code below?

HTML:
#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:
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.
 
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.
 
Sweet!

I'll report back on how this all works out once I get further along with the product design, it's fairly complicated. :D
 
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'
 
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!!
 
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.
 
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.
 
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:
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.
 
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:
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.
 
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 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. :eek::confused:
 
Last edited:
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.
 
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?
 
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.
 
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.
 
Status
Not open for further replies.
Back
Top