Offline
Newbie
Karma: 0
Posts: 3
|
 |
« Reply #30 on: December 23, 2012, 02:44:13 pm » |
Hello again guys, Sorry I was away with family for a bit , Sorry about the format of my code I am still new to this forum I read the rules and Apologize  Here is a correct format of my code  #include <TinyGPS.h> #include <SD.h> #include <stdlib.h> #include <SoftwareSerial.h>
TinyGPS gps; static char dtostrfbuffer[20]; const int chipSelect = 10; int LED = 13;
//Define String String SD_date_time = "invalid"; String SD_lat = "invalid"; String SD_lon = "invalid"; String dataString ="";
static void gpsdump(TinyGPS &gps); static bool feedgps(); static void print_float(float val, float invalid, int len, int prec, int SD_val); static void print_int(unsigned long val, unsigned long invalid, int len); static void print_date(TinyGPS &gps); static void print_str(const char *str, int len);
void setup() { //Serial interfaces Serial.begin(9600); pinMode(10, OUTPUT); //Chip Select Pin for the SD Card pinMode(LED, OUTPUT); //LED Indicator //Connect to the SD Card if (!SD.begin(chipSelect)) { Serial.println("Card Failure"); return; } Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version()); Serial.println("by Mikal Hart"); Serial.println(); Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS)); Serial.println(); Serial.println("Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum"); Serial.println(" (deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail"); Serial.println("--------------------------------------------------------------------------------------------------------------------------------------"); }
void loop() { bool newdata = false; unsigned long start = millis(); // Every second we print an update while (millis() - start < 1000) { if (feedgps()) newdata = true; } gpsdump(gps); //Write the newest information to the SD Card dataString = SD_date_time + "," + SD_lat + "," + SD_lon; if (SD_date_time != "invalid") digitalWrite(LED, HIGH); else digitalWrite(LED, LOW); //Open the Data CSV File File dataFile = SD.open("LOG.csv", FILE_WRITE); if (dataFile) { dataFile.println(dataString); Serial.println(dataString); dataFile.close(); } else { Serial.println("\nCouldn't open the log file!"); } }
static void gpsdump(TinyGPS &gps) { float flat, flon; unsigned long age, date, time, chars = 0; unsigned short sentences = 0, failed = 0; static const float LONDON_LAT = 51.508131, LONDON_LON = -0.128002; print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5); print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5); gps.f_get_position(&flat, &flon, &age); print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5, 1); //LATITUDE print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5, 2); //LONGITUDE print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
print_date(gps); //DATE AND TIME
print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 2, 0); print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2, 0); print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2, 0); print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6); print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0UL : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9); print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : TinyGPS::course_to(flat, flon, 51.508131, -0.128002), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2, 0); print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);
gps.stats(&chars, &sentences, &failed); print_int(chars, 0xFFFFFFFF, 6); print_int(sentences, 0xFFFFFFFF, 10); print_int(failed, 0xFFFFFFFF, 9); Serial.println(); }
static void print_int(unsigned long val, unsigned long invalid, int len) { char sz[32]; if (val == invalid) strcpy(sz, "*******"); else sprintf(sz, "%ld", val); sz[len] = 0; for (int i=strlen(sz); i<len; ++i) sz[i] = ' '; if (len > 0) sz[len-1] = ' '; Serial.print(sz); feedgps(); }
static void print_float(float val, float invalid, int len, int prec, int SD_val) { char sz[32]; if (val == invalid) { strcpy(sz, "*******"); sz[len] = 0; if (len > 0) sz[len-1] = ' '; for (int i=7; i<len; ++i) sz[i] = ' '; Serial.print(sz); if(SD_val == 1) SD_lat = sz; else if(SD_val == 2) SD_lon = sz; } else { Serial.print(val, prec); if (SD_val == 1) SD_lat = dtostrf(val,10,5,dtostrfbuffer); else if (SD_val == 2) SD_lon = dtostrf(val,10,5,dtostrfbuffer); int vi = abs((int)val); int flen = prec + (val < 0.0 ? 2 : 1); flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1; for (int i=flen; i<len; ++i) Serial.print(" "); } feedgps(); }
static void print_date(TinyGPS &gps) { int year; byte month, day, hour, minute, second, hundredths; unsigned long age; gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age); if (age == TinyGPS::GPS_INVALID_AGE) { Serial.print("******* ******* "); SD_date_time = "invalid"; } else { char sz[32]; sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d ", month, day, year, hour, minute, second); Serial.print(sz); SD_date_time = sz; } print_int(age, TinyGPS::GPS_INVALID_AGE, 5); feedgps(); }
static void print_str(const char *str, int len) { int slen = strlen(str); for (int i=0; i<len; ++i) Serial.print(i<slen ? str[i] : ' '); feedgps(); }
static bool feedgps() { while (Serial.available()) { if (gps.encode(Serial.read())) return true; } return false; }
I am also new to C++ , We only did Pascal in my High School. Like a mentioned in my first post I can't seem to log the data to the SD card, I can see Latitude and Longitude on the Serial Monitor at 9600Baud But also with a twist,the Serial Monitor gives out one reading and then the whole header part. I attached the Image with an screenshot of the Serial monitor. I am also using an Arduino Uno R3 and I am also using the Itead-Studio GPS Shield I am using an spare 2GB Flash drive in the onboard SD slot I did format the SD Card to FAT, and I did put the LOG.csv file on the drive But everytime when I test to see if Data has been logged I see no data has been logged to the SD Card. Please guys if someone can point me in the right direction, I am still VERY new to Arduino. Thanks alot guys!
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 316
Posts: 35542
Seattle, WA USA
|
 |
« Reply #31 on: December 23, 2012, 03:45:23 pm » |
Between the TinyGPS library, the SD library, and the String library, I'm guess that you are out of memory. The fact that the Arduino keeps resetting is proof of that.
Laziness is the only reason that the String class is being used in that code. Buck up and get rid of it.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 3
|
 |
« Reply #32 on: December 23, 2012, 07:22:22 pm » |
Thanks Paul! Going to try that. According to Arduino IDE I am using 28046 bytes of the maximum 32,256? Does that mean I have already reached an Threshold amount of bytes?
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 316
Posts: 35542
Seattle, WA USA
|
 |
« Reply #33 on: December 23, 2012, 07:34:47 pm » |
According to Arduino IDE I am using 28046 bytes of the maximum 32,256? That is how much program memory you are using. That says nothing about how much SRAM you are using. A sketch that size, though, pretty much implies more than you have, though. Getting rid of the String class will help. Keeping some of the literal strings out of SRAM will help, too. Serial.print( F("Testing TinyGPS library v. " ));
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #34 on: December 29, 2012, 11:16:19 pm » |
Greetings and Hello, First, excuse me for my poor english. Some days i get two Arduino GPS Shield by iteadstudio (equal from title topic), version 1.1 . Problem number 1 - My two Shield was set to 9600, not 4800. Solution 1 - Easy, simple put Softserial to 9600. This code simple get a value of pins from gps shield, (3 and 4) and send to my pc via default serial. GPS Shield TX/RX(pin 3 and in 4) --> Arduino (SoftwareSerial [read pin 3]) | Arduino (Serial [default]/USB) --> PC (Arduino Serial Monitor) #include <SoftwareSerial.h> SoftwareSerial ss(3,4); char c; void setup() { Serial.begin(115200); ss.begin(9600); Serial.println("Begin..."); delay(1000);
}
void loop() { while (ss.available()) { c = ss.read(); Serial.print(c); } }
Using the program above i get dump from GPS, but not signal from sat's $GPGGA,004651.052,,,,,0,00,,,M,0.0,M,,0000*57 $GPGLL,,,,,004651.052,V*19 $GPGSA,A,1,,,,,,,,,,,,,,,*1E $GPGSV,3,1,12,20,00,000,,10,00,000,,31,00,000,,27,00,000,*7C $GPGSV,3,2,12,19,00,000,,07,00,000,,04,00,000,,24,00,000,*76 $GPGSV,3,3,12,16,00,000,,28,00,000,,26,00,000,,29,00,000,*78 $GPRMC,004651.052,V,,,,,,,291006,,*22 $GPVTG,,T,,M,,N,,K*4E
The dump show me that i dont have any sat (...,,,0,00,,,...). Double zero equal zero sat. $GPGGA,004651.052,,,,,0,00,,,M,0.0,M,,0000*57
I use an Samsung GalaxyTAB and GPS Test+ (Android APP) The android APP show me 08 (eight) sat at equal location from my GPS arduino shield + arduino UNO The only point is a GPS antenna. I dont have a square gps antenna. Questions: Is REALLY need a GPS antenna to get signal from sat's ? Only the shield dont get any sat ? I need to set any parameter or extra configuration to "start" get signal from sat ? Thanks for any help...
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 316
Posts: 35542
Seattle, WA USA
|
 |
