How to read, log, and visualize GPS data using Arduino

In the previous article, I explained how to use your Arduino to read GPS data from a u-blox 6 GPS, and visualize it on the PC using serial communication.

In this article, I will show you how to log the GPS data on an SD card, inside Arduino Ethernet, and then export it to your PC using serial communication. After exporting the binary file to the PC, it is possible to convert it to a CSV file and visualize it in Excel. It is also possible to analyze the data using more advanced tools such as Matlab, and so on. The complete Arduino sketch code can be downloaded here: GPS_serial_test GPS_serial_v2_20160402.

As explained in the u-blox6 Receiver Description Protocol Specification official guide, it is possible to use the proprietary UBX protocol to read ECEF position (X, Y, Z position in cm), time and speed (X, Y, Z speed in cm/s). I used the service NAV-SOL (0x01 0x06) for this purpose. The payload of this message is quite big (52 bytes) but it contains a lot of useful data. By using the Tempo library (tempo_library_v1) which I made for Arduino, I managed to poll this message once a second (the time can be calibrated), and log the messages on the Arduino Ethernet SD Card (file "capture.log").

In order to be able to send and receive correctly the UBX messages, I implemented a checksum check as below.

The following code parses the data received from the GPS (UBX 0x01 0x06 message).

After logging the file, it is possible to transfer the content to the PC by removing the SD card and connecting it to the PC. Since this procedure is troublesome if you want to transfer the files many times, I also implemented a part of software (on both Arduino and PC) which handles the file transfer via Serial.

arduino_receive_datalog_1The file transfer to the PC via Serial (57600 bps) requires a long time (10.9 seconds for 13696 bytes) due to the fact that the Arduino has to read data from the SD before sending it to the PC.

arduino_receive_datalog_2Finally, the binary data is converted from binary format to a CSV file, which can be opened using Excel. The important info which are included in the NAV-SOL (0x01 0x06) message payload is the following:

  • iTOW: GPS Millisecond Time of Week (ms)
  • fTOW: Fractional Nanoseconds remainder (ns)
  • week: GPS week (GPS time)
  • ecefX, ecefY, ecefZ: ECEF X Y Z coordinates (cm)
  • pAcc: 3D position accuracy estimate (cm)
  • ecefVX, ecefVY, ecefVZ: ECEF X Y Z velocity (cm/s)
  • sAcc: Speed Accuracy Estimatearduino_receive_datalog_3

 

Author: Davide Cavaliere

I am an Italian Electrical Engineer graduated at Politecnico di Milano. My interests are motorcycles and cars, electronics, programming, Internet of Things, and Japanese culture.

1 thought on “How to read, log, and visualize GPS data using Arduino”

  1. Hi Davide,
    I am testing a ublox NEO M8P with teh above GPS_serial example however i am getting a compile error "In function 'void PC_message_parse()':
    GPS_serial:80: error: 'class Tempo' has no member named 'reset'
    Timer1.reset();

    I had a look in the header files for the tempo library and there is no function reset() in the tempo class.

    Is there a work around for this?

    Any help is much appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *