0

SD Card Writing
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

SD Card Writing

by benniekluck on Wed Jun 07, 2017 8:54 am

Hello there.
I am using a feather m0 and two 16 bit adcs to take 3 differential analog measurements and write the voltages to an SD card. Everything works great when the controller is plugged into my PC's usb but when I run the unit on an independent power supply (24 V - 3.7 V DC-DC converter into the JST jack) the controller doesn't create a file on the SD card or write to it. I feel like it is a power supply issue, but my code is also included below. Any ideas?
Thanks,
Ben
Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include "RTClib.h"
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads1(0x48);
Adafruit_ADS1115 ads2(0x49);
RTC_DS3231 rtc;
const int chipSelect = 4;

void setup(void)
{
  Serial.begin(9600);
  ads1.begin();
  ads2.begin();
  while (!Serial) {
  }
  if (!SD.begin(chipSelect)) {
    return;
  }
}
void loop() {
DateTime now = rtc.now();
  int16_t one;
  int16_t two;
  int16_t three;
    float   multiplier = .1875F;
  one = ads1.readADC_Differential_0_1();
  two = ads1.readADC_Differential_2_3();
  three = ads2.readADC_Differential_0_1();

  File dataFile = SD.open("datalog.txt", FILE_WRITE);
  if (dataFile) {
    dataFile.print(now.year(), DEC);
    dataFile.print('/');
    dataFile.print(now.month(), DEC);
    dataFile.print('/');
    dataFile.print(now.day(), DEC);
    dataFile.print(" ");
    dataFile.print(now.hour(), DEC);
    dataFile.print(':');
    dataFile.print(now.minute(), DEC);
    dataFile.print(':');
    dataFile.print(now.second(), DEC);
    dataFile.print(" ");
    dataFile.print(one*multiplier);
    dataFile.print(" ");
    dataFile.print(two*multiplier);
    dataFile.print(" ");
    dataFile.println(three*multiplier);
    dataFile.close();

    delay(1000);
  }
  else {
   
  }
}

benniekluck
 
Posts: 3
Joined: Wed Jun 07, 2017 8:49 am

Re: SD Card Writing

by franklin97355 on Wed Jun 07, 2017 10:05 am

Code: Select all | TOGGLE FULL SIZE
  Serial.begin(9600);
  ads1.begin();
  ads2.begin();
  while (!Serial) {
  }
Since your code does not use serial and you are not connected to a serial interface while remote you can remove the serial code and it should work

franklin97355
 
Posts: 21300
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: SD Card Writing

by benniekluck on Wed Jun 07, 2017 11:00 am

And indeed it does. Thank you.
Ben

benniekluck
 
Posts: 3
Joined: Wed Jun 07, 2017 8:49 am

Please be positive and constructive with your questions and comments.