Yun, SD CardInfo Example, + Console

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
cybrk
 
Posts: 11
Joined: Sun Jun 08, 2014 10:24 am

Yun, SD CardInfo Example, + Console

Post by cybrk »

Greetings Adafruit,

Learning the Yun, and trying to test out the SD card which does not seem to work when I try to write to it, so I went back and tried the CardInfo Example Sketch, I added Console service and the sketch is below, but compile does not work. Can you help?

Sketch
/*
SD card test

This example shows how use the utility libraries on which the'
SD library is based in order to get info about your SD card.
Very useful for testing a card when you're not sure whether its working or not.

The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
** CS - depends on your SD card shield or module.
Pin 4 used here for consistency with other Arduino examples


created 28 Mar 2011
by Limor Fried
modified 9 Apr 2012
by Tom Igoe
*/
// include the SD library:
#include <SPI.h>
#include <SD.h>
#include <Console.h>
// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 4;

void setup()
{
// Open Console communications and wait for port to open:
Serial.begin(9600);
Bridge.begin();
Console.begin(); while (!Console) {
; // wait for Console port to connect. Needed for Leonardo only
}


Console.print("\nInitializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(10, OUTPUT); // change this to 53 on a mega


// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
Console.println("initialization failed. Things to check:");
Console.println("* is a card is inserted?");
Console.println("* Is your wiring correct?");
Console.println("* did you change the chipSelect pin to match your shield or module?");
return;
} else {
Console.println("Wiring is correct and a card is present.");
}

// print the type of card
Console.print("\nCard type: ");
switch (card.type()) {
case SD_CARD_TYPE_SD1:
Console.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Console.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Console.println("SDHC");
break;
default:
Console.println("Unknown");
}

// Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
if (!volume.init(card)) {
Console.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
return;
}


// print the type and size of the first FAT-type volume
uint32_t volumesize;
Console.print("\nVolume type is FAT");
Console.println(volume.fatType(), DEC);
Console.println();

volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
volumesize *= 512; // SD card blocks are always 512 bytes
Console.print("Volume size (bytes): ");
Console.println(volumesize);
Console.print("Volume size (Kbytes): ");
volumesize /= 1024;
Console.println(volumesize);
Console.print("Volume size (Mbytes): ");
volumesize /= 1024;
Console.println(volumesize);


Console.println("\nFiles found on the card (name, date and size in bytes): ");
root.openRoot(volume);

// list all files in the card with date and size
root.ls(LS_R | LS_DATE | LS_SIZE);
}


void loop(void) {

}

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Yun, SD CardInfo Example, + Console

Post by tdicola »

Are you trying to use the SD card reader built into the Yun? If so you actually need to use a special FileSystem API that's specific to the Arduino Yun (kind of like how the Console class is a special Yun-only WiFi serial console). Take a look at this example for more information: http://arduino.cc/en/Tutorial/YunDatalogger

Also can you post the error that you're seeing in the Arduino IDE when you compile?

User avatar
cybrk
 
Posts: 11
Joined: Sun Jun 08, 2014 10:24 am

Re: Yun, SD CardInfo Example, + Console

Post by cybrk »

Thank you for your response.

Regarding your referral to example: http://arduino.cc/en/Tutorial/YunDatalogger

This is actually the sketch I was working on when I discovered I had a SD problem. Basically I have taken this Sketch and added components for the ADS11115 which I have working today. The problem with the working sketch is that I am trying to write the two data-strings to the SD card and the sketch just fails without an error. So I thought I had a problem with my SD setup, and that is why I went back to try the CardInfo example. In the sketch below I have added the characters "//** " in front of all my SD related commands to keep the sketch running. In this sketch I do use FileIO. If I remove these comment characters and try to let the Yun write to SD..it either fails or locks up, but I do not get an error to view.

Sketch-code

/*
AnalogReadSerialConsole
Reads analog input on pin 0
Reads analog input on pin 1
Reads analog input on pin 2

scale the numbers between 0.0 and 5.0, divide 5.0 by 1023.0
and multiply that by the sensorValue
sensor * 0.0048875855327468

prints the result to the serial and console monitor.

Pin 13 has an LED connected named = led
Delay of 500ms
Flash of 1000ms
Delay of 500ms


*/
// 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 = 4;

//Pin 13 has an LED connected named = led
int led = 13;

#include <Console.h>
#include <FileIO.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
Bridge.begin();
Console.begin();

