Changing baudrate of a GPS module

Hello Friends,

I’m trying to make a speedometer by using an Arduino, I want that the speed is updated as much as possible. That means a high update rate and a LOT OF DATA. Sometimes I got a delayed speed. That is why I (think I) need a higher baud rate. In sketch is a setup-part for the GPS module. You can choose the update rate and the baud rate. I got the setup part of the code from someone else. He included a description : ‘‘delay(5); // simulating a 38400baud pace (or less), otherwise commands are not accepted by the device.’’
He says that you need a baud rate of 38400 or lower. But I want a higher baud rate to let’s say 115200 baud. So this is my problem: the GPS module accepts the 38400 baud command but not the 115200 baud command.

Someone who can help me out?
If you got any tips, they are welcome
My code:

#include <NeoSWSerial.h>//Include Software Serial Library
#include <U8glib.h> // Include the OLED library
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0); // Define a certain part of the OLED library
#include "TinyGPS++.h"// include  GPS library


#define u8g_logo_sat_width 19                                   //
#define u8g_logo_sat_height 19                                  //
const unsigned char u8g_logo_sat[] = {                          //
  //
  0x80, 0x1F, 0x00, 0xF0, 0x70, 0x00, 0x18, 0xC0, 0x00, 0x0C, 0x80, 0x01, //
  0x06, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x06, 0x03, 0x07, 0x04, //
  0x01, 0x07, 0x04, 0x01, 0x07, 0x04, 0x01, 0x07, 0x04, 0x83, 0x0D, 0x04, // GPS ICON Image
  0x82, 0x08, 0x02, 0x82, 0x08, 0x02, 0x06, 0x00, 0x03, 0x0C, 0x80, 0x01, //
  0x18, 0xC0, 0x00, 0x70, 0x70, 0x00, 0xC0, 0x1F, 0x00,          //
  //
};                                                              //

NeoSWSerial serial_connection(3, 4); //Define Serial Pins
TinyGPSPlus gps; // Define gps object
//Creating some variables:

double gps_speed;
double Lat;
double Long;
double timehour;
double timedistance;
double traveleddistancesum;
double traveleddistance;
double traveleddistance1;

//GPS Module Setup, this is sent in "void GPSSETUP()"
const unsigned char UBLOX_INIT[] PROGMEM = {
  //0xB5,0x62,0x06,0x08,0x06,0x00,0xF4,0x01,0x01,0x00,0x01,0x00,0x0B,0x77//(2 Hz)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0xC8,0x00,0x01,0x00,0x01,0x00,0xDE,0x6A, //(5Hz)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0xE8,0x03,0x01,0x00,0x01,0x00,0x01,0x39, //(1Hz)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0x64,0x00,0x01,0x00,0x01,0x00,0x7A,0x12, //(10Hz)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0xBC,0x02,0x01,0x00,0x01,0x00,0xD4,0x2C,//(1,43 Hz/700 ms)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0x58,0x02,0x01,0x00,0x01,0x00,0x70,0xD4, //(1,67Hz/600 ms)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0x64,0x00,0x01,0x00,0x01,0x00,0x7A,0x12, //(10Hz)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0xC8,0x00,0x01,0x00,0x01,0x00,0xDE,0x6A, //(5Hz)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0xE8,0x03,0x01,0x00,0x01,0x00,0x01,0x39 //(1Hz)
  0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xFA, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x96, //(4HZ)

  // The next sentence will set the baudrate to the one you choose
  //0xB5,0x62,0x06,0x00,0x14,0x00,0x01,0x00,0x00,0x00,0xD0,0x08,0x00,0x00,0x00,0x96,0x00,0x00,0x23,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xAE,0x6A,
  0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x23, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x70, // 38400
  //0xB5,0x62,0x06,0x00,0x14,0x00,0x01,0x00,0x00,0x00,0xD0,0x08,0x00,0x00,0x00,0xC2,0x01,0x00,0x23,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0xDC,0x5E, //115200
};


void setup() {
  Serial.begin(115200);//This opens up communications to the Serial monitor in the Arduino IDE
  Serial.println("Welcome to the Speedometer");




  GPSSETUP();
  delay(1000);
}


