Serial Print Not Working After Snooze deepSleep

Status
Not open for further replies.

ErkelByte

Member
I got sleep working thank you to the awesome people on this forum. However when it wakes up from a DS3231 RTC it refuses to print to the Serial monitor. The Serial Monitor rapidly flips between connected and disconnected. Please let me know what I'm doing wrong while trying to print.

Code:
/***************************************
 This shows all the wakeups for sleep
 Expect IDD of  around 1.2mA (Teensy 3.x)
 and IDD of around 900uA for (Teensy LC).
 
 Sleep is the most flexable and any
 interrupt can wake the processor.
 
 Touch interface does not work in sleep
 mode.
 ****************************************/
#include <Snooze.h>
// Load drivers
SnoozeDigital digital;
SnoozeCompare compare;
SnoozeTimer timer;
SnoozeAlarm  alarm;
// configures the lc's 5v data buffer (OUTPUT, LOW) for low power
Snoozelc5vBuffer  lc5vBuffer;
/***********************************************************
 Teensy 3.6/LC can't use Timer Driver with either Touch or
 Compare Drivers and Touch can't be used with Compare.
 
 Teensy 3.x/LC touch interface does not work with sleep.
 
 Teensy LC does not have a rtc so Alarm driver can't be
 used as of yet.
 
 Teensy 3.2 can use any Core Drivers together.
 ***********************************************************/
SnoozeBlock config_teensyLC(digital, lc5vBuffer);

#include <DS3232RTC.h> 
DS3232RTC RTC(false);
int idx = 0;
void setup() {
    Serial.begin(9600);
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, HIGH);
    while(!Serial){}
    delay(5000);
    digitalWrite(LED_BUILTIN, LOW);
    Serial.println("Started v1.0.12");

    RTC.begin(); 

    setSyncProvider(RTC.get);   // the function to get the time from the RTC
    if(timeStatus() != timeSet)
        Serial.println("Unable to sync with the RTC");
    else
        Serial.println("RTC has set the system time");

    Serial.print(hour());
    Serial.print(':');
    Serial.print(minute());
    Serial.print(':');
    Serial.println(second());
    delay(10000);
    
    /********************************************************
     Define digital pins for waking the teensy up. This
     combines pinMode and attachInterrupt in one function.
     
     Teensy 3.x
     Digtal pins: all pins
     
     Teensy LC
     Digtal pins: all interrupt able pins
     ********************************************************/
    pinMode(21, INPUT_PULLUP);
    pinMode(22, INPUT_PULLUP);
    digital.pinMode(21, INPUT_PULLUP, RISING);//pin, mode, type
    digital.pinMode(22, INPUT_PULLUP, RISING);//pin, mode, type

    // setup alarm
    RTC.alarmInterrupt(ALARM_1, true);
    RTC.setAlarm(ALM1_MATCH_SECONDS, ((second() + 40) % 60), 0, 0, 1);
    RTC.squareWave(SQWAVE_1_HZ); 
    // clear the alarm flag
    RTC.alarm(ALARM_1);
}

void loop() {
    int who = 0; // what woke us up
    /********************************************************
     feed the sleep function its wakeup parameters. Then go
     to deepSleep.
     ********************************************************/
    who = Snooze.deepSleep( config_teensyLC );// return module that woke processor

    // wait for serial monitor
    elapsedMillis time = 0;
    while (!Serial && time < 1000) {
        Serial.write(0x00);// print out a bunch of NULLS to serial monitor
        digitalWriteFast(LED_BUILTIN, HIGH);
        delay(30);
        digitalWriteFast(LED_BUILTIN, LOW);
        delay(30);
    }
    // normal delay for Arduino Serial Monitor
    delay(200);
    // print who woke the teensy up, i.e. timer || digital
    Serial.printf("Timer Driver number indicator: %i | index: %i\n", who, idx);
    delay(1000);
    idx++;
}
 
Status
Not open for further replies.
Back
Top