Code Monkey home page Code Monkey logo

ubxgps's Introduction

UbxGps

This Arduino library was developed for the fastest and simplest communication with u-blox GPS modules, which support proprietary UBX protocol that is binary and therefore more compact than common NMEA. Main idea was to achieve real 10 Hz from NEO-7M and it was done. Huge thanks to iforce2d for a tutorial video whose code is laid in the basics of the library.

This library depends on GPS module configuration and can handle only one type of UBX packet at a time, which you can choose during GPS module configuration. UbxGps provides easy-to-use interface to all the available data in accordance with the Protocol Specification that you can find in the Docs directory. Also, full description of properties is accessible in the source codes.

Supported UBX packet types

UBX packet types supported by the library are listed below. Feel free to add other packets to the library, since the library is designed to make new types as easy as it can be.

UbxGpsNavPosecef.h

NAV-POSECEF (Position Solution in ECEF): iTOW, ecefX, ecefY, ecefZ, pAcc.

UbxGpsNavPosllh.h

NAV-POSLLH (Geodetic Position Solution): iTOW, lon, lat, height, hMSL, hAcc, vAcc.

UbxGpsNavPvt.h

NAV-PVT (Navigation Position Velocity Time Solution): iTOW, year, month, day, hour, min, sec, valid, tAcc, nano, fixType, flags, reserved1, numSV, lon, lat, height, hMSL, hAcc, vAcc, velN, velE, velD, gSpeed, heading, sAcc, headingAcc, pDOP, reserved2, reserved3.

UbxGpsNavSol.h

NAV-SOL (Navigation Solution Information): iTOW, fTOW, week, gpsFix, flags, ecefX, ecefY, ecefZ, pAcc, ecefVX, ecefVY, ecefVZ, sAcc, pDOP, reserved1, numSV, reserved2.

Quick Start

Download UbxGps and place it to the Arduino libraries directory. Refer to How to install Libraries for details.

Next step is configuring your GPS module properly, to find out how to do this check section GPS module configuration. Also, take a look at the Auto-configuration sketch for the Arduino Mega boards to configure your GPS module automatically to get NAV-PVT messages with 100 ms frequency and 115200 baudrate.

After that you can use included examples or play with the following simple sketch:

#include "UbxGpsNavPvt.h"

UbxGpsNavPvt gps(Serial3);

void setup()
{
    Serial.begin(9600);
    gps.begin(9600);
}

void loop()
{
    if (gps.ready())
    {
        Serial.print(gps.lon / 10000000.0, 7);
        Serial.print(',');
        Serial.print(gps.lat / 10000000.0, 7);
        Serial.print(',');
        Serial.print(gps.height / 1000.0, 3);
        Serial.print(',');
        Serial.println(gps.gSpeed * 0.0036, 5);
    }
}

Note for Uno users

The library is designed to work with GPS module through a hardware serial port, but Uno has only one. It means that you can configure GPS module, but the library will occupy serial port and you need to do something more to get the data from it. For example: add an SD card to store the data, or transmit it through the Bluetooth or Ethernet. SoftwareSerial can be used, but I can't guarantee it will work without bugs on a high frequency.

GPS module configuration

Step 1. Wiring

So we have an Arduino board and a GPS module. Wiring is pretty simple: GND to GND, VCC to 5V, TX to RX and RX to TX. Because Uno has only one TX/RX pair, we should connect GPS module TX to the 2 pin and RX to the 3 pin and use SoftwareSerial library to communicate with the GPS. If you have something with more than one TX/RX pair on the board you can use it, for example for Mega we can connect GPS RX to the TX3 and TX to the RX3.

Wiring

Auto-configuration

After wiring you can upload the Auto-configuration sketch for the Arduino Mega boards to configure your GPS module automatically.

At the moment it configures the receiver to get NAV-PVT messages with 100 ms frequency and 115200 baudrate, but you can change it according to your needs.

Auto-configuration

Step 2. Serial bridge

This step is optional and is only needed to use u-center. If you don't want to do it, feel free to skip to Checks.

Let's make a bridge between the GPS module and the computer: upload Serial-Bridge-Uno.ino or Serial-Bridge-Mega.ino sketch to the board, it allows us to communicate with GPS module directly from computer. Open Serial Monitor, and if your GPS module is new or have default settings you will see something like on the picture below. If everything is OK, GPS will send some data.

Serial bridge

Step 3. Meet u-center

For u-blox GPS module configuration we will use u-center program that you can find here. It parses data from GPS module and provides useful tools to work with it. Launch program, choose appropriate COM port and set baudrate, 9600 for default. It will start getting some data.

Meet u-center

Step 4. Change baudrate (optional)

If you have something with more than one TX/RX pair it will be useful to raise the baudrate of GPS module. It can helps if you gonna work with high frequency like 5 or 10 Hz. Open View — Messages View window and find UBX — CGF — PRT item. Set the baudrate to 115200 for example and click Send button at the bottom left corner.

Changing baudrate using SoftwareSerial library can cause errors!

GPS module will stops getting data, because our sketch works with old baudrate. Disconnect from COM port in u-center, update GPS_BAUDRATE and PC_BAUDRATE if you want and uploads it to the board. Reconnect u-center and it should works!

Change baudrate

Step 5. Change update frequency (optional)

In Messages View in the UBX — CFG — RATE tab you can change Measurement Period to raise frequency of getting data. I want to achieve 10 Hz, so I change Measurement Period to the 100 milliseconds and click Send button.

Change frequency

Step 6. Disable unnecessary channels

To make GPS module life easier, we can disable unnecessary channels in the UBX — CFG — GNSS tab. We only need GPS, so uncheck other channels at enable column. Again, click Send to save changes.

Serial bridge

Step 7. Choose packet

UBX GPS library works with only one type of UBX packet, so we need to fully disable NMEA packets and enable one of the UBX group. Open context menu on Messages View — NMEA and click Disable Child Messages. u-center will send appropriate command to the GPS module and getting data will stops. If you're using SoftwareSerial it can takes a time to get things right, try to click Disable Child Messages again if it not works.

Then, choose a UBX packet type you want to work with, for example UBX — NAV — PVT, open context menu on it and click Enable Message, GPS module will start getting data again. Open View — Packet Console to see if everything is OK, it should get one type of UBX packet with chosen frequency.

Choose packet

Step 8. Save configuration

Go to UBX — CFG — CFG and click Send to save current configuration.

Important! GPS module will remember what we've done, but sometimes it is not enough: GPS module can return to factory settings after a long time without power, so check your battery on the GPS module.

Save configuration

Step 9. Checks

Close u-center and open an example NavPvt sketch, check baudrate and upload it to the board. If everything is OK you'll get desired data. That's all Folks!

Checks

More details about u-blox GPS module configuration are in Receiver Description — Receiver Configuration found under Docs directory.

Compatible GPS modules

  • NEO-7M — tested
  • Other u-blox GPS modules, which supports UBX protocol
  • Please, notice me if it works with your GPS module

Contribution

Feel free to add something useful to this library ☺️ For example new classes for UBX packets!

Please, use the dev branch for contribution.

Links

ubxgps's People

Contributors

loginov-rocks avatar 1oginov avatar kolyshkin avatar

Watchers

James Cloos avatar Leo Fernandez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.