void loop() {
  // Calculate traveled distance since the arduino is powered:
  traveleddistancesum = (gps.speed.mps() * (millis() - timedistance) / 1000);
  timedistance = millis();
  traveleddistance = ((traveleddistance + traveleddistancesum));
  traveleddistance1 = ((traveleddistance) / 1000);

  //---------------------------------------------------------------------------------------//
  //--------------------------------------Start GPS Prosess--------------------------------//
  //---------------------------------------------------------------------------------------//
  uint8_t GPSchar; //Creating a variable for the gps data


  while (1)
  {
    if (serial_connection.available() > 0)
    {


      GPSchar = serial_connection.read();


      gps.encode(GPSchar);

      Serial.write(GPSchar);

    }

    if (gps.location.isUpdated() && gps.altitude.isUpdated())
    {
      break;// if gps location is updated than continue the loop
    }
  }
  
  // Setting variables:
  gps_speed = (gps.speed.kmph());
  Lat = (gps.location.lat());
  Long = (gps.location.lng());
  timehour = (gps.time.hour() + 1);

  //---------------------------------------------------------------------------------------//
  //--------------------------------Start Printing Prosess---------------------------------//
  //---------------------------------------------------------------------------------------//
  u8g.firstPage();

  do {
    u8g.setFont(u8g_font_unifont);

    u8g.setPrintPos(56, 43);
    u8g.print("km/h");


    u8g.setFont(u8g_font_profont29r);
    u8g.setPrintPos(0, 47);
    u8g.print(gps_speed , 0);
    u8g.setFont(u8g_font_6x10);
    u8g.setPrintPos(0, 62);
    u8g.print("N");
    u8g.setFont(u8g_font_6x10);
    u8g.setPrintPos(7, 62);
    u8g.print( Lat, 6);

    u8g.setPrintPos(73, 62);
    u8g.print("E");

    u8g.setPrintPos(80, 62);
    u8g.print( Long, 6);
    u8g.drawLine(0, 52, 128, 52);
    u8g.drawLine(0, 22, 128, 22);
    u8g.drawLine(89, 22, 89, 52);
    u8g.drawXBM(0, 0, u8g_logo_sat_width, u8g_logo_sat_height, u8g_logo_sat);
    u8g.setFont(u8g_font_unifont);
    u8g.setPrintPos(23, 15);
    if (((gps.course.deg()))  >= 0 && ((gps.course.deg())) <= 22.5) {
      u8g.print("Noord");
    }
    if (((gps.course.deg())) > 22.5 && ((gps.course.deg())) <= 67.5) {
      u8g.print("Noord - Oost");
    }
    if (((gps.course.deg())) > 67.5 && ((gps.course.deg())) <=  112.5 ) {
      u8g.print("Oost");
    }

    if (((gps.course.deg())) > 112.5 && (gps.course.deg()) <= 157.5) {
      u8g.print("Zuid - Oost");

    }
    if ((gps.course.deg()) > 157.5 && (gps.course.deg()) <= 202.5) {
      u8g.print("Zuid");
    }
    if ((gps.course.deg()) > 202.5 && (gps.course.deg()) <= 247.5) {
      u8g.print("Zuid - West");
    }
    if ((gps.course.deg()) > 247.5 && (gps.course.deg()) <= 292.5) {
      u8g.print("West");
    }
    if ((gps.course.deg()) > 292.5 && (gps.course.deg()) <= 337.5) {
      u8g.print("Noord - West");
    }
    if ((gps.course.deg()) > 337.5 && (gps.course.deg()) <= 361) {
      u8g.print("Noord");
    }
    u8g.setPrintPos(92, 49);
    u8g.setFont(u8g_font_6x10);
    if (traveleddistance < 1000 ) {


      u8g.print((traveleddistance), 0);

      u8g.setPrintPos(120, 49);
      u8g.print("M");
    }

    if (traveleddistance1 > 1 && traveleddistance1 < 100 ) {
      u8g.print((traveleddistance1));

    }
    if (traveleddistance1 > 100 ) {
      u8g.print((traveleddistance1), 1);

    }
    u8g.setFont(u8g_font_unifont);
    u8g.setPrintPos(90, 35);
    if (timehour > 23) {
      u8g.print("00");

    }


    else   {

      u8g.print(timehour, 0);
    }
    u8g.drawLine(89, 38, 128, 38);
    u8g.setPrintPos(111, 35);
    u8g.setFont(u8g_font_unifont);
    u8g.print(gps.time.minute());
    if ( (gps.time.second() % 2) == 0) { // this makes the dots blink (in the time bar)
      u8g.setFont(u8g_font_unifont);
      u8g.setPrintPos(105, 35);
      u8g.print(":");

    }
  }

  while (u8g.nextPage());



}
//---------------------------------------------------------------------------------------//
//--------------------------------Run the GPS setup once--------------------------------//
//---------------------------------------------------------------------------------------//
void GPSSETUP() {
  serial_connection.begin(9600);//
  // send configuration data in UBX protocol
  for (unsigned int i = 0; i < sizeof(UBLOX_INIT); i++) {
    serial_connection.write( pgm_read_byte(UBLOX_INIT + i) );
    delay(5); // simulating a 38400baud pace (or less), otherwise commands are not accepted by the device.

  }
  serial_connection.begin(38400);
//serial_connection.begin(115200);
  // send configuration data in UBX protocol
  for (unsigned int i = 0; i < sizeof(UBLOX_INIT); i++) {
    serial_connection.write( pgm_read_byte(UBLOX_INIT + i) );
    delay(5); // simulating a 38400baud pace (or less), otherwise commands are not accepted by the device.

  }

}

