audio library wakes up teensy from hibernate

dsmoniker

New member
I'm trying to use the snooze library (button wakeup demo) with the teensy audio library. When audio objects are instantiated, they wake the teensy up ( ~ every 1sec) so snooze doesn't work as expected. If I try and nest the audio objects in the main loop hibernate works but audio doesn't. I tried wrapping hibernate with disabling/reenabling interrupts on the audio library but that didn't seem to work. Any ideas?

Thanks
Dave


// using teensy 3.6
// snooze 6.2.8
// teensyduino 1.3.6

Code:
#include <Snooze.h>
#include <Bounce.h>

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// Audio
AudioPlaySdWav           playSdWav1;
AudioOutputI2S           i2s1;
AudioConnection          patchCord1(playSdWav1, 0, i2s1, 0);
AudioConnection          patchCord2(playSdWav1, 1, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;


// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  7
#define SDCARD_SCK_PIN   14

// Buttons
#define BT_PLAY_PAUSE 21
#define BT_NEXT 38
#define BT_PREV 37

#define START_HOLD_TIME 3000
#define STOP_HOLD_TIME 1000

#define STATE_WAIT 0
#define STATE_PLAY 1

#define LED 13

// use bounce for pin 21, debounce of 5ms
Bounce bt_play_pause = Bounce(BT_PLAY_PAUSE, 5);
//Bounce bt_next = Bounce(BT_PREV, 5);
//Bounce bt_prev = Bounce(BT_NEXT, 5);


SnoozeDigital digital;

// install drivers to a SnoozeBlock
SnoozeBlock config(digital);


void setup() {
  //Serial.begin(9600);
  
  // Configure pins for bounce library
  pinMode(21, INPUT_PULLUP);
  pinMode(LED, OUTPUT); 

  //pinMode(BT_NEXT, INPUT_PULLUP);
  //pinMode(BT_PREV, INPUT_PULLUP);

  //while (!Serial);
  delay(2000);

 

 //pin, mode, type
  digital.pinMode(21, INPUT_PULLUP, FALLING);

    
}

int current_index = 0;  // while file to play

const char * filelist[10] = {
  "SONG1.WAV", "SONG2.WAV", "SONG3.WAV", "SONG4.WAV", "SONG5.WAV",
  "SONG6.WAV", "SONG7.WAV", "SONG8.WAV", "SONG9.WAV", "SONG10.WAV"
};

      

void loop() {
  
	// if start button not held for 3 sec go back here to sleep.
	SLEEP:
      digitalWrite(LED, HIGH);
      delay(100);
      digitalWrite(LED, LOW);
      
      Serial.println("sleep() again delay 3s");
      delay(3000);

      // you need to update before sleeping.
      bt_play_pause.update();

 
 	  //AudioNoInterrupts();
	 
      int who = Snooze.hibernate(config, SLEEP_MODE::VLLS1);

	  //AudioInterrupts();
	  
      //while (!Serial);
      Serial.print("wakeup.. who=");Serial.print(who);

      
      elapsedMillis timeout = 0;
      // bounce needs to call update longer than the debounce time = 5ms,
      // which is set in constructor.
      while (timeout < 6) bt_play_pause.update();
    
      
	    // now check for start button hold
	    bool wake_state = pollWakeupState();    

	    // if button not held for 3 seconds go back to sleep
	    if (!wake_state) {
	      Serial.println("Button not held long enough ...");
        digitalWrite(LED, LOW);
        delay(100);
        digitalWrite(LED, HIGH);
	      goto SLEEP;
	    }


// If try and move audio down here it compiles but doesn't work. Snooze works as expected..
//AudioPlaySdWav           playSdWav1;
//AudioOutputI2S           i2s1;
//AudioConnection          patchCord1(playSdWav1, 0, i2s1, 0);
//AudioConnection          patchCord2(playSdWav1, 1, i2s1, 1);
//AudioControlSGTL5000     sgtl5000_1;
     
      AudioMemory(8);
  
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
      SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);
      if (!(SD.begin(SDCARD_CS_PIN))) {
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }

      // Todo - read file list from SD card?

      // sd card, wake state
      Serial.println("SD=ok;WS="); Serial.println(wake_state);
      delay(5);
  

      elapsedMillis elapsedTime = 0;

      Serial.println("START:mainLoop");

      bool first = true;
      
	    while (1) {
	    
  	    // if play pause button pressed
  		   bt_play_pause.update();

         if (bt_play_pause.fallingEdge() || first) {

          first = false;
     
          Serial.println("Play update");
      	  const char *filename = filelist[current_index];
  			   
  			  if (playSdWav1.isPlaying() == true) {
             Serial.print("stop playing: ");Serial.println(filename);
  				   playSdWav1.stop();
  			      // reset elapsed time to 0?
  		  	} else {
  		  		// - if paused then play 
  			    playSdWav1.play(filename);    
 
            Serial.print("Start playing: ");Serial.println(filename);   
          } 
        
  		} // end if update  


        // back to sleep after 5 minutes (60000x5)
        if (elapsedTime > 60000) {
            Serial.println("sleeping after 5 mins idle time");
   
            goto SLEEP;
        }

        if (elapsedTime % 5 == 0) {
        
          digitalWrite(LED, HIGH);
          delay(100);
          digitalWrite(LED, LOW);
        }
        delay(100);
        //Serial.println("Next iteration");
        //Serial.printf("Loop Time  in ms: %i \n", elapsedTime);
    } // end while 1 (main loop)
}


