SparkFun Forums 

Where electronics enthusiasts find answers.

Tips and questions relating to the GPS modules from SFE
By josepilove
#122324
I am very new to arduino.

I got everything that needed mocked up and planned out on a Arduino Uno, one of the major things was the LS20031 GPS.

I used NSS to print out what i needed to Serial using the following code:
Code: Select all
#include <NewSoftSerial.h>
#include <TinyGPS.h>

TinyGPS gps;
NewSoftSerial nss(2, 3);
int year, month, day, hour, minutes, second, hundredths;
unsigned long fix_age;
void gpsdump(TinyGPS &gps);
bool feedgps();
void printFloat(double f, int digits = 2);

void setup()
{
  Serial.begin(115200);
  nss.begin(57600);
}

void loop(){
  bool newdata = false;
  unsigned long start = millis();
  // Every 5 seconds we print an update
  while (millis() - start < 1000){
    if (feedgps())
      newdata = true;
  }
  if (newdata){
    Serial.println("-------------");
    gpsdump(gps);
    Serial.println("-------------");
  }
}
void printFloat(double number, int digits){
  // Handle negative numbers
  if (number < 0.0){
     Serial.print('-');
     number = -number;
  }
  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
  number += rounding;
  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);
  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print("."); 
  // Extract digits from the remainder one at a time
  while (digits-- > 0){
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint; 
  } 
}
void gpsdump(TinyGPS &gps){
  long lat, lon;
  float flat, flon;
  unsigned long age, date, time, chars;
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;
  feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors
  gps.f_get_position(&flat, &flon, &age);
  Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5);
  feedgps();
  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  if(month&&day&&year){
    Serial.print("Date: "); Serial.print(static_cast<int>(month)); Serial.print("/"); 
    Serial.print(static_cast<int>(day)); Serial.print("/"); 
    Serial.print(year);
  }
  Serial.print("  Time: "); Serial.print(static_cast<int>(hour)); Serial.print(":"); 
  Serial.print(static_cast<int>(minute)); Serial.print(":"); 
  Serial.println(static_cast<int>(second)); 
}
bool feedgps(){
  while (nss.available()){
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}
I also changed the line in NewSoftSerial.h _NewSS_MAX_RX_BUFF to 128.

So i get just what i need with the Arduino Uno, but i would like a smaller package, so i got the arduino Mini Pro 3.3v 328.

I hook everything up the exact same as i did with the Uno and upload the same code. GPS powers on, gets a fix (red blinking light) but I am getting no Serial output.

I am stumped...anyone? Is there something about the Mini Pro that I am missing?

Thanks in advance!
By borelmfg
#123681
The Uno runs at 16Mhz the 3.3V mini runs at 8Mhz. This maybe screwing up the timing for serial port.
Don't have a good solution. Option, purchase mini pro a 5V, that one runs at 16Mhz
By josepilove
#123687
i don't really know much about things, but back in highschool i liked to overclock my computer by increasing the voltage to the chip, making it run faster. I thought that the 16Mhz vs 8Mhz difference only affected the speed of code execution. But...as i said, the only experience i had was primitive and exploratory..and i lit that computer on fire too...so. :)
By trementina
#126256
I have the same problem. All works fine with UNO, but the serial port doen not work win Mini Pro 3.3.
Simply, i think it's an hardware bug, or a bug in the serial Library.

...