Adafruit Soundboard No Found 🔊[RESOLVED... Thank you Jeff!]

Hey everybody,

I’m trying to run my Adafruit soundboard using this code I copy and pasted from the Adafruit website:

#include <SoftwareSerial.h>
#include "Adafruit_Soundboard.h"


// Choose any two pins that can be used with SoftwareSerial to RX & TX
#define SFX_TX 7
#define SFX_RX 12

// Connect to the RST pin on the Sound Board
#define SFX_RST 4


// we'll be using software serial
SoftwareSerial ss = SoftwareSerial(SFX_TX, SFX_RX);

// pass the software serial to Adafruit_soundboard, the second
// argument is the debug port (not used really) and the third 
// arg is the reset pin

Adafruit_Soundboard sfx = Adafruit_Soundboard(&ss, NULL, SFX_RST);



void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit Sound Board!");
  
  // softwareserial at 9600 baud
  ss.begin(9600); 
  
  if (!sfx.reset()) {
    Serial.println("Not found");
    while (1);
  }
  Serial.println("SFX board found");
}


void loop() {
  flushInput();
  
  Serial.println(F("What would you like to do?"));
  Serial.println(F("[r] - reset"));
  Serial.println(F("[+] - Vol +"));
  Serial.println(F("[-] - Vol -"));
  Serial.println(F("[L] - List files"));
  Serial.println(F("[P] - play by file name"));
  Serial.println(F("[#] - play by file number"));
  Serial.println(F("[=] - pause playing"));
  Serial.println(F("[>] - unpause playing"));
  Serial.println(F("[q] - stop playing"));
  Serial.println(F("[t] - playtime status"));
  Serial.println(F("> "));
  
  while (!Serial.available());
  char cmd = Serial.read();
  
  flushInput();
  
  switch (cmd) {
    case 'r': {
      if (!sfx.reset()) {
        Serial.println("Reset failed");
      }
      break; 
    }
    
    case 'L': {
      uint8_t files = sfx.listFiles();
    
      Serial.println("File Listing");
      Serial.println("========================");
      Serial.println();
      Serial.print("Found "); Serial.print(files); Serial.println(" Files");
      for (uint8_t f=0; f<files; f++) {
        Serial.print(f); 
        Serial.print("\tname: "); Serial.print(sfx.fileName(f));
        Serial.print("\tsize: "); Serial.println(sfx.fileSize(f));
      }
      Serial.println("========================");
      break; 
    }
    
    case '#': {
      Serial.print("Enter track #");
      uint8_t n = readnumber();

      Serial.print("\nPlaying track #"); Serial.println(n);
      if (! sfx.playTrack((uint8_t)n) ) {
        Serial.println("Failed to play track?");
      }
      break;
    }
    
    case 'P': {
      Serial.print("Enter track name (full 12 character name!) >");
      char name[20];
      readline(name, 20);

      Serial.print("\nPlaying track \""); Serial.print(name); Serial.print("\"");
      if (! sfx.playTrack(name) ) {
        Serial.println("Failed to play track?");
      }
      break;
   }

   case '+': {
      Serial.println("Vol up...");
      uint16_t v;
      if (! (v = sfx.volUp()) ) {
        Serial.println("Failed to adjust");
      } else {
        Serial.print("Volume: "); Serial.println(v);
      }
      break;
   }

   case '-': {
      Serial.println("Vol down...");
      uint16_t v;
      if (! (v=sfx.volDown()) ) {
        Serial.println("Failed to adjust");
      } else { 
        Serial.print("Volume: "); 
        Serial.println(v);
      }
      break;
   }
   
   case '=': {
      Serial.println("Pausing...");
      if (! sfx.pause() ) Serial.println("Failed to pause");
      break;
   }
   
   case '>': {
      Serial.println("Unpausing...");
      if (! sfx.unpause() ) Serial.println("Failed to unpause");
      break;
   }
   
   case 'q': {
      Serial.println("Stopping...");
      if (! sfx.stop() ) Serial.println("Failed to stop");
      break;
   }  

   case 't': {
      Serial.print("Track time: ");
      uint32_t current, total;
      if (! sfx.trackTime(&current, &total) ) Serial.println("Failed to query");
      Serial.print(current); Serial.println(" seconds");
      break;
   }  

   case 's': {
      Serial.print("Track size (bytes remaining/total): ");
      uint32_t remain, total;
      if (! sfx.trackSize(&remain, &total) ) 
        Serial.println("Failed to query");
      Serial.print(remain); Serial.print("/"); Serial.println(total); 
      break;
   }  

  }
}






