TinyCircuits Forum
TinyCircuits Products => TinyDuino Processors & TinyShields => Topic started 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 ?
-
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?
-
Thanks, Yes here is the PastBin:
http://pastebin.com/7QdXFYzZ
I "only" merge TinyScreen Sample with Accelerometer sample and SDCard sample
-
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.
-
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
-
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.