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

Thread: Teensy 4.0 freezes using Snooze and EEPROM.put

  1. #1
    Junior Member
    Join Date
    Jan 2021
    Posts
    3

    Teensy 4.0 freezes using Snooze and EEPROM.put

    I'm trying to use Snooze to drop the Teensy power usage. I only need the device to "turn on" every 10 minutes to log it's current GPS location. I'm not seeing much drop in mA when in sleep mode. It's hanging around 100mA. It will bounce up when it wakes up to get the GPS data (150mA). I was hoping to get it lower than 100mA. Anyway, that's not the main issue. Once it wakes up and gets the GPS data, it will right it to the eeprom. I'm using the built in LED to track this and once it writes to the eeprom the LED should turn off, but it doesn't.

    Here is what I'm working with:

    Code:
    #include <TinyGPS.h>
    #include <EEPROM.h>
    #include <Snooze.h>
    
    TinyGPS gps;
    
    int eeAddress = 0;
    struct GPScord {
      float flat;
      float flon;
    };
    
    SnoozeDigital digital;
    SnoozeTimer timer;
    SnoozeUSBSerial usb;
    SnoozeAlarm  alarm;
    
    #if defined(__MKL26Z64__)
    Snoozelc5vBuffer  lc5vBuffer;
    #endif
    
    #if defined(__IMXRT1062__)
    SnoozeBlock config_teensy40(usb, digital, alarm);
    #endif
    
    
    void setup(){
      Serial.end();
      pinMode(LED_BUILTIN, OUTPUT);
      #if !defined(__MKL26Z64__)
      alarm.setRtcTimer(0, 0, 10);// hour, min, sec
      #endif
    
      while (eeAddress < 1060) {
        int who;
        
        #if defined(__IMXRT1062__)
        who = Snooze.sleep( config_teensy40 );
        #endif
        
        if (who == 35) { // rtc wakeup value 
          float flat, flon;
          delay(5000);
          gps.f_get_position(&flat, &flon);
          GPScord GPSvar = {flat, flon};
          eeAddress += sizeof(GPSvar);
      
          digitalWrite(LED_BUILTIN, HIGH);
          EEPROM.put(eeAddress, GPSvar);
          delay(500);                  
          digitalWrite(LED_BUILTIN, LOW);
          delay(500); 
          }
        }
    }
    void loop() {
    }
    I mostly just work with python so maybe I'm missing something simple? Any help would be appreciated.

  2. #2
    Junior Member
    Join Date
    Jan 2021
    Posts
    3
    Maybe there is another way I can reduce power without using Snooze?

  3. #3
    Junior Member
    Join Date
    Jan 2021
    Posts
    3
    I'm kind of stuck on this and I'm not sure where else to post this question. If I can provide some more details to help someone help me, please let me know.

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    200
    Hi,

    I don't claim to re any sort of expert but I see a number of possible problems.

    You have setup snooze to use digital and alarm - you have not used any digital input to wake up, so take the digital out from the snoozeblock setup. You are using alarm, which uses the rtc, but have not setup rtc anywhere.

    You seem to want to wake up every 10 seconds, so why not use timer to do that?

    timer.setTimer(10);// milliseconds - Seconds in Teensy4
    SnoozeBlock config_teensy40(usb, timer);

    I have used that and it worked fine. It may be that the GPS library is killing it.
    Try your code without the GPS and see if it works. Then put GPS in and see if it still works. If not GPS library is somehow killing the snooze library.

  5. #5
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    200
    I have confirmed that the Snooze Library Kills the EEProm library.
    Have raised the issue in "Suggestions and Bug Reports"

  6. #6
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    1,027
    Does it fail with deepSleep or hibernate too? Low power in the Teensy 4.0 is much more complicated than T3.x's, so getting Snooze to be solid for the 4.0 is going to take some more work on my end. As far as why the EEPROM is failing I have know idea at the moment but I'll figure something out.

  7. #7
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    200
    Both sleep and deepSleep fail. Have not tried hibernate as it does a reset each time which is not useful.

  8. #8
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    200
    Hi Duff, hope you and your family are well.
    I have posted a sample prog which demonstrates the problem under "suggestions and .....".

  9. #9
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    1,027
    Quote Originally Posted by BriComp View Post
    Hi Duff, hope you and your family are well.
    I have posted a sample prog which demonstrates the problem under "suggestions and .....".
    All is as good, thanks. I'll check it out.

Posting Permissions

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