Ultimate GPS Logger Shield - enable pin?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88155
- Joined: Sat Feb 07, 2009 10:11 am
Re: Ultimate GPS Logger Shield - enable pin?
Without detailed photos of your wiring or a complete listing of your code, there is not much to go on.
-
- Posts: 15
- Joined: Tue Feb 04, 2014 4:29 am
Re: Ultimate GPS Logger Shield - enable pin?
So let's take a look at my code then:
On the Uno, this works well. However, like I said, it does not on the breadboard.
I followed this schematic and connected all 18 headers marked with a green dot to the corresponding pins on the atmega328 (look here). Did I miss something there?
Code: Select all
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#include <SD.h>
#include <avr/sleep.h>
// Ladyada's logger modified by Bill Greiman to use the SdFat library
//
// This code shows how to listen to the GPS module in an interrupt
// which allows the program to have more 'freedom' - just parse
// when a new NMEA sentence is available! Then access data when
// desired.
//
// Tested and works great with the Adafruit Ultimate GPS Shield
// using MTK33x9 chipset
// ------> http://www.adafruit.com/products/
// Pick one up today at the Adafruit electronics shop
// and help support open source hardware & software! -ada
SoftwareSerial mySerial(8, 7);
Adafruit_GPS GPS(&mySerial);
unsigned long time1, time2;
boolean moving;
// 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
/* set to true to only log to SD when GPS has a fix, for debugging, keep it false */
#define LOG_FIXONLY false
// Set the pins used
#define chipSelect 10
#define ledPin 13
#define LOGGER_ID "00"
File logfile;
// read a Hex value and return the decimal equivalent
uint8_t parseHex(char c) {
if (c < '0')
return 0;
if (c <= '9')
return c - '0';
if (c < 'A')
return 0;
if (c <= 'F')
return (c - 'A')+10;
}
// blink out an error code
void error(uint8_t errno) {
/*
if (SD.errorCode()) {
putstring("SD error: ");
Serial.print(card.errorCode(), HEX);
Serial.print(',');
Serial.println(card.errorData(), HEX);
}
*/
while(1) {
uint8_t i;
for (i=0; i<errno; i++) {
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
}
for (i=errno; i<10; i++) {
delay(200);
}
}
}
void setup() {
// for Leonardos, if you want to debug SD issues, uncomment this line
// to see serial output
//while (!Serial);
// connect at 115200 so we can read the GPS fast enough and echo without dropping chars
// also spit it out
Serial.begin(115200);
Serial.println("\r\nUltimate GPSlogger Shield");
pinMode(ledPin, OUTPUT);
moving = true;
// make sure that the default chip select pin is set to
// output, even if you don't use it:
pinMode(10, OUTPUT);
// see if the card is present and can be initialized:
//if (!SD.begin(chipSelect, 11, 12, 13)) {
if (!SD.begin(chipSelect)) { // if you're using an UNO, you can use this line instead
Serial.println("Card init. failed!");
error(2);
}
char filename[18];
strcpy(filename, "GPSLOG00.TXT");
for (uint8_t i = 0; i < 100; i++) {
filename[6] = '0' + i/10;
filename[7] = '0' + i%10;
// create if does not exist, do not open existing, write, sync after write
if (! SD.exists(filename)) {
break;
}
}
logfile = SD.open(filename, FILE_WRITE);
if( ! logfile ) {
Serial.print("Couldnt create "); Serial.println(filename);
error(3);
}
Serial.print("Writing to "); Serial.println(filename);
// connect to the GPS at the desired rate
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 logging data, we don't suggest using anything but either RMC only or RMC+GGA
// to keep the log files at a reasonable size
// Set the update rate
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_5HZ); // 1 or 5 Hz update rate
// Turn off updates on antenna status, if the firmware permits it
//GPS.sendCommand(PGCMD_NOANTENNA);
//Set nav speed threshold (1.5m/s)
GPS.sendCommand(PMTK_SET_NAV_SPEED_TH_15);
Serial.println("Ready!");
}
void go_sleep() {
GPS.sendCommand(PMTK_STANDBY);
delay(20);
Serial.println("\r\nGoing to sleep...");
attachInterrupt(0, wakeup, LOW);
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
delay(20);
sleep_enable();
sleep_mode();
}
void wakeup() {
detachInterrupt(0);
moving = true;
time1 = 0;
time2 = 0;
}
void loop() {
char c = GPS.read();
if (GPSECHO)
if (c) Serial.print(c);
if ((GPS.speed < 2.5 || !GPS.fix) && moving) {
moving = false;
time1 = millis();
}
if (GPS.speed >= 2.5) moving = true;
if ((GPS.speed < 2.5 || !GPS.fix) && !moving) {
time2 = millis();
if (time2 - time1 >= 300000) go_sleep();
}
// 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 trying 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
// Sentence parsed!
Serial.println("OK");
if (LOG_FIXONLY && !GPS.fix) {
Serial.print("No Fix");
return;
}
// Rad. lets log it!
Serial.println("Log");
char *stringptr = GPS.lastNMEA();
uint8_t stringsize = strlen(stringptr);
if (stringsize != logfile.write((uint8_t *)stringptr, stringsize)) //write the string to the SD file
error(4);
if (strstr(stringptr, "RMC")) logfile.flush();
Serial.println();
}
}
/* End code */
I followed this schematic and connected all 18 headers marked with a green dot to the corresponding pins on the atmega328 (look here). Did I miss something there?
- adafruit_support_bill
- Posts: 88155
- Joined: Sat Feb 07, 2009 10:11 am
Re: Ultimate GPS Logger Shield - enable pin?
If the code and the chip work in an UNO, that pretty much narrows it down to your breadboard then. As you can see, there is nothing between the Atmega 328 pins and the headers for those connections.
-
- Posts: 15
- Joined: Tue Feb 04, 2014 4:29 am
Re: Ultimate GPS Logger Shield - enable pin?
Alright, I just worried maybe some part on the Uno was crucial to the shield working. I'll just solder a socket to the proto area then and try again. Do you think running the µC on 8Mhz will cause any problems? I'd like to save some space by leaving out the quartz and capacitors.
and by the way: why are the first 4 analogue pins connected? I read in another post the shield does not use them.
and by the way: why are the first 4 analogue pins connected? I read in another post the shield does not use them.
- adafruit_support_bill
- Posts: 88155
- Joined: Sat Feb 07, 2009 10:11 am
Re: Ultimate GPS Logger Shield - enable pin?
It will change your serial communication timing. Check the Arduino.cc forums. I believe there are workarounds for this.Do you think running the µC on 8Mhz will cause any problems?
These are only connected to breakout holes on the shield.why are the first 4 analogue pins connected?
-
- Posts: 15
- Joined: Tue Feb 04, 2014 4:29 am
Re: Ultimate GPS Logger Shield - enable pin?
Ok, so I'm just gonna leave them out. Do I understand correctly that the SPI pins are not used either? That would leave me with only D0, D1, D7, D8 and 5v/gnd/reset, which would be great.These are only connected to breakout holes on the shield.
- adafruit_support_bill
- Posts: 88155
- Joined: Sat Feb 07, 2009 10:11 am
Re: Ultimate GPS Logger Shield - enable pin?
SPI is used to talk to the SD card.
-
- Posts: 15
- Joined: Tue Feb 04, 2014 4:29 am
Re: Ultimate GPS Logger Shield - enable pin?
alright, I'll stick to it then. Thanks. I have to say the support here is sublime.adafruit_support_bill wrote:SPI is used to talk to the SD card.
- engineercarl
- Posts: 56
- Joined: Fri Nov 22, 2013 6:47 pm
Re: Ultimate GPS Logger Shield - enable pin?
I ran into a SRAM crash when I tried to get the GPS logger flying on a UNO r3. The SD needs a 512 byte buffer and the GPS library uses a fair bit of memory. You might look here http://forums.adafruit.com/viewtopic.php?f=31&t=50509. You can follow down through the thread to see my process of debugging, or just skip to the last comment to find my final code. SRAM crashes are hard to find.
Also have you considered the BoArduino http://www.adafruit.com/products/72 option? I have embedded a couple of them in projects with great success. The DC kit has the advantage that you can leave out the pieces you don't need. For example, I didn't need a 5V regulator or the power LED, so I just didn't use them. A small note, you will need a TTL-USB converter like http://www.adafruit.com/products/284. These also come in a cable form http://www.adafruit.com/products/70.
Also have you considered the BoArduino http://www.adafruit.com/products/72 option? I have embedded a couple of them in projects with great success. The DC kit has the advantage that you can leave out the pieces you don't need. For example, I didn't need a 5V regulator or the power LED, so I just didn't use them. A small note, you will need a TTL-USB converter like http://www.adafruit.com/products/284. These also come in a cable form http://www.adafruit.com/products/70.
- splat01
- Posts: 9
- Joined: Fri Jun 28, 2013 2:37 pm
Re: Ultimate GPS Logger Shield - enable pin?
I'm looking to build a similar, low-powered GPS using the ultimate GPS (w/ enable pin). I was, however, interested in how you wake the Arduino up after putting it to sleep? Would the RTC be able to do this?
Thanks.
Thanks.
Please be positive and constructive with your questions and comments.