bool pollWakeupState() {

     
    // start hold time button press check
    while (bt_play_pause.duration() < 1000) {
  
        // get current pin state
        bt_play_pause.update();
        
        // check the pin state, if button not
        // pressed before <hold_time> seconds go back to
        // sleep. Read 0 since pin is
        // configured as INPUT_PULLUP.
    
        if (bt_play_pause.read() != 0) {
		        digitalWrite(LED, HIGH);
            delay(100);
            digitalWrite(LED, LOW);
            delay(100);
            digitalWrite(LED, HIGH);
          
            return false;
        }
    }
	
    digitalWrite(LED, LOW);

    // button was held for 3 seconds so now we are awake
    return true;
}
 
Last edited:
I'm trying to use the snooze library (button wakeup demo) with the teensy audio library. When audio objects are instantiated, they wake the teensy up ( ~ every 1sec) so snooze doesn't work as expected.
Not sure what going here, I'll have to look at this. So if you call any of the Audio Library Objects support functions before you go into Hibernate it will wake up after 1 second. What version of Snooze do you have? I'll take a look at your sketch to see what the hell is going on:).

If I try and nest the audio objects in the main loop hibernate works but audio doesn't. I tried wrapping hibernate with disabling/reenabling interrupts on the audio library but that didn't seem to work. Any ideas?
I2S signals will not start backup after going into Hibernate or DeepSleep, I have known about this for a while but haven't fixed it yet since I haven't used the Audio Adapter with Snooze yet. The same happens with the PDB that the Audio library uses which I fixed but unfortunately the I2S is still an issue. I'll look at this in the next week and see if I can expand the SnoozeAudio driver for I2S also.

On side note, can you in the future when posting code use the "code tags", it makes it so much easier to read since it keeps the indentations and format in place.
 
@duff thanks for taking a look at it. The version of snooze I'm using is 6.2.8. I fixed the code issue and learned something new :)
 
I am facing exactly the same issue, but have no idea how to adapt the library.
@dsmoniker: Could you please share your fix?
Thank you!
 
@Saskia I was waiting to see if @duff would be able to provide more insight. The code issue I mentioned in the above post was just in related to posting a code block to this thread. The underlying issue still exists when using snooze with the audio library.
 
@Saskia I was waiting to see if @duff would be able to provide more insight. The code issue I mentioned in the above post was just in related to posting a code block to this thread. The underlying issue still exists when using snooze with the audio library.
I'm working on a bunch of things for Snooze currently and I want to help but your example needs some work like declaring Audio Objects correctly. Does your example work if there is no sleeping involved, I can't follow what you trying to do, can explain what you want to do?
 
I have generated this short sketch to illustrate the observed behaviour.
The audio objects are not used, there are just the audio object instances in the code.

Without the audio objects the sleep mode works as expected.

Any suggestions what needs to be done differently?

Code:
#include <Audio.h> //v1.3
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

#include <Snooze.h> //v6.2.8

