Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 15 of 15

Thread: Putting Teensy 4.0 to sleep does not reduce power consumption?

  1. #1
    Junior Member
    Join Date
    Oct 2017
    Location
    Innsbruck
    Posts
    15

    Putting Teensy 4.0 to sleep does not reduce power consumption?

    The Teensy consumes 30 to 33 mA regardless if in sleep or not. What am I doing wrong here?

    This is the code:

    #include <Snooze.h>

    SnoozeDigital digital;
    SnoozeTimer timer;

    SnoozeBlock config_teensy40(digital, timer);

    void setup()
    {
    timer.setTimer(10);
    }

    void loop()
    {

    Snooze.sleep( config_teensy40 );

    for (int i = 0; i < 4; i++)
    {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
    }
    }

  2. #2
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    1,032
    If I understand this page correctly then timer.setTimer(10); instructs the Teensy to sleep for 10 milliseconds only and then wakeup and flash the LED for 4 secs. That will indeed not show a lower power consumption.
    But I could be wrong in interpreting the API...

    Paul

  3. #3
    Junior Member
    Join Date
    Oct 2017
    Location
    Innsbruck
    Posts
    15
    For the Teensy 4.0 this is seconds as far as I understood it.

    Karl

  4. #4
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    1,136
    Quote Originally Posted by ColdFire View Post
    The Teensy consumes 30 to 33 mA regardless if in sleep or not. What am I doing wrong here?

    This is the code:

    #include <Snooze.h>

    SnoozeDigital digital;
    SnoozeTimer timer;

    SnoozeBlock config_teensy40(digital, timer);

    void setup()
    {
    timer.setTimer(10);
    }

    void loop()
    {

    Snooze.sleep( config_teensy40 );

    for (int i = 0; i < 4; i++)
    {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
    }
    }
    Firstly could you enclose any code posted between CODE tags using the # button as I have done below.
    Code:
    #include <Snooze.h>
    
    SnoozeDigital digital;
    SnoozeTimer timer;
    
    SnoozeBlock config_teensy40(digital, timer);
    
    void setup()
    {
    	timer.setTimer(10);
    }
    
    void loop()
    {
    
    	Snooze.sleep(config_teensy40);
    
    	for (int i = 0; i < 4; i++)
    	{
    		digitalWrite(LED_BUILTIN, HIGH);
    		delay(500);
    		digitalWrite(LED_BUILTIN, LOW);
    		delay(500);
    	}
    }
    As far as your code goes, I don't know if it makes any difference but you have specified a digital sleep component but not initialised it.
    As I said I don't if it makes any difference but make some changes and give it a try.

  5. #5
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    1,032
    Quote Originally Posted by ColdFire View Post
    For the Teensy 4.0 this is seconds as far as I understood it.

    Karl
    You're right, it's stated on the page...
    /************************************************** ******
    * Set Low Power Timer wake up in milliseconds T3.x/LC,
    * seconds T4.x.
    ************************************************** ******/
    Paul

  6. #6
    Junior Member
    Join Date
    Oct 2017
    Location
    Innsbruck
    Posts
    15
    I copied this from the example code

    sleep_all_wakeups.ino

    that can be found in the examples of the Snooze library in hardware\teensy\avr\libraries\Snooze\examples\slee p\

    Karl

  7. #7
    I tried the OP's program with both T4.0 and T4.1, and as soon as it gets loaded the Teensy crashes and does 9 blinks, which means...

    9 Blinks = ARM JTAG DAP Init Error
    The ARM JTAG DAP was detected (4 blinks) but could not be initialized. This error is rather unlikely!
    So, I tried several of the Snooze Example programs, and they all have the same effect on both T4.0 and T4.1

    I'm using Arduino 1.8.19 and TD 1.58b3

  8. #8
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    1,136
    Quote Originally Posted by ColdFire View Post
    I copied this from the example code

    sleep_all_wakeups.ino

    that can be found in the examples of the Snooze library in hardware\teensy\avr\libraries\Snooze\examples\slee p\

    Karl
    Yes and deleted all the parameters which you did not require, unfortunately YOU DID NOT delete the digital parameter.
    As I said I don't know if it will make any difference but without setting up the digital component you could have some un-initialised wake up states causing a premature wake up.

  9. #9
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    1,136
    Quote Originally Posted by joepasquariello View Post
    I tried the OP's program with both T4.0 and T4.1, and as soon as it gets loaded the Teensy crashes and does 9 blinks, which means...



    So, I tried several of the Snooze Example programs, and they all have the same effect on both T4.0 and T4.1

    I'm using Arduino 1.8.19 and TD 1.58b3
    See a needed correction to the Snooze Library here.

  10. #10
    Junior Member
    Join Date
    Oct 2017
    Location
    Innsbruck
    Posts
    15
    I tried with the full source code of the example, but with the same result.

  11. #11
    Quote Originally Posted by BriComp View Post
    See a needed correction to the Snooze Library here.
    With that fix applied, the OP's program seems to work as intended. I'm not measuring current, but the LED does stop blinking for the period specified in the SnoozeTimer.

  12. #12
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    1,136
    Quote Originally Posted by ColdFire View Post
    I tried with the full source code of the example, but with the same result.
    This post might help you.
    See post #16 onwards.

  13. #13
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    1,136
    The Snooze wake up times are rather long for the T4.0. See here.

  14. #14
    Junior Member
    Join Date
    Oct 2017
    Location
    Innsbruck
    Posts
    15
    I implemented this correction but the power consumption does not go down.

  15. #15
    Junior Member
    Join Date
    Oct 2017
    Location
    Innsbruck
    Posts
    15
    Anyway, it's not very important. I will just use a different board for my project.

    Thank you all for your help.

    Karl

Posting Permissions

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