Stuff I’m using:
Ublox NEO-M7N
Arduino Nano V3.0 Atmega 328P
128x64 I2C OLED display

arjanpals:
So this is my problem: the GPS module accepts the 38400 baud command but not the 115200 baud command.

Is it? Your top secret GPS module is either configurable for 115200 or it isn't, but who would ever know?
Further, it may easily be that GPS has its own limitations on update speed and running at 115200 is pointless. I recently drove all over New Zealand using a Garmin satnav as a speedo. It did a fine job but I don't think it was a substitute for the real thing from Bavaria.

I don't know anything about the software serial you are using, but using it at 115200 is probably asking for trouble, and you should consider running GPS on hardware serial if you intend to use that rate.

Telling us what Arduino you are using is obviously quite important too, can you say ?

As a general point I would suggest concentrating on one part of the problem at a time, for instance, first start with the smallest possible program and try and change just the baud rate.

Your NeoSWSerial library is limited to only 4 baudrates, 9600 (default), 19200, 31250 (MIDI) and 38400.

Also, what good would a 115K2 baudrate do if your GPS updates only 10 times per second?

I am using a speedo in my car based on a Neo6M and Nano with a 4-digit 7-segment LED display. Works well. The only lag I notice is when I brake to a stop -- the speed displayed takes some seconds to come to zero, but it's not consistent. I don't know where in the system this lag is caused. It doesn't bother me -- at driving speeds there is no noticeable difference between the display and the car's speedo.

I've been messing with this for over a year and I can offer a few tips.

To explore the capabilities of the GPS receiver, like baud rates, don't use Arduino and your own sketch. Use the u-center software from u-blox. This is so much more powerful and reliable than any sketch we could make.

At first I tried an OLED display and displayed speed, time and course. The drawing rate was too slow. Could that be the source of your lag? Difficult to read in sunlight as well. The LED display refresh is instant and it is so easy to read.

I've come to believe it's a mistake to have an expectation of what we can achieve with a GPS device. When we don't achieve that expectation we go looking for the deficiences in the hardware. The sensible approach is to see what the GPS receiver can do and then write code to make use of it. The recommendation from srnet is spot on -- tackle one technical issue at a time.

I have the GPS at 1Hz sampling rate and 9600 baud (the defaults). I update the display at 1Hz. This works well. The driver can't make use of a higher display rate.

I can't see that the baud rate matters.

Good luck,
John.

You want to look into the update rate the GPS is spitting out. Usually, 1Hz update rate is enough for knowing your position. 10Hz if you want to know more in the same timeframe from which you can calculate speed, heading and so on.

The fastest civilian GPS availabe, according to the webs is the venus838flpx. This one is 50Hz and a breakout board can be bought on Tindie.com, just google venus838flpx-gps-breakout-board and work from there.