« Reply #35 on: December 30, 2012, 06:56:09 am » |
You are doing this testing outside, right?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #36 on: December 30, 2012, 08:31:54 am » |
PaulS,
Yes, about 40 minutes running. Clear Sky, no clouds.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 316
Posts: 35542
Seattle, WA USA
|
 |
« Reply #37 on: December 30, 2012, 11:01:09 am » |
I would certainly have expected you to need an antenna. Ask on the ITEAD forum, or email them directly.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 26
|
 |
« Reply #38 on: January 17, 2013, 02:26:31 pm » |
Hello I'm using the Arduino UNO and Arduino Mega2560 with the GPS Shield 1.1 from Itead Studio. I'm also using the TinyGPS Library and the SerialMonitor from the Arduino Software but I can't get any GPS data. I#m using the "simple_test" from TinyGPS. The RX jumper is on 3 and the TX jumper on 2. The only data I get are stars. Do I have to type something in the SerielMonitor? Sorry for my bad english. BlackDice
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 316
Posts: 35542
Seattle, WA USA
|
 |
« Reply #39 on: January 17, 2013, 02:28:56 pm » |
The only data I get are stars. That means that the GPS IS sending data to the Arduino. But, it isn't getting any data from satellite positions. You are doing this test outside, right?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 26
|
 |
