Reading GPS data using Arduino and a U-blox NEO-6M GPS receiver

It is possible to read, and log GPS data, such as time, position, speed, and so on, using an Arduino microcontroller plus an U-blox NEO-6M GPS receiver
ORIGINAL POST
By Davide Cavaliere
components
Hardware Components
Arduino Ethernet
X 1
U-blox NEO-6M GPS
X 1
Software Apps and online services
Arduino IDE
details

IMG_0068-1024x768.jpg

Arduino GPS serial

It is possible to read, and log GPS data, such as time, position, speed, and so on, using an Arduino microcontroller plus an U-blox NEO-6M GPS receiver.

For my test, I used an Arduino Ethernet and a U-blox NEO-6M GPS, which I bought on Amazon Japan for 2,580Yen (about 17 Euro), a very cheap price.

In order to interface the Arduino with the GPS receiver, you have to connect the following pins: power supply VCC (5V), GND (0V), and serial RX and TX. You need to connect the GPS receiver TX to the Arduino RX, and RX with TX. Actually, the NEO-6M GPS serial communication works with 3.3V voltage signal, while Arduino works with 5V voltage signals. However, it is possible to connect the Arduino serial pins directly to the NEO-6M pins without any problem.

U-blox NEO-6M GPS
U-blox NEO-6M GPS

On Arduino side, I used the pins 7 (RX) and 8 (TX) and the Software Serial Library. In fact, the Arduino built-in serial port (0=RX, 1=TX) was already used for the communication with the PC. In the picture below, pins 3, 5 and 6 are also connected to an other Arduino Micro, but these pins are not used in this sketch.

U-blox NEO-6M GPS Arduino Ethernet
U-blox NEO-6M GPS Arduino Ethernet
Shop Related Products

The following Arduino sketch is continuously polling, once in a second, data from the GPS receiver. In order to poll GPS data, the command PUBX,00 is used (this is a proprietary command of U-blox). The received data is then forwarded to the PC serial connection, and visualized on the screen.

GPS_data_screenshot_2
GPS_data_screenshot_2

I removed part of the information, for privacy (otherwise you would know exactly the coordinates of the place where I live). The message forwarded to the PC is as below (instead of “xxxx” and “yyyy”, the latitude, longitude and height positions were received). The original message received by the GPS receiver has a “$” at the beginning, and a “*” at the end (before the checksum). I used these 2 character to understand when the message starts and when it ends. The data which Arduino sends to the PC is only the characters between “$” and “*” (I did not implement any checksum check at the moment).

PUBX,00,131309.00,aaaaa.bbbbb,N,ccccc.ddddd,E,xxx.yyy,G3,28,22,1.757,8.60,0.032,,1.86,2.76,1.99,6,0,0

The sketch that I used is as following, and can be downloaded here: GPS_serial_test. In order to run this sketch, you will also need the “Tempo” library which uses Timer1 and can be downloaded here: tempo_library_v1. I used Timer1 in to create a 10ms scheduler, and manage the polling request every 100 scheduler tasks (10ms x 100 = 1s).

By default, the NEO-6M outputs RMC, VTG, CGA, GSA, GSV, GLL messages once a second (these are standard NMEA messages). Since I wanted to receive the info by polling message (i.e. not automatically, to avoid Arduino sofware serial reception overloading), I first had to disable the automatic sending of the messages (for example, for RMC, this can be done by sending to the GPS receiver the command: $PUBX,40,RMC,0,0,0,0*47). This configuration is performed at the first loop execution. The software then polls the info (time, position, speed) by using the proprietary $PUBX,00*33 request.

The complete protocol explanation for the NEO-6M GPS receiver can be downloaded here: u-blox6 Receiver Description Protocol Specification. The official manual explains which are the NMEA standard messages (ASCII codification) supported, and also the details of the proprietary UBX protocol (binary codification). The explanation of the message $PUBX,00 can be found at pages 68-70. In the next article, I will show how you can use Arduino Ethernet to log GPS data on the SD memory, and then transfer it to the PC.

IMG_0068-1024x768.jpg

Arduino GPS serial

It is possible to read, and log GPS data, such as time, position, speed, and so on, using an Arduino microcontroller plus an U-blox NEO-6M GPS receiver.

For my test, I used an Arduino Ethernet and a U-blox NEO-6M GPS, which I bought on Amazon Japan for 2,580Yen (about 17 Euro), a very cheap price.

In order to interface the Arduino with the GPS receiver, you have to connect the following pins: power supply VCC (5V), GND (0V), and serial RX and TX. You need to connect the GPS receiver TX to the Arduino RX, and RX with TX. Actually, the NEO-6M GPS serial communication works with 3.3V voltage signal, while Arduino works with 5V voltage signals. However, it is possible to connect the Arduino serial pins directly to the NEO-6M pins without any problem.

U-blox NEO-6M GPS
U-blox NEO-6M GPS

On Arduino side, I used the pins 7 (RX) and 8 (TX) and the Software Serial Library. In fact, the Arduino built-in serial port (0=RX, 1=TX) was already used for the communication with the PC. In the picture below, pins 3, 5 and 6 are also connected to an other Arduino Micro, but these pins are not used in this sketch.

U-blox NEO-6M GPS Arduino Ethernet
U-blox NEO-6M GPS Arduino Ethernet
Shop Related Products

The following Arduino sketch is continuously polling, once in a second, data from the GPS receiver. In order to poll GPS data, the command PUBX,00 is used (this is a proprietary command of U-blox). The received data is then forwarded to the PC serial connection, and visualized on the screen.

GPS_data_screenshot_2
GPS_data_screenshot_2

I removed part of the information, for privacy (otherwise you would know exactly the coordinates of the place where I live). The message forwarded to the PC is as below (instead of “xxxx” and “yyyy”, the latitude, longitude and height positions were received). The original message received by the GPS receiver has a “$” at the beginning, and a “*” at the end (before the checksum). I used these 2 character to understand when the message starts and when it ends. The data which Arduino sends to the PC is only the characters between “$” and “*” (I did not implement any checksum check at the moment).

PUBX,00,131309.00,aaaaa.bbbbb,N,ccccc.ddddd,E,xxx.yyy,G3,28,22,1.757,8.60,0.032,,1.86,2.76,1.99,6,0,0

The sketch that I used is as following, and can be downloaded here: GPS_serial_test. In order to run this sketch, you will also need the “Tempo” library which uses Timer1 and can be downloaded here: tempo_library_v1. I used Timer1 in to create a 10ms scheduler, and manage the polling request every 100 scheduler tasks (10ms x 100 = 1s).

By default, the NEO-6M outputs RMC, VTG, CGA, GSA, GSV, GLL messages once a second (these are standard NMEA messages). Since I wanted to receive the info by polling message (i.e. not automatically, to avoid Arduino sofware serial reception overloading), I first had to disable the automatic sending of the messages (for example, for RMC, this can be done by sending to the GPS receiver the command: $PUBX,40,RMC,0,0,0,0*47). This configuration is performed at the first loop execution. The software then polls the info (time, position, speed) by using the proprietary $PUBX,00*33 request.

The complete protocol explanation for the NEO-6M GPS receiver can be downloaded here: u-blox6 Receiver Description Protocol Specification. The official manual explains which are the NMEA standard messages (ASCII codification) supported, and also the details of the proprietary UBX protocol (binary codification). The explanation of the message $PUBX,00 can be found at pages 68-70. In the next article, I will show how you can use Arduino Ethernet to log GPS data on the SD memory, and then transfer it to the PC.

COMMENTS

Please Login to comment
  Subscribe  
Notify of