AudioPlaySdWav          playSdWav;
AudioOutputI2S			lineOut;
AudioConnection         patchCord1(playSdWav, 0, lineOut, 0);
AudioConnection         patchCord2(playSdWav, 0, lineOut, 1);
AudioControlSGTL5000    audioShield;

SnoozeTimer snoozeTimer;
SnoozeUSBSerial snoozeUSB;
SnoozeAudio snoozeAudio;
SnoozeBlock config_teensy36(snoozeTimer, snoozeUSB, snoozeAudio);

void blink(int count = 1) {
	for (int i = 0; i < (count > 0 ? count : 1); i++) {
		digitalWrite(LED_BUILTIN, HIGH);
		delay(50);
		digitalWrite(LED_BUILTIN, LOW);
		delay(50);
	}
}

void setup() {
	AudioMemory(10);
	Serial.begin(9600);
	delay(200);
	pinMode(LED_BUILTIN, OUTPUT);
	Serial.println("Setup...");
	snoozeTimer.setTimer(15000);
	delay(200);
}

void loop() {
	//int who = Snooze.deepSleep(config_teensy36); //Teensy calls setup() after approx. one second
	//int who = Snooze.hibernate(config_teensy36); //Teensy calls setup() after approx. one second
	int who = Snooze.sleep(config_teensy36);       //Teensy continues after approx. one second with who=-1, instead of 15s sleep
	while (!Serial);
	delay(200);
	Serial.println((String)who + " wakeup...");
	blink(who);
	delay(200);
}
 
I'm sorry for pushing older threats, but I came across the same problem and haven't found a solution yet.
The code below produces the issue:

Code:
#include <Wire.h>
#include <SPI.h>
#include <SerialFlash.h>
#include <Snooze.h>
#include <Audio.h>

AudioInputI2S            i2s1;

SnoozeDigital digital;
SnoozeBlock config_t36(digital);

const uint8_t wake = 2;

void setup() {
  AudioMemory(60);
  digital.pinMode(wake, INPUT, RISING);       //wake-up done manually by connecting pin 2 to 3.3V
  pinMode(10, OUTPUT);                        //LED to check if Teensy woke up
  Serial.begin(115200);
  while (!Serial);
  Serial.println("Setup");
}

void loop() {
  Serial.println("Loop");
  uint8_t who;
  delay(10);
  who = Snooze.deepSleep(config_t36);
  if (who == wake) {
    digitalWrite(10, HIGH);
    delay(400);
    digitalWrite(10, LOW);
  }
}

This restarts the serial monitor over and over again approx. every second although the wake-pin is not triggered, producing the following output:
Code:
Setup
Loop
So it looks like the setup()-function is executed every time the Teensy wakes up.

Removing the line:
Code:
AudioInputI2S            i2s1;
fixes the problem. I also tried to instantiate the I2S object inside the loop() function:
Doing this outside the if-loop produces the same issue as before.
Doing this inside the if-loop does not produce the same issue, but the Teensy won't return to sleep, as soon as it was woken up by the wake-pin.

Are there any solutions or ideas?

Regards, Julian
 
I'll take a look at this next week, I'm out of town now.


Duff,
I observed similar behavior on a snooze derivative I'm using in my code
switching of the I2S clock
Code:
    SIM_SCGC6 &= ~SIM_SCGC6_I2S;
solved the problem for me
 
Thanks WMXZ for the solution, I haven't been able to do much on the Teensy stuff lately since I bought a house and home improvement projects take up all my time now a days:) One thing I would say is you would need to enable the I2S clock after waking also. I was working on the Teensy Audio Board sleep modes but never got them into Snooze library.
 
Great, it's working! Thank you WMXZ and duff.

You have to enable the I2S-clock after the wake up:
Code:
SIM_SCGC6 |= SIM_SCGC6_I2S;
worked for me!
 
yes, you have to add this code after wake-up, when code resumes.
(in my case, hibernate is deepest and program does not resume at the location where hibernate is called, but restarts the whole program. So this is not necessary, in all other cases, yes)
 
Hello again,

I just encountered another problem with my system, when I tested it outside "in the field".

The actual program is quite "simple":

1. Teensy wakes up triggered by a motion sensor.
2. Stereo sound is recorded and saved on a uSD card as long as there is a motion detected.
3. When there is no motion the recording is stopped and Teensy goes back to sleep.

