Rebooting After 13 Seconds, Programming Bug?

Nano 33 IOT is rebooting constantly after 13 seconds when I start playing audio via audiozero library. i have stripped pretty much everything from my script in an attempt to identify the cause of the reboot and it seems to be related to running both " AudioZero.play(myFile);" and the arduino cloud update/OnCloudChange at the same time. both of these work fine on their own and if i comment out either one i don't get the reboot but if they are both there the device will reboot every 13 seconds. When it reboots it does get through the script, the audio plays but only for a few seconds and the it powers off and back on. if i remove the cloud stuff it will play the audio all they way through the 2min WAV. if i remove the play command from audiozero it will stay up and online (connected to the WIFI) indefinitely.

could this be a bug in the audiozero library? i have never had trouble with it but this is the first time i have tried to use it in conjunction with the Arduino cloud stuff.

#include <SD.h>
#include <SPI.h>
#include <AudioZero.h>
#include "thingProperties.h"

void setup() {
   // debug output at 115200 baud
  Serial.begin(115200);

  // setup SD-card
  Serial.print("Initializing SD card...");
  if (!SD.begin(4)) {
    Serial.println(" failed!");
    while(true);
  }
  Serial.println(" done.");


  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 

  int count = 0;

  // open wave file from sdcard
  File myFile = SD.open("rain.wav");
  // 44100kHz stereo => 88200 sample rate
  AudioZero.begin(2*44100);
  if (!myFile) {
    // if the file didn't open, print an error and stop
    Serial.println("error opening rain.wav");
    while (true);
  }

  Serial.print("Playing");
  
  // until the file is not finished  
  AudioZero.play(myFile);
//  AudioZero.close();
  Serial.println("End of file. Thank you for listening!");
  while (true) ;
}


void onCloudChange() {
  // Do something
}

Sounds like a power issue.

One thing I see is the Autozero object is recreated every time you go through your loop. I wouldn't be surprised if repeated creation chews up some memory.

Suggestion: Always assume the libraries are not the issue, until you can boil the code down to so simple its nearly obvious the library has an issue.
The reason is, as soon as you start thinking the library is at fault you reduce your focus on it still being with your code.

i am powering the nano via a 5v 4a power supply to the 5v pin. i might try powering it via a 3.3v and powering things like the 5v audio amp separate.

One thing I see is the Autozero object is recreated every time you go through your loop. I wouldn't be surprised if repeated creation chews up some memory.
Suggestion: Always assume the libraries are not the issue, until you can boil the code down to so simple its nearly obvious the library has an issue.
The reason is, as soon as you start thinking the library is at fault you reduce your focus on it still being with your code.

good point, i will take a look at that!

Might this trigger a watchdog?

If the watchdog fuse is set, he will need to do more than break the infinite loop.

There is now a software watchdog timer built into the ArduinoIoTCloud library:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.