Sunspot Home

Arduino speaking variometer
adding a micro SD card to store flight data

These are my backup project notes - please email me if interested

Objective
Solder to the tabs of a full-size-SD-to-micro-SD-adapter to hold a micro SD card in the variometer

Method
I followed this hack since it takes much less space than the various SD card shields for Arduino
http://arduinodiy.wordpress.com/2012/03/28/sd-card-on-arduino/

sdbackSDtabs
Solder (quickly!) to the gold tabs - pin 9 is offset at the clipped off corner (not used here)

My Arduino is set to run at 3.3 volts so I do not need the resistor voltage droppers to connect to the SD card as in the link above.

I connected as below.

(first number is the SD card pin - the second number is the Arduino digital pin - NC = not connected)

1 NC <---------this pin is furthest from the cut off corner of the SD adapter
2 12-MISO
3 NC
4 13-SCK
5 3.3 volts
6 Earth
7 11-MOSI
8 10-SS
9 clipped corner pin - NC

I used tinyFAT for the following first test with a Sandisk 2GB FAT16 micro SD card - it worked perfectly - I will test others later - more to come!

// Demo_writeLn (C)2011 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// modified by fgm for speaking vario test - first try
//
// This program is a demo of the writeLn()-function.
//
// This demo will create a textfile, and fill it with 1MB
// of text. The file will be named 'BIGFILE.TXT'. If the
// file already exists it will first be deleted.
//
// SD card must be connected to the SPI port of your Arduino.
//
// Remember to select 115200 baud in the Serial Monitor.
//

#include <tinyFAT.h>
#include <avr/pgmspace.h>

byte res;
char Str4[8] = "arduino";
char *verboseError(byte err)
{
switch (err)
{
case ERROR_MBR_READ_ERROR:
return "Error reading MBR";
break;
case ERROR_MBR_SIGNATURE:
return "MBR Signature error";
break;
case ERROR_MBR_INVALID_FS:
return "Unsupported filesystem";
break;
case ERROR_BOOTSEC_READ_ERROR:
return "Error reading Boot Sector";
break;
case ERROR_BOOTSEC_SIGNATURE:
return "Boot Sector Signature error";
break;
default:
return "Unknown error";
break;
}
}

void setup() {
// Initialize serial communication at 115200 baud
Serial.begin(115200);
Serial.println();
// Initialize tinyFAT
// You might need to select a lower speed than the default SPISPEED_HIGH
res=file.initFAT();
if (res!=NO_ERROR)
{
Serial.print("***** ERROR: ");
Serial.println(verboseError(res));
while (true) {};
}

Serial.println("This demo will create a textfile, and fill it with 1MB of text.");
Serial.println("The file will be named 'BIGFILE.TXT'. If the file already exists it will first be deleted.");
Serial.println();
Serial.println("***** Send any character to start *****");
while (!Serial.available()) {};
Serial.flush();
//=====================================================================================================================
char filenamebuffer[50];
sprintf(filenamebuffer, "FILEDATA.TXT");
Serial.println(filenamebuffer);


if (file.exists(filenamebuffer))
file.delFile(filenamebuffer);

file.create(filenamebuffer);

res=file.openFile("filenamebuffer", FILEMODE_TEXT_WRITE);
if (res==NO_ERROR)
{

long altitude = 1234; // <----------------------------------------------calculate these eventually
long timer = 9876;

char buffer[50];
char timerbuffer[50];

sprintf(buffer, "the current altitude is %d", altitude);
Serial.println(buffer);

sprintf(timerbuffer, "the current time is %d", timer);
Serial.println(timerbuffer);

file.writeLn(buffer);
file.writeLn(timerbuffer);

Serial.println("altitude and time saved");

file.closeFile();
}
else
{
switch(res)
{
case ERROR_ANOTHER_FILE_OPEN:
Serial.println("** ERROR: Another file is already open...");
break;
default:
Serial.print("** ERROR: ");
Serial.println(res, HEX);
break;
}
}
Serial.println("***** All done... *****");

}

void loop()
{
}

more

to come!

 

Comments? email me