This worked perfectly when I tested it in front of my desk. After testing it outside for more than 24 hours I saw that some recordings have a beeping sound which sometimes interferes with the recorded sound and sometimes is present without any other sounds. By now the first recordings are perfectly. After an inconstant time the beeping sound appears which sometimes also disappears again so that subsequent recordings are good again. The beeping occurs from one recording to another and not during a recording. Here is an example: https://drive.google.com/open?id=1K7h4kr8uHtCE-QZAt85b8XLvRco1ewj6

I don't really know where to begin, as I don't see a regularity :(

I also attached a spectrogram of the sound which shows that there is a bunch of overlapping frequencies.

Any ideas what is going wrong there?

Best regards,
Julian
 

Attachments

  • spectrogram_beep.jpg
    spectrogram_beep.jpg
    101.1 KB · Views: 146
Julian,
My hunch is that you modulate your audio signal with an other signal.
looking into the power spectrum (or time series) I would say that the modulation frequency is about 690 Hz)

This is suspiciously related with the audio block update rate (690 = 44100/(128/2))

There are two different possibilities for modulation.
- digital cable close and parallel to analog lines (including V+ to microphone)
- poorly filtered V+ to microphone

you did not say anything on te HW you are using
maybe you could describe in detail and also a picture of the system in the field would help.

Walter
 
Hey Walter,

you did not say anything on te HW you are using

Oops, you're right... I am using a Teensy 3.6 with the builtin SD slot, two ICS43434 digital microphones, a Bosch BME 280 environment sensor and a PCF8523 RTC on a single PCB.
Teensy wakes up by the trigger of a motion sensor. It grabs date and time from the RTC and creates a new file with the current date/time (DDHHMMSS.WAV) and records stereo sound while the motion sensor detects something.
After that Teensy is put back to sleep. Every 30 minutes it wakes up by timer and logs temperature and humidity.

What I found out via testing this weekend:
When I don't use the sleep mode, the recordings are fine! :confused:
I tried a lot of different configurations, e.g. leaving out both the RTC and environment sensor and also just one of them, leaving out the wake-up by the timer, adding some 10uF capacitors between V+ and GND, adding the missing pull-down resistor for the i2S clock, etc. ...
Every time I had the beeping sound occurring sometimes after 30 minutes, sometimes after an hour. Doesn't that speak against a HW-problem?
Just leaving out the sleep mode was successful. Instead of going to sleep, Teensy is simply hanging in a while-loop waiting for the trigger to start a measurement.
I'll try out sleep instead of deepSleep maybe..

Best regards,
Julian
 
Sure, this is the code that produces the beeping sound:

Code:
#include <Wire.h>
#include <SPI.h>
#include <SerialFlash.h>
#include <Snooze.h>
#include <SD.h>
#include <Audio.h>
#include <RTClib.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define SEALEVELPRESSURE_HPA (1013.25)
//#define FILE_BASE_NAME "Stereo"
#define CS_PIN BUILTIN_SDCARD

/////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// Object Initializing ////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

// GUItool: begin automatically generated code
AudioInputI2S            i2s1;           //xy=168,145
AudioRecordQueue         queue1;         //xy=360,62
AudioRecordQueue         queue2;         //xy=389,145
AudioConnection          patchCord1(i2s1, 0, queue1, 0);
AudioConnection          patchCord2(i2s1, 1, queue2, 0);
// GUItool: end automatically generated code
SnoozeDigital digital;
SnoozeTimer timer;
SnoozeBlock config_teensy36(digital);
File frec;
Adafruit_BME280 bme;
RTC_PCF8523 rtc;

/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////      Constants      ////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

const uint8_t Teensy = 2;
const uint8_t PIR1_IR = 24;
const char temp_log_file[12] = "temphum.txt";
uint8_t mode = 0;
uint8_t led = 28;
uint16_t rec_interval = 2400;
volatile uint32_t rec_start;

uint32_t ChunkSize = 0L;
uint32_t Subchunk1Size = 16;
uint8_t AudioFormat = 1;
uint8_t numChannels = 2;
uint32_t sampleRate = 44100;
uint8_t bitsPerSample = 16;
uint32_t byteRate = sampleRate * numChannels * (bitsPerSample / 8); // samplerate x channels x (bitspersample / 8)
uint16_t blockAlign = numChannels * bitsPerSample / 8;
uint32_t Subchunk2Size = 0L;
uint32_t recByteSaved = 0L;
uint32_t NumSamples = 0L;
byte byte1, byte2, byte3, byte4;