// The ADC input range (or gain) can be changed via the following
// functions, but be careful never to exceed VDD +0.3V max, or to
// exceed the upper and lower limits if you adjust the input range!
// Setting these values incorrectly may destroy your ADC!
// ADS1015 ADS1115
// ------- -------
ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
// ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV

ads.begin();
//** FileSystem.begin();

//** while(!Serial); // wait for Serial port to connect.
//** Serial.println("Filesystem datalogger\n");
//** while(!Console); // wait for Serial port to connect.
//** Console.println("Filesystem datalogger\n");

}

// the loop routine runs over and over again forever:
void loop() {

// make a string for assembling the data to log:
String dataString = "";
String dataString2 = "";
dataString += getTimeStamp();
dataString += " ";
// read the input on analog pin 0:
int sensorValue0 = analogRead(A0);
int sensorValue1 = analogRead(A1);
int sensorValue2 = analogRead(A2);

// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage0 = sensorValue0 * (5.0 / 1023.0);
float voltage1 = sensorValue1 * (5.0 / 1023.0);
float voltage2 = sensorValue2 * (5.0 / 1023.0);

// Build the dataString
dataString += voltage0;
dataString += ", ";
dataString += voltage1;
dataString += ", ";
dataString += voltage2;

//ADS1015 Query
int16_t adc0, adc1, adc2, adc3;

adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);

// Convert the reading (based on gainset) to a voltage (adc_n x 0.1875)default :
// ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
// ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV

float Avoltage0 = adc0 * (5.0 / 1023.0);
float Avoltage1 = adc1 * (0.1875);
float Avoltage2 = adc2 * (0.1875);
float Avoltage3 = adc3 * (0.1875);


// Build the dataString2
dataString2 += Avoltage0;
dataString2 += ", ";
dataString2 += Avoltage1;
dataString2 += ", ";
dataString2 += Avoltage2;
dataString2 += ", ";
dataString2 += Avoltage3;


// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
// The FileSystem card is mounted at the following "/mnt/FileSystema1"
//** File dataFile = FileSystem.open("/mnt/sd/datalog.txt", FILE_APPEND);

// if the file is available, write to it:
//** if (dataFile) {
//** dataFile.println(dataString);
//** dataFile.close();
// print out the value you read:
Serial.println(dataString);
Console.println(dataString);
Serial.println(dataString2);
Console.println(dataString2);


//** }
// if the file isn't open, pop up an error:
//** else {
//** Serial.println("error opening datalog.txt");
//** Console.println("error opening datalog.txt");


delay(15000);


delay(500); // delay in between reads for stability
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second


}
// This function return a string with the time stamp
String getTimeStamp() {
String result;
Process time;
// date is a command line utility to get the date and the time
// in different formats depending on the additional parameter
time.begin("date");
time.addParameter("+%D-%T"); // parameters: D for the complete date mm/dd/yy
// T for the time hh:mm:ss
time.run(); // run the command

// read the output of the command
while(time.available()>0) {
char c = time.read();
if(c != '\n')
result += c;
}

return result;
}

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Yun, SD CardInfo Example, + Console

Post by tdicola »

I haven't used the SD card API on the Yun, but what if you start small and build up from there so it's easier to see what might be causing problems as new functionality is added. Start with a sketch that just writes data to the SD card to see if it works. For example try something like:

Code: Select all

#include <FileIO.h>

void setup() {
  // Initialize the bridge, serial, and SD card.
  Bridge.begin();
  Serial.begin(9600);
  FileSystem.begin();

  // Open file and write some data to it.
  File dataFile = FileSystem.open("/mnt/sd/helloworld.txt", FILE_APPEND);
  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println("Hello world!");
    dataFile.close();
  }
}

void loop () {
  // Do nothing in the loop.
  delay(1000);
}
If you upload this sketch it should add a new "Hello world!" line to the file /mnt/sd/helloworld.txt. Give this a shot to check if a very simple SD card write works.

User avatar
cybrk
 
Posts: 11
Joined: Sun Jun 08, 2014 10:24 am

Re: Yun, SD CardInfo Example, + Console

Post by cybrk »

Wow, I did not realize the solution was so simple

The problem was 2 here:
File dataFile = FileSystem.open("/mnt/sd/arduino/yun1_log.txt", FILE_APPEND);

