Data logging
Posted: 10 Mar 2021 21:30
moin,
to log data you have to change/add the following lines:
(I used Pin8 on Arduino Uno, feel free to use an other free pin)
add in pin assignments:
/*************************************************/
//Define pin assignments.
/*************************************************/
#define SD_Card_CS 8 /* CS-Pin fuer SD-CARD*/
add in Setup:
/*************************************************/
//Function to set up device for operation. (setup)
/*************************************************/
pinMode(SD_Card_CS, OUTPUT);
digitalWrite(SD_Card_CS, HIGH);
change in Setup:
//Configure data logging.
if ( SD.begin() ) {
to
if ( SD.begin(SD_Card_CS) ) {
change Data logging function to:
/*************************************************/
//Data logging function.
/*************************************************/
void logData(String logString)
{
//Connect to SD-Card.
// if (SD.begin(SD_Card_CS))
if (logEnabled==true)
{
File logFile = SD.open("log.txt", FILE_WRITE);
//Store data.
logFile.println(logString);
//Close file.
logFile.close();
//Flush SPI, required when switching between modes.
COM_SPI(0x00);
}
}
cause second initialization of SD-Card will fail
Have fun
wolf
to log data you have to change/add the following lines:
(I used Pin8 on Arduino Uno, feel free to use an other free pin)
add in pin assignments:
/*************************************************/
//Define pin assignments.
/*************************************************/
#define SD_Card_CS 8 /* CS-Pin fuer SD-CARD*/
add in Setup:
/*************************************************/
//Function to set up device for operation. (setup)
/*************************************************/
pinMode(SD_Card_CS, OUTPUT);
digitalWrite(SD_Card_CS, HIGH);
change in Setup:
//Configure data logging.
if ( SD.begin() ) {
to
if ( SD.begin(SD_Card_CS) ) {
change Data logging function to:
/*************************************************/
//Data logging function.
/*************************************************/
void logData(String logString)
{
//Connect to SD-Card.
// if (SD.begin(SD_Card_CS))
if (logEnabled==true)
{
File logFile = SD.open("log.txt", FILE_WRITE);
//Store data.
logFile.println(logString);
//Close file.
logFile.close();
//Flush SPI, required when switching between modes.
COM_SPI(0x00);
}
}
cause second initialization of SD-Card will fail
Have fun
wolf