/************************ MENU HELPERS ***************************/

void flushInput() {
  // Read all available serial input to flush pending data.
  uint16_t timeoutloop = 0;
  while (timeoutloop++ < 40) {
    while(ss.available()) {
      ss.read();
      timeoutloop = 0;  // If char was received reset the timer
    }
    delay(1);
  }
}

char readBlocking() {
  while (!Serial.available());
  return Serial.read();
}

uint16_t readnumber() {
  uint16_t x = 0;
  char c;
  while (! isdigit(c = readBlocking())) {
    //Serial.print(c);
  }
  Serial.print(c);
  x = c - '0';
  while (isdigit(c = readBlocking())) {
    Serial.print(c);
    x *= 10;
    x += c - '0';
  }
  return x;
}

uint8_t readline(char *buff, uint8_t maxbuff) {
  uint16_t buffidx = 0;
  
  while (true) {
    if (buffidx > maxbuff) {
      break;
    }

    if (Serial.available()) {
      char c =  Serial.read();
      //Serial.print(c, HEX); Serial.print("#"); Serial.println(c);

      if (c == '\r') continue;
      if (c == 0xA) {
        if (buffidx == 0) {  // the first 0x0A is ignored
          continue;
        }
        buff[buffidx] = 0;  // null term
        return buffidx;
      }
      buff[buffidx] = c;
      buffidx++;
    }
  }
  buff[buffidx] = 0;  // null term
  return buffidx;
}
/************************ MENU HELPERS ***************************/

However, when I run this exact code, It says my soundboard can’t be found:

Can you help me isolate the issue? I’m not sure whether this issue is a coding issue, soldering issue (I soldered the RX TX and RST pins), or something else?

Do you have any guidance on how to troubleshoot and find out what the exact problem is?

Here’s my wiring for reference:

Thank you everybody!

3 Likes

The wiring diagram, the image and the code in the tutorial indicates 5 and 6 for TX and RX, but the code you have posted uses 7 and 12. Either change the wiring to match the code, or change the code to match the wiring, and see what the effect is.

4 Likes

Thank you Jeff!

Good pick up!

My bad, I didn’t update my wiring to reflect my actual drawing.

I ran the code you see with this wiring, and it says “Not Found” on the serial monitor.

Do you have any recommendations on how I can start troubleshooting to find the reason why it can’t be found?

Whether you think it may be a code issue? soldering issue? Maybe I could even use my multimeter to measure something?

Thank you.

2 Likes

Your wiring diagram still doesn’t quite match the code - the diagram indicates 11 not 12 for the RX. You can certainly check the 5v and Gnd on the module with the multimeter (Gnd will probably read a few millivolts) but more than that is difficult. Depending on the multimeter you could look at TX and you might see a flicker as it tries to communicate, but you can’t rely on it.

You can do a partial check on the soldering by measuring the voltage at different points along a connection. The voltage from any point back to the starting point should be the same, within a few millivolts. This isn’t entirely reliable (for some signals, simply putting a finger on the probe can alter the reading) but might indicate any major problem.

There are two things you can do in software: both are hopeful rather than scientific. One is to insert a delay after starting the sofware serial object, and before trying to initialise the board: The other is to comment out the halt if the initialising fails and plow ahead regardless. This second tactic has worked for me with a different board, but that was a cheap knockoff and the AdaFruit product is likely to be less forgiving.

  // softwareserial at 9600 baud
  ss.begin(9600); 
  delay(500);
  if (!sfx.reset()) {
    Serial.println("Not found");
    // while (1);
  }
  Serial.println("SFX board found");
4 Likes

jeff
your code worked
HALLULUJEHA! it worked!

thank you so much you arduino wizard!! :mage:

i was about to throw in the towel, give up on my soundboard, move to a new city, start a new life if it didn’t work.

all joking aside.

may i ask why the delay worked? is it because the arduino needs time to process the code?

3 Likes

Glad to hear you got it working. Sometimes these things are as much a black art as they are technical expertise.

But I hope it really is working - I didn’t make it clear, but commenting out that while (1); line will give you the success message, even if it didn’t succeed!

Some Arduino boards require the delay, but not usually the UNO or Mega. But the idea for trying it comes from experience with those other boards. Another possibility is that the soundcard does some sort of checking of the serial data before it can respond properly - it would only have to miss one or two characters for the initialisation sequence not to be recognised.

3 Likes

thank you jeff! :smiley:

agreed with the black art part. sometimes i change a piece of the code that doesn’t make any logical sense, and something seems to work again.

maybe i need to get a degree in wizardry instead of electrical engineering.

1 Like