From previous tutorials I must have gotten confused regarding the folder location as I was under the impression Arduino would not recognize SD resource unless /arduino existed. In your sample code helloworld.txt was saved to root folder rather than /arduino. I made a small change and now the sketch works very well. I share the full sketch below with you and the Adafruit forum as I know several of my collaborators are experiencing similar problems. Thank you again for your excellent and timely support.
Stephen

code--start

/*
AnalogReadSerialConsole
Reads analog input on pin 0
Reads analog input on pin 1
Reads analog input on pin 2

scale the numbers between 0.0 and 5.0, divide 5.0 by 1023.0
and multiply that by the sensorValue
sensor * 0.0048875855327468

prints the result to the serial and console monitor.

Pin 13 has an LED connected named = led
Delay of 500ms
Flash of 1000ms
Delay of 500ms


*/
// 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 = 4;

//Pin 13 has an LED connected named = led
int led = 13;

#include <Console.h>
#include <FileIO.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
Bridge.begin();
Console.begin();

// The ADC input range (or gain) can be changed via the following
// functions, but be careful never to exceed VDD +0.3V max, or to
// exceed the upper and lower limits if you adjust the input range!
// Setting these values incorrectly may destroy your ADC!
// ADS1015 ADS1115
// ------- -------
ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
// ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV

ads.begin();
//** FileSystem.begin();

//** while(!Serial); // wait for Serial port to connect.
//** Serial.println("Filesystem datalogger\n");
//** while(!Console); // wait for Serial port to connect.
//** Console.println("Filesystem datalogger\n");

}

// the loop routine runs over and over again forever:
void loop() {

// make a string for assembling the data to log:
String dataString = "";
String dataString2 = "";
dataString += getTimeStamp();
dataString += " ";
// read the input on analog pin 0:
int sensorValue0 = analogRead(A0);
int sensorValue1 = analogRead(A1);
int sensorValue2 = analogRead(A2);

// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage0 = sensorValue0 * (5.0 / 1023.0);
float voltage1 = sensorValue1 * (5.0 / 1023.0);
float voltage2 = sensorValue2 * (5.0 / 1023.0);

// Build the dataString
dataString += voltage0;
dataString += ", ";
dataString += voltage1;
dataString += ", ";
dataString += voltage2;

//ADS1015 Query
int16_t adc0, adc1, adc2, adc3;

adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);


// Build the dataString2
dataString2 += adc0;
dataString2 += ", ";
dataString2 += adc1;
dataString2 += ", ";
dataString2 += adc2;
dataString2 += ", ";
dataString2 += adc3;


// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
// The FileSystem card is mounted at the following "/mnt/FileSystema1"
//** File dataFile = FileSystem.open("/mnt/sd/datalog.txt", FILE_APPEND);

// if the file is available, write to it:
//** if (dataFile) {
//** dataFile.println(dataString);
//** dataFile.close();
// print out the value you read:
Serial.println(dataString);
Console.println(dataString);
Serial.println(dataString2);
Console.println(dataString2);


//** }
// if the file isn't open, pop up an error:
//** else {
//** Serial.println("error opening datalog.txt");
//** Console.println("error opening datalog.txt");


delay(15000);


delay(500); // delay in between reads for stability
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second


}
// This function return a string with the time stamp
String getTimeStamp() {
String result;
Process time;
// date is a command line utility to get the date and the time
// in different formats depending on the additional parameter
time.begin("date");
time.addParameter("+%D-%T"); // parameters: D for the complete date mm/dd/yy
// T for the time hh:mm:ss
time.run(); // run the command

// read the output of the command
while(time.available()>0) {
char c = time.read();
if(c != '\n')
result += c;
}

return result;
}

code--end

User avatar
cybrk
 
Posts: 11
Joined: Sun Jun 08, 2014 10:24 am

Re: Yun, SD CardInfo Example, + Console

Post by cybrk »

Ok that last code was the wrong code...and I don't see captcha so I resubmit the correct code here:

/*
YUN Analog Datalogger and ADS1115 4 channel setup that
writes to SD card
created 19 Jun 2014
Stephen Engel

Sketch reads A0,A1,A2 and converts to voltage based on 10bit ADC
Sketch reads Channel 1-4 ADS1115
Sketch converts channel values to Volts "not sure this conversion is correct yet"
Sketch writes 2 Datastrings to SD card note path* "/mnt/sd/arduino/yun1_log.txt"
Assumes Fat16/Fat32 format with /arduino folder in root of SD card.

AnalogReadSerialConsole
Reads analog input on pin 0
Reads analog input on pin 1
Reads analog input on pin 2

scale the numbers between 0.0 and 5.0, divide 5.0 by 1023.0
and multiply that by the sensorValue
sensor * 0.0048875855327468

prints the result to the serial and console monitor.

Pin 13 has an LED connected named = led
Delay of 500ms
Flash of 1000ms
Delay of 500ms




*/
//Pin 13 has an LED connected named = led
int led = 13;

#include <Console.h>
#include <FileIO.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */

void setup() {
// Initialize the Bridge, Serial, Console, and FileSystem.
Serial.begin(9600); // initialize serial communication at 9600 bits per second:
Bridge.begin(); // initialize Bridge:
Console.begin(); // initialize Console communication :
FileSystem.begin(); // initialize FileSystem:


// The ADC input range (or gain) can be changed via the following
// functions, but be careful never to exceed VDD +0.3V max, or to
// exceed the upper and lower limits if you adjust the input range!
// Setting these values incorrectly may destroy your ADC!
// ADS1015 ADS1115
// ------- -------
// ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
// ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV

ads.begin();

}

// the loop routine runs over and over again forever:
void loop() {

// make a string for assembling the data to log:
String dataString = "";
String dataString2 = "";
dataString += getTimeStamp();
dataString += " ";
// read the input on analog pin 0:
int sensorValue0 = analogRead(A0);
int sensorValue1 = analogRead(A1);
int sensorValue2 = analogRead(A2);

// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage0 = sensorValue0 * (5.0 / 1023.0);
float voltage1 = sensorValue1 * (5.0 / 1023.0);
float voltage2 = sensorValue2 * (5.0 / 1023.0);

// Build the dataString
dataString += voltage0;
dataString += ", ";
dataString += voltage1;
dataString += ", ";
dataString += voltage2;

//ADS1015 Query
int16_t adc0, adc1, adc2, adc3;

adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);

// Convert the reading (based on gainset) to a voltage (adc_n x 0.1875)default :
// ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
// ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV

float Avoltage0 = adc0 * (0.0001875);
float Avoltage1 = adc1 * (0.0001875);
float Avoltage2 = adc2 * (0.0001875);
float Avoltage3 = adc3 * (0.0001875);


// Build the dataString2
dataString2 += Avoltage0;
dataString2 += ", ";
dataString2 += Avoltage1;
dataString2 += ", ";
dataString2 += Avoltage2;
dataString2 += ", ";
dataString2 += Avoltage3;

// Open file and write some data to it.
File dataFile = FileSystem.open("/mnt/sd/arduino/yun1_log.txt", FILE_APPEND);
// if the file is available, write to it:
if (dataFile) {
dataFile.println(dataString);
dataFile.println(dataString2);
dataFile.close();
}


// print out the value you read:
Serial.println(dataString);
Console.println(dataString);
Serial.println(dataString2);
Console.println(dataString2);



delay(500); // delay in between reads for stability
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second


}
// This function return a string with the time stamp
String getTimeStamp() {
String result;
Process time;
// date is a command line utility to get the date and the time
// in different formats depending on the additional parameter
time.begin("date");
time.addParameter("+%D-%T"); // parameters: D for the complete date mm/dd/yy
// T for the time hh:mm:ss
time.run(); // run the command

// read the output of the command
while(time.available()>0) {
char c = time.read();
if(c != '\n')
result += c;
}

return result;
}

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Yun, SD CardInfo Example, + Console

Post by tdicola »

Cool, good to hear you got it working. Thanks for posting the code so other folks might see it in the future too.

User avatar
SwCharlie
 
Posts: 1
Joined: Sat Nov 28, 2015 4:06 pm

Re: Yun, SD CardInfo Example, + Console

Post by SwCharlie »

For some reason when I add Serial1.begin(9600); to this code: (https://www.arduino.cc/en/Tutorial/YunDatalogger), then the Yun's built-in SD card doesn't work anymore. So I bought a separate SD card module (this also seems better as it is not dependent on the linux system). So in the examples for datalogger (using SD.h library), it specifies that the connection should be:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4

Where should CS pin be connected on the Yun?

I tried connecting it to pin 2 and 4 and 10 (chaning the "const int chipSelect = 4;" respectively. But no luck.

Any help would be appreciated.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”