/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////      Functions      ////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

void ISR1() {
  rec_start = millis();
}


void startRecording() {
  DateTime now = rtc.now();
  char fileName[18];
  sprintf(fileName, "%02u%02u%02u%02u.WAV", now.day(), now.hour(), now.minute(), now.second());
  frec = SD.open(fileName, FILE_WRITE);
  if (frec) {
    queue1.begin();
    queue2.begin();
    recByteSaved = 0L;
  }

}


// write all 512 bytes to the SD card
void continueRecording() {
  if (queue1.available() >= 2 && queue2.available() >= 2) {
    byte buffer[512]; // data to write
    mxLR(buffer, queue1.readBuffer(), queue2.readBuffer()); // interleave
    queue1.freeBuffer();
    queue2.freeBuffer();  // free buffer
    frec.write(buffer, 512);
    recByteSaved += 512;
  }
}

void stopRecording() {
  queue1.end();
  queue2.end();
  // flush buffer
  while (queue1.available() > 0 && queue2.available() > 0) {
    queue1.readBuffer();
    queue1.freeBuffer();
    queue2.readBuffer();
    queue2.freeBuffer();
  }
  queue1.clear();
  queue2.clear();
  writeOutHeader();
  frec.close(); // close file
}

inline void mxLR(byte *dst, const int16_t *srcL, const int16_t *srcR)
{
  byte cnt = 128;
  int16_t *d = (int16_t *)dst;
  const int16_t *l = srcL;
  const int16_t *r = srcR;

  while (cnt--)
  {
    *(d++) = *l++;
    *(d++) = *r++;
  }
}


void temp_log() {
  DateTime now = rtc.now();
  char date[5];
  char rtc_time[9];
  if (now.minute() >= 0 && now.minute() < 30 && mode == 0) {
    sprintf(date, "%02u.%02u", now.day(), now.month());
    sprintf(rtc_time, "%02u:%02u:%02u", now.hour(), now.minute(), now.second());
    frec = SD.open(temp_log_file, FILE_WRITE);
    if (frec) {
      frec.print(date);
      frec.print("\t");
      frec.print(rtc_time);
      frec.print("\t");
      frec.print(bme.readTemperature());
      frec.print("\t");
      frec.println(bme.readHumidity());
    }
    frec.close();
    mode = 1;
  } else if (now.minute() >= 30 && mode == 1) {
    sprintf(date, "%02u.%02u", now.day(), now.month());
    sprintf(rtc_time, "%02u:%02u:%02u", now.hour(), now.minute(), now.second());
    frec = SD.open(temp_log_file, FILE_WRITE);
    if (frec) {
      frec.print(date);
      frec.print("\t");
      frec.print(rtc_time);
      frec.print("\t");
      frec.print(bme.readTemperature());
      frec.print("\t");
      frec.println(bme.readHumidity());
    }
    frec.close();
    mode = 0;
  }
}

