Thank you very much. I managed to get i work. It is actually pretty simple. I think a better upload the working file so others can enjoy the community.
/*
SD card datalogger
This example shows how to log data from three analog sensors
to an SD card using the SD library.
The circuit:
* analog sensors on analog ins 0, 1, and 2
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
created 24 Nov 2010
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
*/
#include <SD.h>
#include <Wire.h>
// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 53;
int controlPin0 = 7; // digtital input pin to control start and stop of datalogger
int controlPin1 = 12; // digtital output pin to make false/true
int controlPin2 = 13; // digtital input pin to make false/true
int analogPin5 = A5;
int analogPin6 = A6;
int analogPin7 = A7;
int analogPin8 = A8;
int analogPin9 = A9;
int analogPin10 = A10;
int analogPin11 = A11;
int analogPin12 = A12;
int analogPin13 = A13;
int analogPin14 = A14;
int analogPin15 = A15;
// the logging file
File logfile;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println();
Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:
pinMode(53, OUTPUT);
pinMode(controlPin0, INPUT);
pinMode(controlPin1, OUTPUT);
pinMode(controlPin2, INPUT);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
return;
}
Serial.println("card initialized.");
}
void loop()
{
if (digitalRead(controlPin0)==LOW)
{
digitalWrite(controlPin1, LOW);
}
if (digitalRead(controlPin0)==HIGH&&digitalRead(controlPin2)==LOW)
{
// create a new file
char filename[] = "LOGGER00.CSV";
for (uint8_t i = 0; i < 100; i++) {
filename[6] = i/10 + '0';
filename[7] = i%10 + '0';
if (! SD.exists(filename)) {
// only open a new file if it doesn't exist
logfile = SD.open(filename, FILE_WRITE);
break; // leave the loop!
}
}
if (! logfile) {
Serial.println("couldnt create file");
return;
}
Serial.println("card initialized.");
Serial.print("Logging to: ");
Serial.println(filename);
logfile.println("Temperature0,temperature1,temperature2,Temperature3,temperature4,temperature5,temperature6,temperature7,pressure0,pressure1,pressure2");
Serial.println("Temperature0,temperature1,temperature2,Temperature3,temperature4,temperature5,temperature6,temperature7,pressure0,pressure1,pressure2");
digitalWrite(controlPin1, HIGH);
delay (1000);
}
if (digitalRead(controlPin0)==HIGH && digitalRead(controlPin2)==HIGH)
{
// make a string for assembling the data to log:
File logfile = SD.open("filename", FILE_WRITE);
// read 11 sensors and append to the string:
float tempPin0 = (2*(analogRead(analogPin8)*5.0 / 1023)- 2.05) / 0.005;
float tempPin1 = (2*(analogRead(analogPin9)*5.0 / 1023)- 2.05) / 0.005;
float tempPin2 = (2*(analogRead(analogPin10)*5.0 / 1023)- 2.05) / 0.005;
float tempPin3 = (2*(analogRead(analogPin11)*5.0 / 1023)- 2.05) / 0.005;
float tempPin4 = (2*(analogRead(analogPin12)*5.0 / 1023)- 2.05) / 0.005;
float tempPin5 = (2*(analogRead(analogPin13)*5.0 / 1023)- 2.05) / 0.005;
float tempPin6 = (2*(analogRead(analogPin14)*5.0 / 1023)- 2.05) / 0.005;
float tempPin7 = (2*(analogRead(analogPin15)*5.0 / 1023)- 2.05) / 0.005;
float pressurePin0 = analogRead(analogPin5)*5.0 / 1023;
float pressurePin1 = analogRead(analogPin6)*5.0 / 1023;
float pressurePin2 = analogRead(analogPin7)*5.0 / 1023;
// if the file is available, write to it:
if (logfile) {
logfile.print(tempPin0);
logfile.print(", ");
logfile.print(tempPin1);
logfile.print(", ");
logfile.print(tempPin2);
logfile.print(", ");
logfile.print(tempPin3);
logfile.print(", ");
logfile.print(tempPin4);
logfile.print(", ");
logfile.print(tempPin5);
logfile.print(", ");
logfile.print(tempPin6);
logfile.print(", ");
logfile.print(tempPin7);
logfile.print(", ");
logfile.print(pressurePin0);
logfile.print(", ");
logfile.print(pressurePin1);
logfile.print(", ");
logfile.print(pressurePin2);
// print to the serial port too:
Serial.print(tempPin0);
Serial.print(", ");
Serial.print(tempPin1);
Serial.print(", ");
Serial.print(tempPin2);
Serial.print(", ");
Serial.print(tempPin3);
Serial.print(", ");
Serial.print(tempPin4);
Serial.print(", ");
Serial.print(tempPin5);
Serial.print(", ");
Serial.print(tempPin6);
Serial.print(", ");
Serial.print(tempPin7);
Serial.print(", ");
Serial.print(pressurePin0);
Serial.print(", ");
Serial.print(pressurePin1);
Serial.print(", ");
Serial.print(pressurePin2);
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening file");
}
logfile.println();
Serial.println();
delay(1000);
}
}
best regards Bastian