Go Down

Topic: Begin failed (Read 405 times) previous topic - next topic

dpoornima

Feb 06, 2018, 09:42 pm Last Edit: Feb 06, 2018, 09:44 pm by dpoornima
Hello ,

I am using  Sd card microbreakout board from adafruit and an 8 GB SD card from Sandisk.

Whenever I run my code:
Code: [Select]

#include <SPI.h>
#include <SdFat.h>
SdFat SD;
//#include<SD.h>;
#include <SoftwareSerial.h>
#include "Adafruit_Soundboard.h"

#define SFX_TX 5
#define SFX_RX 6
#define SFX_RST 4
SoftwareSerial ss = SoftwareSerial(SFX_TX, SFX_RX);
Adafruit_Soundboard sfx = Adafruit_Soundboard(&ss, NULL, SFX_RST);

#define FILE_BASE_NAME "Data"
#include <Wire.h>
#include <RTClib.h>
#include <float.h>

unsigned long time;
RTC_DS3231 rtc;
int chipSelect = 10;
File file;
int BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
char filename[] = FILE_BASE_NAME "00.csv";

//added button library, variables and button function
#include <Bounce2.h>
Bounce button = Bounce(); //instantiate a Bounce object

const byte LedPin = 9;
const byte ButtonPin = 7;
bool logFlag = true;//default status to enable SD writes in Loop


char testSFX[] = {"T01RAND1WAV"};


void buttonCheck()//debounced function to check if button pressed
{
  button.update();
  if (button.fell())
  {
    if (logFlag == true)
    {
      logFlag = false;
      Serial.println();
      Serial.println("Data Logging in Loop Disabled");
      Serial.println("Press Reset to Enable");
      Serial.println();
    }
  }
}



void setup()
{
  Wire.begin(); // wake up I2C bus
  delay (500);
  Serial.begin(115200);
  Serial.println ("Sketch has started");

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

  pinMode (LedPin, OUTPUT);
  digitalWrite(LedPin, LOW);

  pinMode(ButtonPin, INPUT_PULLUP);
  button.attach(ButtonPin);
  button.interval(20);//20 ms debounce interval

  if (rtc.lostPower())
  {
    Serial.println("RTC lost power,set the time");
    rtc.adjust(DateTime(2017, 8, 21, 17, 10, 00));
  }
  delay(10);
  //pinMode(10, OUTPUT);
  //digitalWrite(10, HIGH);
  if (!SD.begin(10))
  {
    Serial.println(F("begin failed"));
    return;
  }

  while (SD.exists(filename)) {
    if (filename[BASE_NAME_SIZE + 1] != '9') {
      filename[BASE_NAME_SIZE + 1]++;
    }
    else if (filename[BASE_NAME_SIZE] != '9') {
      filename[BASE_NAME_SIZE + 1] = '0';
      filename[BASE_NAME_SIZE]++;
    }
    else {
      Serial.println(F("Can't create file name"));
      return;
    }
  }
  File file = SD.open(filename, FILE_WRITE);
  digitalWrite(LedPin, HIGH);//indicate file being written
  DateTime now = rtc.now();
  file.print(now.year(), DEC);
  file.print('/');
  file.print(now.month(), DEC);
  file.print('/');
  file.print(now.day(), DEC);
  file.print(',');
  file.print(now.hour(), DEC);
  file.print(':');
  file.print(now.minute(), DEC);
  file.print(':');
  file.print(now.second(), DEC);
  file.println();
  file.print("Time( ms)");
  file.print(',');
  file.println();
  file.close();
  digitalWrite(LedPin, LOW);//file write finished
}


The serial monitor prints :
Sketch has started
SFX board found
begin failed.

And the same code sometimes prints :
Sketch has started
SFX board found
Sketch has started
SFX board found
Sketch has started
SFX board found
continously.

I have the  SDcard breakput board connected to promini like this:
Arduino-Sdcardbreakout board
3V- 3V
GND-GND
13-CLK
12-D0
11-D1
10-CS

Can anyone help me figure out the solution?

Thank you!

ieee488

Not sure what you are trying to do.

Remove the code for the soundboard and just concentrate on the code for the SD card.

cattledog

Quote
I have the  SDcard breakput board connected to promini like this:
Arduino-Sdcardbreakout board
3V- 3V
GND-GND
13-CLK
12-D0
11-D1
10-CS
The constant resets are a symptom of a power problem.

There are 3v and 5v issues to sort out. Do you have a 3.3v pro mini or a 5v promini?

What are you conecting 3v - 3v? Where are you getting the 3v from? I'm not sure you can take the 3V output from a 5V promini and get enough supply current.

As I understand the adafruit SD module, it usually takes a 5v input to an onboard regulator.

The power draw when writing to the card can be fairly high, up to 100mA (or more)! That means that you must have a fairly good 3.3V power supply for the card. 

Please explain more about your wiring.

dpoornima

#3
Feb 09, 2018, 06:32 pm Last Edit: Feb 09, 2018, 06:34 pm by dpoornima
Hello,

I have a 3.3V promini. I connected the 3V pin on the Sd card to the VCC pin of the pro mini(3.3 V)

Thank you!

cattledog

It still sounds like a power problem. With some promini's you can only get 150 ma in total through them.

Do you see the issue without the soundboard?

I would try to power the sd card independently from the pro mini. Make sure the grounds are connected.

dpoornima

I connected the soundboard with a Li battery. Soundboard is not being powered by promini.Only the Sd card is being powered by the promini.

I will try to power the Sd card seperately too and check.

Thank you!

CrossRoads

SD cards need more current than the 150mA that the Promini can supply.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up