void writeOutHeader() { // update WAV header with final filesize/datasize

  //  NumSamples = (recByteSaved*8)/bitsPerSample/numChannels;
  //  Subchunk2Size = NumSamples*numChannels*bitsPerSample/8; // number of samples x number of channels x number of bytes per sample
  Subchunk2Size = recByteSaved;
  ChunkSize = Subchunk2Size + 36;
  frec.seek(0);
  frec.write("RIFF");
  byte1 = ChunkSize & 0xff;
  byte2 = (ChunkSize >> 8) & 0xff;
  byte3 = (ChunkSize >> 16) & 0xff;
  byte4 = (ChunkSize >> 24) & 0xff;
  frec.write(byte1);  frec.write(byte2);  frec.write(byte3);  frec.write(byte4);
  frec.write("WAVE");
  frec.write("fmt ");
  byte1 = Subchunk1Size & 0xff;
  byte2 = (Subchunk1Size >> 8) & 0xff;
  byte3 = (Subchunk1Size >> 16) & 0xff;
  byte4 = (Subchunk1Size >> 24) & 0xff;
  frec.write(byte1);  frec.write(byte2);  frec.write(byte3);  frec.write(byte4);
  byte1 = AudioFormat & 0xff;
  byte2 = (AudioFormat >> 8) & 0xff;
  frec.write(byte1);  frec.write(byte2);
  byte1 = numChannels & 0xff;
  byte2 = (numChannels >> 8) & 0xff;
  frec.write(byte1);  frec.write(byte2);
  byte1 = sampleRate & 0xff;
  byte2 = (sampleRate >> 8) & 0xff;
  byte3 = (sampleRate >> 16) & 0xff;
  byte4 = (sampleRate >> 24) & 0xff;
  frec.write(byte1);  frec.write(byte2);  frec.write(byte3);  frec.write(byte4);
  byte1 = byteRate & 0xff;
  byte2 = (byteRate >> 8) & 0xff;
  byte3 = (byteRate >> 16) & 0xff;
  byte4 = (byteRate >> 24) & 0xff;
  frec.write(byte1);  frec.write(byte2);  frec.write(byte3);  frec.write(byte4);
  byte1 = blockAlign & 0xff;
  byte2 = (blockAlign >> 8) & 0xff;
  frec.write(byte1);  frec.write(byte2);
  byte1 = bitsPerSample & 0xff;
  byte2 = (bitsPerSample >> 8) & 0xff;
  frec.write(byte1);  frec.write(byte2);
  frec.write("data");
  byte1 = Subchunk2Size & 0xff;
  byte2 = (Subchunk2Size >> 8) & 0xff;
  byte3 = (Subchunk2Size >> 16) & 0xff;
  byte4 = (Subchunk2Size >> 24) & 0xff;
  frec.write(byte1);  frec.write(byte2);  frec.write(byte3);  frec.write(byte4);
  frec.close();

}


void led_blink(int error) {
  for (int i = 0; i < error; i++) {
    digitalWrite(led, HIGH);
    delay(100);
    digitalWrite(led, LOW);
    delay(100);
  }
}


/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////    Setup and Loop   ////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

void setup() {
  pinMode(Teensy, INPUT);
  AudioMemory(250);
  pinMode(PIR1_IR, INPUT);
  pinMode(led, OUTPUT);
  timer.setTimer(60000 * 30);
  attachInterrupt(digitalPinToInterrupt(PIR1_IR), ISR1, RISING);
  if (!(SD.begin(CS_PIN))) {
    while (1) {
      delay(1000);
    }
  }
  bool status = bme.begin();
  if (!status) {
    while (1) {
      delay(100);
    }
  }
  while (digitalRead(Teensy) == HIGH) {                //wait until the RTC line is lo longer used and free to be read (by another Teensy)
  }
  if (! rtc.begin()) {
    while (1) {
      delay(1000);
    }
  }
  digital.pinMode(Teensy, INPUT, RISING);
  led_blink(3);
}

void loop() {
  SIM_SCGC6 &= ~SIM_SCGC6_I2S;
  int who;
  who = Snooze.deepSleep(config_teensy36);
  SIM_SCGC6 |= SIM_SCGC6_I2S;
  if (who == Teensy) {
    rec_start = millis();
    startRecording();
    while (millis() - rec_start < rec_interval) {
      continueRecording();
    }
    stopRecording();
    temp_log();
  }
  else if (who == 36) { //LP Timer wakeup = 36
    temp_log();
  }

}
 
Try putting a small delay after restarting the I2S after waking. Though I wonder how the Audio Board handles it's clock missing when in deepSleep, I haven't looked at that or much with the Audio board. Maybe there is more that needs to be done to put the Audio board in low power state before deepSleep or hibernate?

Maybe try killing the I2S clock and doing a while loop simulating sleeping and see if the same problem happens? It could also be an issue with the SD stuff to, I don't know?
 
Maybe try killing the I2S clock and doing a while loop simulating sleeping and see if the same problem happens? It could also be an issue with the SD stuff to, I don't know?

I tried this with and without a 10 ms delay, both resulted in empty sound files of 44 Byte file-size :confused:
BTW: I'm not using the Audio board.

@Theremingenieur: Any hints on where to find this and how to edit it?

Best regards,
Julian
 
Back
Top