Yes, the venus GPS can do 115K2 baudrate but it's the update rate you want to be the most interested in.

Leroy,

The GPS provides the speed and course, there's no need to do any calculations.

John.

HillmanImp, you are correct. I was more referring to doing any external calculations on the data.

Leroy,

Okay – sorry.

It would be interesting to determine the time for the GPS to transmit its data packet, and the time to perform all the tasks done by the sketch. What do you reckon the ratio would be? In a one second period, maybe the data packet takes <100ms at 9600 baud, leaving up to 900ms for the sketch to do its loop.

John.

Leroy2007:
Also, what good would a 115K2 baudrate do if your GPS updates only 10 times per second?

I noticed when I used a higher update rate (>1Hz) the displayed has a delay, when I used a higher baud rate the delay was gone. The delay comes back at around 4Hz so I was thinking when I increase the baud rate. I can get a even higher update rates

Software serial libraries generally cap out at 38400 baud. If you want to run the GPS faster than that you'll need something that has multiple hardware serial ports.

arjanpals:
I noticed when I used a higher update rate (>1Hz) the displayed has a delay, when I used a higher baud rate the delay was gone. The delay comes back at around 4Hz so I was thinking when I increase the baud rate. I can get a even higher update rates

Thats possibly because the GPS is taking a while to put out all the default NMEA sentences, and its taking longer than 1 second at 9600baud.

You would normally disable all but GPGGA and GPRMC, so the GPS has plenty of time to send them at 1Hz.

However, I suspect you ought to be checking the basics, like how long it takes the display to update, that is likely a significant bottlekneck .................

HillmanImp:
Leroy,

Okay – sorry.

It would be interesting to determine the time for the GPS to transmit its data packet, and the time to perform all the tasks done by the sketch. What do you reckon the ratio would be? In a one second period, maybe the data packet takes <100ms at 9600 baud, leaving up to 900ms for the sketch to do its loop.

John.

The maximum NMEA sentence length is 82 bytes, so, in theory and I’m no expert, we can calculate how long it would take the GPS unit to send one complete NMEA sentence.

The thing to keep in mind is, in my opinion, that the GPS unit itself has already parsed the sentences and made available to the TX port but it may still be transmitting or is not ready to receive?

My impression from much messing around is that the GPS receiver delivers its data packet in a short time and the Arduino has a ton of time to do its tasks. My impression is that one second is plenty of time to achieve both.

If I wanted to increase the rate of data transmission (but I don't know why this is needed) I would experiment in u-center. Increase the sampling rate and find where the communications starts to fall over.

The slowest player in the GPS speedometer scenario is the driver of the car. The driver cannot watch the display continuously. What they need is that when they look at the display it is displaying a value that is close to the car's current speed.

John.

Hello everyone,

Thank y’all for replying. I modified the sketch a bit and now I’m running on hardware serial instead of software serial. But there is another problem now: if I have an update rate of 5 Hz or higher than my speed is only updating twice per second, BUT the coordinates are changing at that certain update rate. That is very strange to me…

The modified code:

//#include <NeoSWSerial.h>//Include Software Serial Library
#include <U8glib.h> // Include the OLED library
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0); // Define a certain part of the OLED library
#include "TinyGPS++.h"// include  GPS library


#define u8g_logo_sat_width 19                                   //
#define u8g_logo_sat_height 19                                  //
const unsigned char u8g_logo_sat[] = {                          //
  //
  0x80, 0x1F, 0x00, 0xF0, 0x70, 0x00, 0x18, 0xC0, 0x00, 0x0C, 0x80, 0x01, //
  0x06, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x06, 0x03, 0x07, 0x04, //
  0x01, 0x07, 0x04, 0x01, 0x07, 0x04, 0x01, 0x07, 0x04, 0x83, 0x0D, 0x04, // GPS ICON Image
  0x82, 0x08, 0x02, 0x82, 0x08, 0x02, 0x06, 0x00, 0x03, 0x0C, 0x80, 0x01, //
  0x18, 0xC0, 0x00, 0x70, 0x70, 0x00, 0xC0, 0x1F, 0x00,          //
  //
};                                                              //
#define serial_connection Serial
//NeoSWSerial serial_connection(3, 4); //Define Serial Pins
TinyGPSPlus gps; // Define gps object
//Creating some variables:

