TinyCircuits Forum

TinyCircuits Products => TinyDuino Processors & TinyShields => Topic started by: jpencausse on March 15, 2015, 01:07:57 PM

Title: TinyScreen / SDCard writing issue
Post by: jpencausse on March 15, 2015, 01:07:57 PM
Hi,
I'm trying to log accelerometer to SDCard and display it on TinyScreen.

Everything should be fine but nothing is write on the Card
- The card is Formated
- The SD example ar OK
- I use TinyScreen + TinySD + TinyUSB + TinyDuino

void setup(void) {
  Serial.begin(9600); while (!Serial) { ; }
  Wire.begin();
  ...
  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);
  if (!SD.begin(10)) {  Serial.println("Card failed, or not present"); return; }
}

void writeSD(long delta, long time){
  File dataFile = SD.open("datalog.json", FILE_WRITE);
  String str = "{ \"delta\": " + String(delta*250/1000) + ", \"duration\":" + String(time*250/1000) + "}";
  dataFile.println(str);
  dataFile.close();
 
  if (SD.exists("datalog.json")) {
    Serial.println("datalog.json exists.");
  }
}

And SD.exists() return it do not exists ... any idea ?

Title: Re: TinyScreen / SDCard writing issue
Post by: Ben Rose on March 16, 2015, 06:53:32 PM
SD cards share the SPI bus with TinyScreen, so how and when each is used is important. Can you post or attach the full sketch?
Title: Re: TinyScreen / SDCard writing issue
Post by: jpencausse on March 18, 2015, 05:47:48 AM
Thanks, Yes here is the PastBin:
http://pastebin.com/7QdXFYzZ

I "only" merge TinyScreen Sample with Accelerometer sample and SDCard sample
Title: Re: TinyScreen / SDCard writing issue
Post by: Ben Rose on March 18, 2015, 12:38:31 PM
You're using a very early version of the TinyScreen library. The newest version is at https://github.com/TinyCircuits/TinyCircuits-TinyScreen_Lib or our CodeBender examples. I think the version you have is old enough that the SPI is managed in a manner that can conflict with the SD card, so see if just changing the library fixes your problem and let us know.
Title: Re: TinyScreen / SDCard writing issue
Post by: jpencausse on March 19, 2015, 07:16:48 AM
Ok thanks

For the SD Card I use the tutorial in SDCard page:
https://tiny-circuits.com/tiny-shield-micro-sd.html

For the Accelerometer I use the tutorial in page:
https://tiny-circuits.com/learn/tinyshield-accel

For the TinyScreen I follow projects here:
https://tinycircuits.hackster.io/

EDIT: Try with latest version but SD card still not writing
Title: Re: TinyScreen / SDCard writing issue
Post by: Ben Rose on March 20, 2015, 01:54:11 PM
We've updated the Hackster examples to use the latest library, sorry about that! I'll take a closer look at your code soon and see if I can figure out what's going on.