I'm attempting to build a GPS tracker for my cat. It's for my final project in school. The devices I have are the MKR1000, MicoSD Card Adapter, and Adafruit Ultimate GPS Breakout. I'm attempting to record onto the SD card GPS degrees every few seconds, however I'm struggling to make anything work. I've attempted to adapt the sketch posted on
The components are different due to size constraints. I believe I have the correct pin connections to power the GPS but I can't figure out how to connect the SD Card. I also run into errors with the sketch provided. I removed the content for the LCD screen but I get errors regarding the library and I can't identify why. If there is someone that has experience in this that can help me, either with how to get the SD card adapter to connect with the MKR1000 and/or better instructions on how to make the sketch I'm using work, I would greatly appreciate it.
did you test each component individually in a seperate program before attempting a combined program?
upload your code (using code tags </>)
upload the serial monitor output
upload a schematic showing the wiring
GPS card: TX and RX are serial port directions, not radio directions. GPS Card TX out goes to Arduino serial RX. GPS card RX in from Arduino port TX out.
I'm attempting to do that. Right now I am working on GPS and the sketch.
Here is the code I modified to use. I removed the LCD section because I'm not using an LCD that was part of the original build.
//This is a modification of the Example code: GPS_SoftwareSerial_Parsing
//Works well with an Arduino Uno with WiFi Rev2,
//with Arduino Uno I get massive Latitude Issues
//Uses Official Ethernet Shield for ICSP Headers required for SD Usage on Arduino Uno with WiFi
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
//ETCG Notes -- SD Card Setup on Ethernet Shield
#include <SPI.h>
#include <SD.h>
#define sdPin 4
File logFile;
// Connect the GPS Power pin to 5V
// Connect the GPS Ground pin to ground
// Connect the GPS TX (transmit) pin to Digital 8
// Connect the GPS RX (receive) pin to Digital 7
// you can change the pin numbers to match your wiring:
SoftwareSerial mySerial(8, 7);
Adafruit_GPS GPS(&mySerial);
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
// Set to 'true' if you want to debug and listen to the raw GPS sentences
#define GPSECHO true
void setup()
{
//ETCG Notes - Start LCD
//ETCG Comment -- Checks for SD Card, if not found keeps loading.
//Use WHILE loop below to require SD Card
if (!SD.begin(sdPin)) {
delay(2000);
}
//ETCG Notes -- Uncomment While Loop if You REQUIRE SD Card
/*
while (!SD.begin(sdPin)) {
lcd.setCursor(0, 1);
lcd.print("SD Card Not Found");
}
*/
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
// also spit it out
Serial.begin(115200);
delay(5000);
Serial.println("Adafruit GPS library basic test!");
// 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
GPS.begin(9600);
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
// uncomment this line to turn on only the "minimum recommended" data
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
// For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
// the parser doesn't care about other sentences at this time
// Set the update rate
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
// For the parsing code to work nicely and have time to sort thru the data, and
// print it out we don't suggest using anything higher than 1 Hz
// Request updates on antenna status, comment out to keep quiet
GPS.sendCommand(PGCMD_ANTENNA);
delay(1000);
// Ask for firmware version
mySerial.println(PMTK_Q_RELEASE);
}
uint32_t timer = millis();
void loop() // run over and over again
{
char c = GPS.read();
// if you want to debug, this is a good time to do it!
if ((c) && (GPSECHO))
Serial.write(c);
// if a sentence is received, we can check the checksum, parse it...
if (GPS.newNMEAreceived()) {
// a tricky thing here is if we print the NMEA sentence, or data
// we end up not listening and catching other sentences!
// so be very wary if using OUTPUT_ALLDATA and trytng to print out data
//Serial.println(GPS.lastNMEA()); // this also sets the newNMEAreceived() flag to false
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
return; // we can fail to parse a sentence in which case we should just wait for another
}
// approximately every 2 seconds or so, print out the current stats
if (millis() - timer > 2000) {
timer = millis(); // reset the timer
Serial.print("\nTime: ");
if (GPS.hour < 10) {
Serial.print('0');
}
Serial.print(GPS.hour, DEC); Serial.print(':');
if (GPS.minute < 10) {
Serial.print('0');
}
Serial.print(GPS.minute, DEC); Serial.print(':');
if (GPS.seconds < 10) {
Serial.print('0');
}
Serial.print(GPS.seconds, DEC); Serial.print('.');
if (GPS.milliseconds < 10) {
Serial.print("00");
} else if (GPS.milliseconds > 9 && GPS.milliseconds < 100) {
Serial.print("0");
}
Serial.println(GPS.milliseconds);
Serial.print("Date: ");
Serial.print(GPS.day, DEC); Serial.print('/');
Serial.print(GPS.month, DEC); Serial.print("/20");
Serial.println(GPS.year, DEC);
Serial.print("Fix: "); Serial.print((int)GPS.fix);
Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
if (GPS.fix) {
Serial.print("Location: ");
Serial.print(GPS.latitude, 8); Serial.print(GPS.lat);
Serial.print(", ");
Serial.print(GPS.longitude, 8); Serial.println(GPS.lon);
//ETCG Notes -- The Following Gives Coordinates in formant you can plug into
//Google Maps (Degrees)
Serial.println("Location in Degrees");
Serial.print(GPS.latitudeDegrees, 8);
Serial.print(", ");
Serial.println(GPS.longitudeDegrees, 8);
Serial.print("Speed (knots): "); Serial.println(GPS.speed);
Serial.print("Angle: "); Serial.println(GPS.angle);
Serial.print("Altitude: "); Serial.println(GPS.altitude);
Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
//ETCG Notes -- Print to LCD Screen
float mph;
mph = (GPS.speed) * 1.15;
//ETCG Notes -- Write to SD Card
logFile = SD.open("gpsLog.txt", FILE_WRITE);
String timeStamp = String(GPS.day, DEC) + (",") + String(GPS.month, DEC) + (",") + String(GPS.year, DEC) + (" - ")
+ String(GPS.hour, DEC) + (":") + String(GPS.minute, DEC) + (":") + String(GPS.seconds, DEC);
if (logFile) {
logFile.print("Time Stamp: ");
logFile.print(timeStamp);
logFile.print(" Speed: ");
logFile.print(mph);
logFile.print(" Lat/long: ");
logFile.print(GPS.latitudeDegrees, 8);
logFile.print(", ");
logFile.println(GPS.longitudeDegrees, 8);
logFile.close();
} else {
}
} else {
}
}
}
I'm getting a ton of errors from this sketch
../SoftwareSerial-master/SoftwareSerial.cpp:362:2: error: #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
#error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
^~~~~
.../SoftwareSerial-master/SoftwareSerial.cpp: In member function 'bool SoftwareSerial::listen()':
.../SoftwareSerial-master/SoftwareSerial.cpp:418:23: error: 'SREG' was not declared in this scope
uint8_t oldSREG = SREG;
^~~~
.../SoftwareSerial-master/SoftwareSerial.cpp:418:23: note: suggested alternative: 'SING'
uint8_t oldSREG = SREG;
^~~~
SING
.../SoftwareSerial-master/SoftwareSerial.cpp:419:5: error: 'cli' was not declared in this scope
cli();
^~~
...SoftwareSerial-master/SoftwareSerial.cpp:419:5: note: suggested alternative: 'Gclk'
cli();
^~~
Gclk
In file included from .../Library/Arduino15/packages/arduino/hardware/samd/1.8.13/cores/arduino/Arduino.h:51:0,
from ...Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:43:
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'void SoftwareSerial::setTX(uint8_t)':
.../Arduino15/packages/arduino/hardware/samd/1.8.13/variants/mkrwifi1010/variant.h:49:35: error: invalid conversion from 'PortGroup*' to 'uint8_t {aka unsigned char}' [-fpermissive]
#define digitalPinToPort(P) (&(PORT->Group[g_APinDescription[P].ulPort]))
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:594:18: note: in expansion of macro 'digitalPinToPort'
uint8_t port = digitalPinToPort(tx);
^~~~~~~~~~~~~~~~
.../Arduino15/packages/arduino/hardware/samd/1.8.13/variants/mkrwifi1010/variant.h:52:41: error: base operand of '->' is not a pointer
#define portOutputRegister(port) (&(port->OUT.reg))
^
...Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:595:27: note: in expansion of macro 'portOutputRegister'
_transmitPortRegister = portOutputRegister(port);
^~~~~~~~~~~~~~~~~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'void SoftwareSerial::setRX(uint8_t)':
.../Arduino15/packages/arduino/hardware/samd/1.8.13/variants/mkrwifi1010/variant.h:49:35: error: invalid conversion from 'PortGroup*' to 'uint8_t {aka unsigned char}' [-fpermissive]
#define digitalPinToPort(P) (&(PORT->Group[g_APinDescription[P].ulPort]))
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:605:18: note: in expansion of macro 'digitalPinToPort'
uint8_t port = digitalPinToPort(rx);
^~~~~~~~~~~~~~~~
.../Arduino15/packages/arduino/hardware/samd/1.8.13/variants/mkrwifi1010/variant.h:53:41: error: base operand of '->' is not a pointer
#define portInputRegister(port) (&(port->IN.reg))
^
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:606:26: note: in expansion of macro 'portInputRegister'
_receivePortRegister = portInputRegister(port);
^~~~~~~~~~~~~~~~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:617:31: error: 'table' was not declared in this scope
for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i)
^~~~...Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:617:31: note: suggested alternative: 'tanl'
for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i)
^~~~~
tanl
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:633:9: error: 'digitalPinToPCICR' was not declared in this scope
if (digitalPinToPCICR(_receivePin))
^~~~~~~~~~~~~~~~~.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:633:9: note: suggested alternative: 'digitalPinToPort'
if (digitalPinToPCICR(_receivePin))
^~~~~~~~~~~~~~~~~
digitalPinToPort
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:635:46: error: 'digitalPinToPCICRbit' was not declared in this scope
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
^~~~~~~~~~~~~~~~~.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:635:46: note: suggested alternative: 'digitalPinToPort'
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
digitalPinToPort
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:635:42: error: '_BV' was not declared in this scope
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
^~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:635:42: note: suggested alternative: '_B'
*digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
^~~
_B
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:636:8: error: 'digitalPinToPCMSK' was not declared in this scope
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:636:8: note: suggested alternative: 'digitalPinToPort'
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~
digitalPinToPort
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:636:46: error: 'digitalPinToPCMSKbit' was not declared in this scope
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:636:46: note: suggested alternative: 'digitalPinToPort'
*digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
digitalPinToPort
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:651:7: error: 'digitalPinToPCMSK' was not declared in this scope
if (digitalPinToPCMSK(_receivePin))
^~~~~~~~~~~~~~~~~
.../Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:651:7: note: suggested alternative: 'digitalPinToPort'
if (digitalPinToPCMSK(_receivePin))
^~~~~~~~~~~~~~~~~
digitalPinToPort
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:652:45: error: 'digitalPinToPCMSKbit' was not declared in this scope
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:652:45: note: suggested alternative: 'digitalPinToPort'
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
^~~~~~~~~~~~~~~~~~~~
digitalPinToPort
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:652:41: error: '_BV' was not declared in this scope
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
^~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:652:41: note: suggested alternative: '_B'
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
^~~
_B
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'virtual size_t SoftwareSerial::write(uint8_t)':
/Users/gregmiddleton/Documents/Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:687:21: error: 'SREG' was not declared in this scope
uint8_t oldSREG = SREG;
^~~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:687:21: note: suggested alternative: 'SING'
uint8_t oldSREG = SREG;
^~~~
SING
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:688:3: error: 'cli' was not declared in this scope
cli(); // turn off interrupts for a clean txmit
^~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:688:3: note: suggested alternative: 'Gclk'
cli(); // turn off interrupts for a clean txmit
^~~
Gclk
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:692:26: error: 'XMIT_START_ADJUSTMENT' was not declared in this scope
tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);
^~~~~~~~~~~~~~~~~~~~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp: In member function 'virtual void SoftwareSerial::flush()':
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:735:21: error: 'SREG' was not declared in this scope
uint8_t oldSREG = SREG;
^~~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:735:21: note: suggested alternative: 'SING'
uint8_t oldSREG = SREG;
^~~~
SING
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:736:3: error: 'cli' was not declared in this scope
cli();
^~~
.../Arduino/libraries/SoftwareSerial-master/SoftwareSerial.cpp:736:3: note: suggested alternative: 'Gclk'
cli();
^~~
Gclk
exit status 1
Compilation error: exit status 1
I can't post the wire diagram but for the GPS, I have the GPS TX connected to RX on the Arduino, GPS RX connected to the Arduino TX, GPS GND to GND and GPS VIN connected to 5V.
error messages indicate problem with SoftwareSerial
no need to use SoftwareSerial
on the MKR1000 Serial is used for USB communications and Serial1 is a hardware serial port on Tx pin 14 Rx pin 13
I used this program on a MKRFOX to test Serial1 communications
// Arduino MKRFOX hardware serial1 port Serial1 on Tx pin 14 Rx pin 13
// on the MKRFOX Serial is used for USB communications and Serial1 is a hardware serial port on Tx pin 14 Rx pin 13
// NOTE: MKRFOX uses 3.3V logic
// - if commected to UNO 5V logic use a voltage divider 2.2K to ground 1K to UNO Tx
// MKRFOX pin 14 is TX
// MKRFOX pin 13 is Rx
// for loopback test connect pin 13 to pin 14
void setup() {
Serial.begin(115200); // initialise serial monitor port
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial1.begin(9600); // initialise Serial1
Serial.println();
Serial.write("Arduino MKRFOX Serial1 test - for loopback test connect pin 13 to pin 14\n");
}
void loop() {
if (Serial1.available()) // read from Serial1 output to Serial
Serial.write(Serial1.read());
if (Serial.available()) { // read from Serial outut to Serial1
int inByte = Serial.read();
//Serial.write(inByte); // local echo if required
Serial1.write(inByte);
}
}
I connected a GPS_GY-NEO6MV2 NEO-6M module to a MKRFOX Serial1 pins 13 and 14 and running the above code the serial monitor displays NMEA data, e.g.
I thought I had it working but I'm not getting any data stored onto the SD card. I'm currently running the card adapter in parallel with the GPS and the LED on the GPS is lit, and the adapter is following the same design so I believe it is receiving power. The sketch uploaded without error. I verified the sd card works by adding and deleting files on it manually. I even replaced the card adapter with another one I had and received the same result. So I either have it wired wrong, the sketch is wrong, or I have a card the Arduino doesn't like.
CS on the adapter is connected to pin 4, which is designated in the sketch.
SCK on the adapter is connected to SCK on the Arduino.
MDSI on the adapter is connected to MDSO on the Arduino.
MDSO on the adapter is connected to MDSI on the Arduino.
The reader is getting 5V from the Arduino. Below is the sketch I'm using.
//Works well with an Arduino Uno with WiFi Rev2,
//with Arduino Uno I get massive Latitude Issues
//Uses Official Ethernet Shield for ICSP Headers required for SD Usage on Arduino Uno with WiFi
#include <Adafruit_GPS.h>
#define mySerial Serial1
Adafruit_GPS GPS(&mySerial);
//ETCG Notes - LCD I2C Screen
//ETCG Notes -- SD Card Setup on Ethernet Shield
#include <SPI.h>
#include <SD.h>
#define sdPin 4
File logFile;
// Connect the GPS Power pin to 5V
// Connect the GPS Ground pin to ground
// Connect the GPS TX (transmit) pin to Digital 13
// Connect the GPS RX (receive) pin to Digital 14
// you can change the pin numbers to match your wiring:
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
// Set to 'true' if you want to debug and listen to the raw GPS sentences
#define GPSECHO true
void setup()
{
//ETCG Comment -- Checks for SD Card, if not found keeps loading.
//Use WHILE loop below to require SD Card
if (!SD.begin(sdPin)) {
delay(2000);
}
//ETCG Notes -- Uncomment While Loop if You REQUIRE SD Card
/*
while (!SD.begin(sdPin)) {
lcd.setCursor(0, 1);
lcd.print("SD Card Not Found");
}
*/
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
// also spit it out
Serial.begin(115200);
delay(5000);
Serial.println("Adafruit GPS library basic test!");
// 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
GPS.begin(9600);
// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
// uncomment this line to turn on only the "minimum recommended" data
//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
// For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since
// the parser doesn't care about other sentences at this time
// Set the update rate
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate
// For the parsing code to work nicely and have time to sort thru the data, and
// print it out we don't suggest using anything higher than 1 Hz
// Request updates on antenna status, comment out to keep quiet
GPS.sendCommand(PGCMD_ANTENNA);
delay(1000);
// Ask for firmware version
mySerial.println(PMTK_Q_RELEASE);
}
uint32_t timer = millis();
void loop() // run over and over again
{
char c = GPS.read();
// if you want to debug, this is a good time to do it!
if ((c) && (GPSECHO))
Serial.write(c);
// if a sentence is received, we can check the checksum, parse it...
if (GPS.newNMEAreceived()) {
// a tricky thing here is if we print the NMEA sentence, or data
// we end up not listening and catching other sentences!
// so be very wary if using OUTPUT_ALLDATA and trytng to print out data
//Serial.println(GPS.lastNMEA()); // this also sets the newNMEAreceived() flag to false
if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false
return; // we can fail to parse a sentence in which case we should just wait for another
}
// approximately every 2 seconds or so, print out the current stats
if (millis() - timer > 2000) {
timer = millis(); // reset the timer
Serial.print("\nTime: ");
if (GPS.hour < 10) {
Serial.print('0');
}
Serial.print(GPS.hour, DEC); Serial.print(':');
if (GPS.minute < 10) {
Serial.print('0');
}
Serial.print(GPS.minute, DEC); Serial.print(':');
if (GPS.seconds < 10) {
Serial.print('0');
}
Serial.print(GPS.seconds, DEC); Serial.print('.');
if (GPS.milliseconds < 10) {
Serial.print("00");
} else if (GPS.milliseconds > 9 && GPS.milliseconds < 100) {
Serial.print("0");
}
Serial.println(GPS.milliseconds);
Serial.print("Date: ");
Serial.print(GPS.day, DEC); Serial.print('/');
Serial.print(GPS.month, DEC); Serial.print("/20");
Serial.println(GPS.year, DEC);
Serial.print("Fix: "); Serial.print((int)GPS.fix);
Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
if (GPS.fix) {
Serial.print("Location: ");
Serial.print(GPS.latitude, 8); Serial.print(GPS.lat);
Serial.print(", ");
Serial.print(GPS.longitude, 8); Serial.println(GPS.lon);
//ETCG Notes -- The Following Gives Coordinates in formant you can plug into
//Google Maps (Degrees)
Serial.println("Location in Degrees");
Serial.print(GPS.latitudeDegrees, 8);
Serial.print(", ");
Serial.println(GPS.longitudeDegrees, 8);
Serial.print("Speed (knots): "); Serial.println(GPS.speed);
Serial.print("Angle: "); Serial.println(GPS.angle);
Serial.print("Altitude: "); Serial.println(GPS.altitude);
Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
//ETCG Notes -- Print to LCD Screen
float mph;
mph = (GPS.speed) * 1.15;
//ETCG Notes -- Write to SD Card
logFile = SD.open("gpsLog.txt", FILE_WRITE);
String timeStamp = String(GPS.day, DEC) + (",") + String(GPS.month, DEC) + (",") + String(GPS.year, DEC) + (" - ")
+ String(GPS.hour, DEC) + (":") + String(GPS.minute, DEC) + (":") + String(GPS.seconds, DEC);
if (logFile) {
logFile.print("Time Stamp: ");
logFile.print(timeStamp);
logFile.print(" Speed: ");
logFile.print(mph);
logFile.print(" Lat/long: ");
logFile.print(GPS.latitudeDegrees, 8);
logFile.print(", ");
logFile.println(GPS.longitudeDegrees, 8);
logFile.close();
} else {
}
} else {
}
}
}
the SPI connections in Examples>SD>ReadWrite are for an UNO
have a look at arduino-mkr1000-wifi-board-pinout for the MKR1000 SPI connections and modify the code
The only modification I could see was the SD.Begin pin. I tried moving that to another digital pin and it still didn't work. Am I missing anything?
/*
SD card read/write
This example shows how to read and write data to and from an SD card file
The circuit:
SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)
created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
*/
#include <SPI.h>
#include <SD.h>
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(6)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop() {
// nothing happens after setup
}
UPDATE - I found the problem. It was with the wiring. I can write to my SD Card now. Thank you for all your help. Cross your fingers everything else is working.
The sketch works. The SD Card is logging the coordinates. The GPS device is working. The only issues are the timestamp is off but that can be fixed after the download. Thank you again for all your help. I wouldn't have gotten this working without you.