double gps_speed;
double Lat;
double Long;
double timehour;
double timedistance;
double traveleddistancesum;
double traveleddistance;
double traveleddistance1;

//GPS Module Setup, this is sent in "void GPSSETUP()"
const unsigned char UBLOX_INIT[] PROGMEM = {
  //0xB5,0x62,0x06,0x08,0x06,0x00,0xF4,0x01,0x01,0x00,0x01,0x00,0x0B,0x77//(2 Hz)
 // 0xB5,0x62,0x06,0x08,0x06,0x00,0xC8,0x00,0x01,0x00,0x01,0x00,0xDE,0x6A, //(5Hz)
    //0xB5,0x62,0x06,0x08,0x06,0x00,0xC8,0x00,0x01,0x00,0x01,0x00,0xDE,0x6A, //(5Hz)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0xE8,0x03,0x01,0x00,0x01,0x00,0x01,0x39, //(1Hz)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0x64,0x00,0x01,0x00,0x01,0x00,0x7A,0x12, //(10Hz)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0xBC,0x02,0x01,0x00,0x01,0x00,0xD4,0x2C,//(1,43 Hz/700 ms)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0x58,0x02,0x01,0x00,0x01,0x00,0x70,0xD4, //(1,67Hz/600 ms)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0x64,0x00,0x01,0x00,0x01,0x00,0x7A,0x12, //(10Hz)
  //0xB5,0x62,0x06,0x08,0x06,0x00,0xE8,0x03,0x01,0x00,0x01,0x00,0x01,0x39 //(1Hz)
  0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xFA, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x96, //(4HZ)

  // The next sentence will set the baudrate to the one you choose
  //0xB5,0x62,0x06,0x00,0x14,0x00,0x01,0x00,0x00,0x00,0xD0,0x08,0x00,0x00,0x00,0x96,0x00,0x00,0x23,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xAE,0x6A,
  0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x23, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x70, // 38400
  //0xB5,0x62,0x06,0x00,0x14,0x00,0x01,0x00,0x00,0x00,0xD0,0x08,0x00,0x00,0x00,0xC2,0x01,0x00,0x23,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0xDC,0x5E, //115200
};


void setup() {
Serial.begin(9600);
  GPSSETUP();
  // delay(1000);
}


