I’ve purchased the RadioShack version of the SD Shield v3.
I’m trying to pass in data from a GPS breakout board and have my Arduino UNO receive the data over SoftwareSerial and have the SD Shield write the data to an SD card.
- I can communicate just fine with the GPS board over SoftwareSerial when not using the SD Shield.
- I can communicate just fine with the SD shield and even remove, create and write to files on the SD card.
- When I try to mix #1 and #2, it appears that I cannot see the data that’s coming in over SoftwareSerial. I do, however, appear to still have full access to the SD card and remove/create/read/write capabilities.
I’m trying to use SoftwareSerial over pins 2 and 3, but I’ve also tried 7 and 8 and other combinations.
I think I know that pins 10-13 are in use by the SD Shield, but am I missing something else? I swear I had this working a few hours ago, but now I’ve got nothing. Getting the data in isn’t very useful if I can’t do something with it. Being able to write data isn’t very useful if I can’t get the data in.
Can somebody please help?!?
Here’s a sketch that works for me to see the data streaming in from GPS:
#include <SoftwareSerial.h>
SoftwareSerial gps(2,3);
void setup() {
Serial.begin(19200);
gps.begin(19200);
}
void loop() {
if(Serial.available()) {
char c = Serial.read();
Serial.write(c);
}
if(Serial.available()) {
gps.write(Serial.read());
}
}
Here’s a sketch that works to write dummy data to my SD card (while setting up the SoftwareSerial, but not trying to read it):
#include <SD.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>
SoftwareSerial gpsSerial(2,3);
const int chipSelect = 10;
TinyGPS gps;
File dataFile;
char* dataFileName = "dataLog.csv";
int lines = 0;
boolean connected = false;
boolean initialized = false;
char dataLine[100];
int dataLinePos = 0;
boolean live = true;
void setup() {
Serial.begin(9600);
gpsSerial.begin(19200);
Serial.print("\nInitializing SD card...");
pinMode(10, OUTPUT);
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
return;
}
Serial.println("card initialized.");
if (SD.exists(dataFileName)) {
SD.remove(dataFileName);
}
dataFile = SD.open(dataFileName, FILE_WRITE);
if (dataFile) {
initialized = true;
Serial.println("Data file initialized.");
} else {
Serial.println("Data file NOT initialized!");
}
}
boolean done = false;
void loop() {
if (done == false) {
for (int i = 0; i < 10000; i = i + 1) {
Serial.println(i);
dataFile.println(i);
}
dataFile.close();
done = true;
}
}