Add Altitude to GPS sketch

I have succeeded installing U-center using wine. Also found a laptop with Win 7 and installed U-center. Where to now?

Can the Arduino be used as an interface between the VK2828U7G5LF and u-center, or do I need to create something else??

The last part of post #16 describes what you need to do to create interface between u-center and the GPS module.

The code will just forward every character we receive from the module to the COM port. But instead of using the Serial Monitor we start u-center and connect to it. Once connected u-center will automatically start decoding the messages from the module and display it.

We will try sending data from the module to u-center first.

Next step will be to send character both directions. Then you should be able to configure your module. Right now, the sketch does not do this yet.

I have the u-center running. In NEMA-GxGGA mode displaying appropriate Log, Lat, and Alt. Needed to wait a long time.

OK, now you need to replace the loop with the following code

void loop()
{
  if ( ss.available() )
  {
    char c = ss.read();
    Serial.write(c);
  }
  if( Serial.available() )
  {
    char c = Serial.read();
    ss.write(c);
  }
}

This will now enable communication in both direction. I cannot test this with the u-center, because my chip is not from u-blox. But I found the command set for my module and send a standby command trough the Serial Monitor and the module stop sending messages. Then I woke the module by sending somthing else.

Once you have connected, see if the Tools → “Receiver Configuration” item in the u-center menu is enabled. See if there is a checkbox or something for the GGA mode.
There are many other menu items, have a look trough them if the Receiver Configuration is not the right one.

In View → Packet Console you can see the output from the module, like in the Serial Monitor. So you can see if your settings have the right effect.

u-center now appears to be enabled to send a configuration (View/Configuration), with a table as per page 11 VK2828U7G5LF Data sheet, I cannot find anything that specifies GGA, and don't know what I am changing from to be able to revert.

OK, let’s do this slowly. I did a little bit of testing.

First go to Tools -> Receiver Configuration
Select Generation: u-blox M8/8
Select a empty txt file on your hard drive or create one with the [...] button. Make sure it’s in a folder you can write to.
Click Transfer GNSS -> File

I believe this is a safe operation that will not change anything. You should see a little window pop up that will send messages to the GPS module and the GPS module will send the configuration data back. Check the file if it has some stuff in it. This is likely a backup of your current settings.

Next, lets explore the Configuration

Select View -> Configuration View
Click on MSG(Messages)
On the right side of this box, you will see a dropdown box, select F0-00 NMEA GxGGA and note the settings for IIC, UART1, UART2, USB, SPI
Then select F0-00 NMEA GxRMC and F0-00 NMEA GxVTG, these are the messages your module is printing out, so I expect the settings to be different

If you feel like trying and the boxes for GxGGA are empty and the boxes for the other two are not.
Go to View -> “Text Console”, move the two dialog windows so you can see both.
Select GxGGA and check the boxes.
Then click the little Send button at the bottom
See if the GxGGA messages now appear in the Text Console

I believe this is not permanent. This will just change the configuration in RAM.

Power down your GPS module and restart it again and see if the GxGGA messages are still send by the module.

Let me know what happens. If the messages are not sent. We will save the configuration to flash memory in the next step.

Whow, you have gone to a lot of trouble. Unfortunately my responses are not good.

If I select Generation: u-blox M8/8, it does not accept it, it resets to u-box 7

Click Transfer GNSS -> File

the output:
polling: MON-VER - B5 62 0A 04 00 00 0E 34 ...
... timeout occurred without receiving an answer. Retrying (repeating)

If I select View -> Configuration View, Click on MSG(Messages)

select F0-00 NMEA GxGGA ... there is nothing displayed

Then select F0-00 NMEA GxRMC and F0-00 NMEA GxVTG, they do not display anything

if I click "On" in the boxes above, they display a 1

I note on the bottom task bar: NTRIP client: Not connected

meanwhile, the NMEA - GxGGA window is updating the UTC time

I love a good puzzle. :slight_smile:

Lets try the following. On page 14 of the datasheet you can see a couple of commands that can be send to the module. Lets see if they work. If they work, they could still only change the settings in RAM, but then you could call this in your main program.

Add the follwing to your code and replace the loop. We will use the Serial Monitor for this. Once compile and downloaded, start the Serial Monitor. You should see the messages from the GPS module. Now, send one letter e.g. A[ENTER] from the Serial Monitor. This will send the message to the GPS module. If the command works, the GPGGA messages should now be send from your GPS module.

As before, if it works, power cycle the board and connect the Serial Monitor and check if the setting is permanent.

// VK2828U7G5LF Datasheet page 14 8.2 Enable Outputting Commands
// 24 45 49 47 50 51 2c 47 47 41 2a 32 37 0d 0a b5 62 06 01 03 00 f0 00 01 fb 10 -> Enable GPGGA
byte enableGPGGA[] = {0x24, 0x45, 0x49, 0x47, 0x50, 0x51, 0x2c, 0x47, 0x47, 0x41, 0x2a, 0x32, 0x37, 0x0d, 0x0a, 0xb5, 0x62, 0x06, 0x01, 0x03, 0x00, 0xf0, 0x00, 0x01, 0xfb, 0x10};