« Reply #40 on: January 17, 2013, 02:32:06 pm » |
Yes I keep the antenna out of the window.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 26
|
 |
« Reply #41 on: January 17, 2013, 02:47:16 pm » |
there is a switch 3,3V or 5V what do I have to choose?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 26
|
 |
« Reply #42 on: January 18, 2013, 03:39:37 am » |
Ok now I'm getting GPS data but only with the Arduino UNO. I get only stars with the Arduino MEGA 2560. This is my Programm #include <TinyGPS.h> //Shield Einstellung //rx = 1 //tx = 0
TinyGPS gps;
static void gpsdump(TinyGPS &gps); static bool feedgps(); static void print_float(float val, float invalid, int len, int prec); static void print_int(unsigned long val, unsigned long invalid, int len); static void print_date(TinyGPS &gps); static void print_str(const char *str, int len);
void setup() { Serial.begin(9600); Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version()); Serial.println("by Mikal Hart"); Serial.println(); Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS)); Serial.println(); Serial.println("Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum"); Serial.println(" (deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail"); Serial.println("--------------------------------------------------------------------------------------------------------------------------------------"); }
void loop() { bool newdata = false; unsigned long start = millis(); // Every second we print an update while (millis() - start < 1000) { if (feedgps()) newdata = true; } gpsdump(gps); }
static void gpsdump(TinyGPS &gps) { float flat, flon; unsigned long age, date, time, chars = 0; unsigned short sentences = 0, failed = 0; static const float LONDON_LAT = 51.508131, LONDON_LON = -0.128002; print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5); print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5); gps.f_get_position(&flat, &flon, &age); print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5); print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5); print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
print_date(gps);
print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 2); print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2); print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2); print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6); print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0UL : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9); print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : TinyGPS::course_to(flat, flon, 51.508131, -0.128002), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2); print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);
gps.stats(&chars, &sentences, &failed); print_int(chars, 0xFFFFFFFF, 6); print_int(sentences, 0xFFFFFFFF, 10); print_int(failed, 0xFFFFFFFF, 9); Serial.println(); }
static void print_int(unsigned long val, unsigned long invalid, int len) { char sz[32]; if (val == invalid) strcpy(sz, "*******"); else sprintf(sz, "%ld", val); sz[len] = 0; for (int i=strlen(sz); i<len; ++i) sz[i] = ' '; if (len > 0) sz[len-1] = ' '; Serial.print(sz); feedgps(); }
static void print_float(float val, float invalid, int len, int prec) { char sz[32]; if (val == invalid) { strcpy(sz, "*******"); sz[len] = 0; if (len > 0) sz[len-1] = ' '; for (int i=7; i<len; ++i) sz[i] = ' '; Serial.print(sz); } else { Serial.print(val, prec); int vi = abs((int)val); int flen = prec + (val < 0.0 ? 2 : 1); flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1; for (int i=flen; i<len; ++i) Serial.print(" "); } feedgps(); }
static void print_date(TinyGPS &gps) { int year; byte month, day, hour, minute, second, hundredths; unsigned long age; gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age); if (age == TinyGPS::GPS_INVALID_AGE) Serial.print("******* ******* "); else { char sz[32]; sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d ", month, day, year, hour, minute, second); Serial.print(sz); } print_int(age, TinyGPS::GPS_INVALID_AGE, 5); feedgps(); }
static void print_str(const char *str, int len) { int slen = strlen(str); for (int i=0; i<len; ++i) Serial.print(i<slen ? str[i] : ' '); feedgps(); }
static bool feedgps() { while (Serial.available()) { if (gps.encode(Serial.read())) return true; } return false; }
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 316
Posts: 35542
Seattle, WA USA
|
 |
« Reply #43 on: January 18, 2013, 04:10:39 pm » |
You have 4 hardware serial ports on the Mega. One can be used for debugging, so that is the one that you connected the GPS to. Why?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #44 on: January 19, 2013, 07:42:21 am » |
Hi everybody,
I recently bought this GPS Shield (1 week ago). Still fighting in order to receive coordonnantes from sats. No stats detected ? added external antenna but still no sat ?
Here are some gsp data :
$GPGGA,123505.587,,,,,0,00,,,M,0.0,M,,0000*5C $GPGLL,,,,,123505.587,V*12 $GPGSA,A,1,,,,,,,,,,,,,,,*1E $GPGSV,3,1,12,04,69,044,33,16,58,290,,12,49,301,,17,35,094,35*75 $GPGSV,3,2,12,31,15,260,28,06,13,292,,30,13,317,,09,13,296,*7C $GPGSV,3,3,12,28,03,150,,02,02,241,,01,00,045,,23,-2,113,*6D $GPRMC,123505.587,V,,,,,,,190113,,*2E $GPVTG,,T,,M,,N,,K*4E CHARS=38111 SENTENCES=0 CSUM ERR=0 $GPGGA,123506.583,,,,,0,00,,,M,0.0,M,,0000*5B $GPGLL,,,,,123506.583,V*15 $GPGSA,A,1,,,,,,,,,,,,,,,*1E $GPRMC,123506.583,V,,,,,,,190113,,*29 $GPVTG,,T,,M,,N,,K*4E CHARS=38278 SENTENCES=0 CSUM ERR=0
Any idea ? Thanks for your help
|
|
|
|
|
Logged
|
|
|
|
|
|