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

Thread: RTC Teensy LC Low Power

  1. #1
    Junior Member
    Join Date
    Feb 2020
    Posts
    4

    RTC Teensy LC Low Power

    I need a low power solution to wake up my Teensy LC every 6 hours to take sensor readings (sent via LoRa). The teensy is powered via LiPo battery/mini-solar panel. Does anyone know how I can do this using low power? I can use millis/delay to simply wake up the teensy LC but that doesn't save me a whole lot of power. I am aware that the Teensy LC does not have a RTC built in and that there is a snooze library that does provide low power options. I tried the snooze library but it can only wake up the teensy every 5 seconds max and the "alarm" for this library requires an on-board rtc - only works for Teensy 3.5/3.6. So I bought an RTC shield with battery and I can get the time no problem on the teensy LC using the RTC wired to the Teensy LC. However if I snooze the Teensy LC it will not come out of sleep when using the snooze library. Basically I see the issue as this - the RTC shield cannot be "flashed" to alarm every 6 hours and the snooze library on the teensy LC does not perform any internal register level sync with the external RTC shield via the SCL/SDA. I thought about counting pulses or using my NE555 to oscillate but these require extra power. If there is no low power+alarm solution perhaps I can simply use the millis/delay solution and turn off the power hungry components of the teensy LC i.e. the USB via playing with the teensy's registers? Thoughts, ideas would be greatly apprciated.

  2. #2
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,279
    Cant you just update the RTC alarm time with every wakeup?

  3. #3
    Senior Member
    Join Date
    May 2017
    Posts
    122
    Try this,

    use only timer in snooze lib, no RTC at all.
    wake up LC every 60 seconds to increase counter variable and compare value. If value >= (minutes * 60 * 6 hours) do LoRa stuff and set value = 0.
    Go to low power again.

  4. #4
    Junior Member
    Join Date
    Sep 2019
    Posts
    3
    I've recently started using the TPL5110 timer. Adafruit and Sparkfun both sell breakout boards. The timer sits between the battery and everything else (except the solar charger) and turns everything on or off. When the system is off, it draws about 50 nA. The wakeup time is set with a resistor and it is only approximate, but can be set from a few seconds to about 2.5 hours. I've used a couple of strategies to deal with longer wakeup times. You can either wake up, do a quick check of the RTC and go back to sleep if it's not within an acceptable time window or you can store a counter in eeprom and only scan sensors every so many wakeups. You have to be able to accept the less-than-precise nature of the timer.

  5. #5
    Junior Member
    Join Date
    Feb 2020
    Posts
    4
    Awesome replies everyone, thanks! I will try to increment a counter in the eeprom every 60 seconds and compare current cnt to a set value (6 hours), do stuff->reset cntr... I will update this thread once I have some empirical data - power usage etc. This seems to be the easiest solution.

    Cheers,
    James

  6. #6
    Junior Member
    Join Date
    Feb 2020
    Posts
    4
    Here is the code below. I increment the counter to a different byte addr in the EEPROM until I reach the end, then start over at the 1st byte. I do this because there is a limit to physically writing to the same sector over and over. I hear it's around 100K per sector. So in this example I write from byte 1-127, each write equals 1 minute (the alarm is set to 60000 millis, waking the teensy->set the EEPROM->go to sleep). For simplicity I set the main function to fire off every 61 minutes but in Production this will be set to 240 minutes (send sensor data every 4 hours). Since it zeros out the prior byte as it moves along the 127 bytes there are 2 writes every iteration, repeating the write every 127 minutes. And around and around we go writing the the EEPROM every minute. At the rate I calculated the lifespan of the EEPROM on my teensy LC will be 12 years.

    Code:
    #include <Snooze.h>
    #include <EEPROM.h>
    SnoozeDigital digital;
    SnoozeCompare compare;
    SnoozeTimer timer;
    Snoozelc5vBuffer  lc5vBuffer;
    SnoozeBlock config_teensyLC(digital, timer, lc5vBuffer);
    
    // start reading from the first byte (address 0) of the EEPROM
    unsigned int addr = 0;
    int val;
    int ttl_time,curr_addr,prior_addr = 0;
    
    
    void setup()
    {
      // initialize serial and wait for port to open:
      timer.setTimer(60000);// milliseconds
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
      }
    }
    
    void loop()
    {
    
        Snooze.deepSleep( config_teensyLC );// return module that woke processor
        Serial.println("checking time");
        check_time();
         
    }
    
    void check_time(){
      ttl_time = 0;
    
      // read a byte from the current address of the EEPROM
      for(int i=0;i < EEPROM.length();i++){
        val = EEPROM.read(i);
        if(val > 0){
          Serial.print("here is current time: ");
          Serial.println(val);
          curr_addr=i;
          ttl_time = val;
        }
        
      }
    
    //61 is # of minutes
      if(ttl_time > 0 && ttl_time < 61){
        Serial.print("not yet, incrementing time: ");
        Serial.println(ttl_time);
    
        if(curr_addr < (EEPROM.length() - 1)){
          addr = curr_addr + 1;
        }
        else addr = 0;
    
        //clear the current address
        EEPROM.write(curr_addr, 0);
        //set the new time on the next byte
        ttl_time = ttl_time + 1;
        EEPROM.write(addr, ttl_time);   
      }
      
    //run main function every 61 minutes (up to 255 minutes)
      else if (ttl_time == 61 ){
        Serial.print("time to change the world!!! ");
        Serial.println(ttl_time);
        delay(60000);
        //start over
        EEPROM.write(curr_addr, 0);
        EEPROM.write(0, 1);
        ttl_time = 0;
      }
      
      else if (ttl_time > 61 ){
        Serial.print("SOMETHING WENT WRONG RESETING ALL NUMBERS");
        for(int i=0;i < EEPROM.length() ;i++){
        EEPROM.write(i, 0);
      }
    
      }
      else //(ttl_time = 0)
      {
        EEPROM.write(0, 1);
      }
    
    }
    Last edited by Frank B; 03-04-2020 at 09:17 PM. Reason: Added code tags

  7. #7
    Senior Member
    Join Date
    May 2017
    Posts
    122
    Hello,

    I don't think you need to put your counter in EEPROM (understand your concerns about limited write cycles).

    As far as I know, the snooze library/teensy keeps your variables in RAM during "sleep", "deepsleep", "hibernate". So write countervariable in RAM and increase, compare etc. after wake up from low power mode.
    You simple don't power off your teensy during "sleep", "deepsleep", "hibernate". Unit drawing just a few mircoampere then. I recommend to use teensy LC, wich has lowest power consumption.
    Last edited by larry_berlin; 03-05-2020 at 08:30 AM.

  8. #8
    Junior Member
    Join Date
    Feb 2020
    Posts
    4
    Thanks Larry! Yes itís an LC. I use a small solar panel to power it. Havenít tested the draw in deepsleep but will post those numbers soon.

  9. #9
    Senior Member
    Join Date
    May 2017
    Posts
    122
    You can expect 150uA in deepsleep for teensy LC.
    You can expect 6uA in hibernate for teensy LC, but you may get problems with your external circuit, because LDO on MK chip is set in a special state.

    Also be aware of your external circuit. There are a lot of pit falls to draws extra current in low power mode.

  10. #10
    Junior Member
    Join Date
    May 2021
    Posts
    1
    has anyone successfully used teensy LC with the TPL5110 timer from Adafruit?
    I am currently working with one. However I have not been able to power the teensy directly from the breakout timer. while standalone the breakout timer seems to work ok, but when i connect the DRV pin to Vin it doesn't seem to wake up on its own. It works when I enable the One_shot switch but then doesn't power back on by itself after the 1st cycle. Then i tried to isolate the power supply by using a small relay. so now the breakout board switches on a relay that connects power to Vin of the teensy. also there is a 10uf cap between Vcc and GND. this setup seems to work standalone but at every power on from the breakout, the DRV pin seems to pulsate a few times so i hear the relay clicking back and forth and then it goes stable, teensy comes alive runs through the LOOP and sends a DONE signal to the breakout timer.

    not sure about this behavior. the only pin from teensy connecting to the breakout is the DONE signal, and i make sure it is set to LOW right away both in SETUP and LOOP code. looks like will have to purchase an osci to further investigate but would appreciate any pointers.

  11. #11
    Junior Member
    Join Date
    Aug 2018
    Posts
    12
    I successfully prototyped using the Adafruit TPL5110 breakout with a Teensy 3.2 (not LC). The power board controls power to the Teensy, an ultrasonic sensor, and a radio transmitter. Once I figured out how it really works, it works fine. Some things to be aware of with this TPL5110 design:
    - It is VERY sensitive to the resistance on the DELAY pin at first power-up. Turn the system off and use a meter to measure the resistance to ground at this pin, and adjust the pot to the time you want based on the TPL5110 data sheet. For may case I needed 29K for a ~2 minute interval. In my final design I intended to cut the trace on the back of the board and use a multiturn trim pot to set the interval more precisely.
    - The interval is determined only once on first power-up of the breakout board and cannot be changed after that. If you have a battery based power system you have to disconnect the battery to change the timer interval while the power is off.
    - Keep in mind this device just times fixed intervals. It does not matter how long it takes for you to signal DONE and power down, the next interval will occur at the same moment no matter when you signaled DONE. Some people assume that the interval starts when DONE is signaled and the Teensy is turned off (sort of like the Snooze library), but that is now how it works. Once it starts, it will power ON the device(s) at 2 minute intervals (in my case) no matter when (or if) DONE is signaled.

    In this photo the TPL5110 board is at the bottom and is the only place the source power is applied. The DRV pin supplies power to all the other devices, including the Teensy via the right side power rail. The middle module is a radio transmitter and takes 3.3V from the Teensy. In this prototype the DONE is signaled manually by briefly connecting the DONE pin (grey lead) to the power rail. When the Teensy software is complete, that will be driven from a digital output pin.

    (Cannot get photo to show in this post, here is a link)
    https://www.dropbox.com/s/vimrlvnt70...otpye.jpg?dl=0

    In this scenario, when the system is sleeping (TPL5110 DRV is off) current draw is less than 1uA (less than I can measure). The spec says around 50nA. The internal battery drain is probably more than this, so in effect it uses zero power when sleeping.

    After getting all this to work I am second guessing my approach. I am not sure of the reliability of the TPL5110 board and if it fails to turn on the system you are hosed with no possible recovery short of manual intervention. Since this will be in a remote hard-to-access location, I am leaning toward using the Teensy deep sleep (snooze library) to power down the Teensy, and a MOSFET to turn off the other system devices (like the breakout board does) under control of the Teensy. Then the sleep intervals can be under software control and can be varied if needed without hardware intervention. From a power consumption point of view, my measurements show I can get the Teensy down to about 60uA during hibernate. That is 1000 times more than the TPL5110 but doing the math... if the system has even a small battery (2600mAh), this .06mA drain is 43,333 hours (about 5 years). So in effect, it does not matter and I can use the software solution with more flexibility and less hardware. BTW my Teensy current measurements (5V supply) were:

    38mA
    - Running, status LED on
    1.2mA
    - Sleep, status LED off
    0.27mA
    - Deep Sleep, status LED off
    0.058mA
    - Hibernate, status LED off

    Still experimenting with the TPL5110 and the Snooze library to determine which is best for this application. I would be interested in anyone else's experience with this...
    Last edited by ct1; 09-24-2021 at 08:08 PM. Reason: Typos

  12. #12
    Junior Member
    Join Date
    Sep 2019
    Posts
    3
    I use a TPL5110 on almost everything (usually with a Teensy LC) and love them. When I first started, I was using the Adafruit breakout board and it worked great until I started adding features to the system and the timer started failing to wake up. Increasing the length of the wires to a radio from a few inches to a few feet finally caused the timer to fail reliably. The TPL datasheet calls for a bypass capacitor and neither the Adafruit nor the Sparkfun board has one. Adding one solved the problem. I have finally settled on two - 47 uF and 100 nF and the TPL5110 works reliably for me now. When changing the resistance (ie, the time interval), you have to remove power from the chip and discharge the capacitors.
    I've measured the current draw when off at ~30 nA (if I recall correctly).

  13. #13
    Junior Member
    Join Date
    Aug 2018
    Posts
    12
    So my conclusion is that the TPL5110 is a useful device, but for my application I will use deep sleep/hibernate on the Teensy and use a digital output pin to drive this device:

    https://rocelec.widen.net/view/pdf/v...03590112-1.pdf

    which will turn on/off the radio and sensor modules as needed, much like the TPL5110 but under processor control. This devices is basically a MOSFET switch, but designed to be driven from digital logic and it has some overcurrent/short circuit protection and thermal shutdown.

    The biggest benefit for my application is that the Teensy will retain memory state between cycles so my remote sensor can be much smarter. E.g. if transmit of the data fails (maybe the host receiver is down), the Teensy can hold the sensor data until the next cycle and attempt to re-transmit it. If the Teensy is powered off between cycles it loses state. (There is some EE memory in the Teensy, but only 2k bytes).

Posting Permissions

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