void loop()
{
  if ( ss.available() )
  {
    char c = ss.read();
    Serial.write( c );
  }
  if( Serial.available() )
  {
    char c = Serial.read(); // just reading Serial to make sure input buffer is cleared, otherwise the message will be send forever
    ss.write( enableGPGGA, sizeof( enableGPGGA ) );
  }
}

I replaced the void loop in the simple_test.ino as described. The serial monitor then produces a lot of garbage, some identifiable text (digits). Sending A had no apparent effect. Running my original program without breaking power produced the previous output (time,Lat, Lon, 100m).

Just to make sure. When you started the modified version the module was sending the normal messages you have seen so far?

Sending A to the Serial Monitor just triggers the message to be send. (It can be any letter.)

Once you send a letter, a lot of garbage came out?

I deleted everything in simple_test.ino staring with and including the line void loop()

I copy/paste all in your code.

I clicked the upload button, clicked Serial Monitor and without sending anything to the Monitor, observed lots of garbage interposed with a few intelligent lines. Capturing only those:

$GPVTG,,T,,M,0.426,N,0.789,K,A*25
$GPGGA,023852.00,4112.16561,S,17452.81259,E,1,07,1.11,211.1,M,16.0,M,,*4C
$GPGSA,A,3,19,17,06,03,02,28,12,,,,,,2.00,1.11,1.67*01
$GPGSV,3,1,09,02,42,311,18,03,17,136,31,06,88,028,25,12,36,227,24*73
$GPGSV,3,2,09,17,44,112,25,19,63,137,18,22,02,149,,24,29,270,21*76
$GPGSV,3,3,09,28,20,044,31*4A

The second line appears to have the required Lat, Lon, and Alt, 211.1M?

Sending A did not appear to change and thing.

So, now your GPS module is sending the GPGGA message with altitude. :slight_smile:

Well sending A is not supposed to change anything if the module is sending the GPGGA message.

It is strange that you see lots of garbage. But then you are using SoftSerial, maybe you are losing a few bits from time to time. The TinyGPS library is likely just ignoring bad messages.

Just to make sure. Power cycle your board a few times. Wait a bit in between and just look at the messages, make sure the GPGGA messages keep coming from time to time.

So, what do we need to do next, now that your GPS module sends you a message with the Altitude?

Now the Serial Monitor is producing only one line which is prefixed GPRMC. There is a higher proportion of garbage, The GPCGA line and the other GP*** lines are not present.

If I run my original sketch Lat, Lon, and false 100 alt as before.

Obviously something has changed. I have only switched sketches to verify the gps module is functional.

I am going to be away from my computer for the next 10 - 12 days. Would it be ok to take up the problem on my return?? Thank you for your patience.

Sure, let me know when you are back.

Hi Klaus

Browsing, I came across a sketch using TinyGPSPlus at: GPS Logger Shield Hookup Guide - learn.sparkfun.com

I tried it, and it provided Lat, Lon, Alt, and Date/Time. May be Tinygps is limited.

Thank you for hanging in there.

johngxnz:
I tried it, and it provided Lat, Lon, Alt, and Date/Time. May be Tinygps is limited.

If you mean that it did include altitude data then try

if (gps.altitude.isUpdated())
  Serial.println(gps.altitude.meters());

The libraries are only parsing the serial messages send by your GPS module.

If the GPGGA messages are arriving at your Arduino and you see them with the simple sketch we have used, then the libraries can get the altitude.

Thank you for the replies.

UKHeliBob: using the TinyGPSPlus sketch referred to, I received all: Lon, Lat, Alt. Date, and Time.

I'm not sure which sketch I should insert your suggestion. When I try it I get errors like:

simple_test:48: error: 'gps.TinyGPS::altitude' does not have class type
if (gps.altitude.isUpdated())
^
simple_test:49: error: 'gps.TinyGPS::altitude' does not have class type
Serial.println(gps.altitude.meters());
^
exit status 1
'gps.TinyGPS::altitude' does not have class type

Klaus_K: Does that mean TinyGPSPlus libraries read/display Altitude, and TinyGPS libraries do not read/display Altitude?

johngxnz:
Does that mean TinyGPSPlus libraries read/display Altitude, and TinyGPS libraries do not read/display Altitude?

You could look at the Example programs in the TinyGPS library, to see how they print out Altitude.

The TinyGPS library has an altitude function it is just a bit different. Have a look into the TinyGPS.h file. All the functions in the public section of the TinyGPS class are available to you. You need

// signed altitude in centimeters (from GPGGA sentence)
inline long altitude() { return _altitude; }

Here is an example just printing the raw NMEA messages and the altitude. As usual it will take a little while to get the altitude.

//#include <SoftwareSerial.h>
#include <TinyGPS.h>

TinyGPS gps;
//SoftwareSerial ss(4, 3);
#define ss Serial1

void setup()
{
  Serial.begin( 9600 );
  while ( !Serial );
  ss.begin( 9600 );
}

void loop()
{
  bool newData = false;

  if ( ss.available() )
  {
    char c = ss.read();
    Serial.write( c );      // uncomment this line if you want to see the GPS data flowing
    if ( gps.encode( c ) )  // Did a new valid sentence come in?
    {
      newData = true;
    }
  }

  if ( newData )
  {
    long altitude;

    altitude = gps.altitude();
    Serial.print( "\n" );
    Serial.print( "Altitude: " );
    Serial.print( altitude );
    Serial.println( " cm" );
  }
}