void loop() {
  // Calculate traveled distance since the arduino is powered:
  traveleddistancesum = (gps.speed.mps() * (millis() - timedistance) / 1000);
  timedistance = millis();
  traveleddistance = ((traveleddistance + traveleddistancesum));
  traveleddistance1 = ((traveleddistance) / 1000);

  //---------------------------------------------------------------------------------------//
  //--------------------------------------Start GPS Prosess--------------------------------//
  //---------------------------------------------------------------------------------------//
  uint8_t GPSchar; //Creating a variable for the gps data


  while (1)
  {
    if (serial_connection.available() > 0)
    {


      GPSchar = serial_connection.read();


      gps.encode(GPSchar);

      //Serial.write(GPSchar);

    }

    if (gps.location.isUpdated() && gps.altitude.isUpdated())
    {
      break;// if gps location is updated than continue the loop
    }
  }
  
  // Setting variables:
  gps_speed = (gps.speed.kmph());
  Lat = (gps.location.lat());
  Long = (gps.location.lng());
  timehour = (gps.time.hour() + 1);

  //---------------------------------------------------------------------------------------//
  //--------------------------------Start Printing Prosess---------------------------------//
  //---------------------------------------------------------------------------------------//
  u8g.firstPage();

  do {
    u8g.setFont(u8g_font_unifont);

    u8g.setPrintPos(56, 43);
    u8g.print("km/h");


    u8g.setFont(u8g_font_profont29r);
    u8g.setPrintPos(0, 47);
    u8g.print(gps_speed , 0);
    u8g.setFont(u8g_font_6x10);
    u8g.setPrintPos(0, 62);
    u8g.print("N");
    u8g.setFont(u8g_font_6x10);
    u8g.setPrintPos(7, 62);
    u8g.print( Lat, 6);

    u8g.setPrintPos(73, 62);
    u8g.print("E");

    u8g.setPrintPos(80, 62);
    u8g.print( Long, 6);
    u8g.drawLine(0, 52, 128, 52);
    u8g.drawLine(0, 22, 128, 22);
    u8g.drawLine(89, 22, 89, 52);
    u8g.drawXBM(0, 0, u8g_logo_sat_width, u8g_logo_sat_height, u8g_logo_sat);
    u8g.setFont(u8g_font_unifont);
    u8g.setPrintPos(23, 15);
    if (((gps.course.deg()))  >= 0 && ((gps.course.deg())) <= 22.5) {
      u8g.print("Noord");
    }
    if (((gps.course.deg())) > 22.5 && ((gps.course.deg())) <= 67.5) {
      u8g.print("Noord - Oost");
    }
    if (((gps.course.deg())) > 67.5 && ((gps.course.deg())) <=  112.5 ) {
      u8g.print("Oost");
    }

    if (((gps.course.deg())) > 112.5 && (gps.course.deg()) <= 157.5) {
      u8g.print("Zuid - Oost");

    }
    if ((gps.course.deg()) > 157.5 && (gps.course.deg()) <= 202.5) {
      u8g.print("Zuid");
    }
    if ((gps.course.deg()) > 202.5 && (gps.course.deg()) <= 247.5) {
      u8g.print("Zuid - West");
    }
    if ((gps.course.deg()) > 247.5 && (gps.course.deg()) <= 292.5) {
      u8g.print("West");
    }
    if ((gps.course.deg()) > 292.5 && (gps.course.deg()) <= 337.5) {
      u8g.print("Noord - West");
    }
    if ((gps.course.deg()) > 337.5 && (gps.course.deg()) <= 361) {
      u8g.print("Noord");
    }
    u8g.setPrintPos(92, 49);
    u8g.setFont(u8g_font_6x10);
    if (traveleddistance < 1000 ) {


      u8g.print((traveleddistance), 0);

      u8g.setPrintPos(120, 49);
      u8g.print("M");
    }

    if (traveleddistance1 > 1 && traveleddistance1 < 100 ) {
      u8g.print((traveleddistance1));

    }
    if (traveleddistance1 > 100 ) {
      u8g.print((traveleddistance1), 1);

    }
    u8g.setFont(u8g_font_unifont);
    u8g.setPrintPos(90, 35);
    if (timehour > 23) {
      u8g.print("00");

    }


    else   {

      u8g.print(timehour, 0);
    }
    u8g.drawLine(89, 38, 128, 38);
    u8g.setPrintPos(111, 35);
    u8g.setFont(u8g_font_unifont);
    u8g.print(gps.time.minute());
    if ( (gps.time.second() % 2) == 0) { // this makes the dots blink (in the time bar)
      u8g.setFont(u8g_font_unifont);
      u8g.setPrintPos(105, 35);
      u8g.print(":");

    }
  }

  while (u8g.nextPage());



}
//---------------------------------------------------------------------------------------//
//--------------------------------Run the GPS setup once--------------------------------//
//---------------------------------------------------------------------------------------//
void GPSSETUP() {
  serial_connection.begin(9600);//
  // send configuration data in UBX protocol
  for (unsigned int i = 0; i < sizeof(UBLOX_INIT); i++) {
    serial_connection.write( pgm_read_byte(UBLOX_INIT + i) );
    delay(5); // simulating a 38400baud pace (or less), otherwise commands are not accepted by the device.

  }
  serial_connection.begin(38400);
//serial_connection.begin(115200);
  // send configuration data in UBX protocol
  for (unsigned int i = 0; i < sizeof(UBLOX_INIT); i++) {
    serial_connection.write( pgm_read_byte(UBLOX_INIT + i) );
    delay(5); // simulating a 38400baud pace (or less), otherwise commands are not accepted by the device.

  }

}

The delay(5) is still in there so the Arduino is picking its nose while the GPS rams GPS sentences at 5Hz through the serial pipeline..

As you're already using NeoSWserial, you might want to look into NeoGPS as well. I'm using it for my projects and it's much, much faster than TinyGPS_++, which, by itself works fine, but maybe you're stretching it.