Giter Club home page Giter Club logo

ubxgps's Introduction

UbxGps

PlatformIO Registry Arduino Lint PlatformIO Build

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 u-blox 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.

UbxGpsNavPvt8.h

Similar to UbxGpsNavPvt.h, but for u-blox NEO-8M.

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 Installing 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<HardwareSerial> 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 Uno_SerialBridge.cpp or Mega_SerialBridge.cpp 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 (Windows only). 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 COMPUTER_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 in u-blox directory.

Compatible GPS Modules

  • NEO-7M - tested
  • NEO-8M - tested
  • Other u-blox GPS modules supporting UBX protocol

Please create an issue to report if you tested UbxGps with other u-blox GPS modules. Thank you!

Reference

ubxgps's People

Contributors

1oginov avatar kolyshkin avatar loginov-rocks avatar njh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ubxgps's Issues

Serial.available() everytime only 4 Bytes

I am using an UBlOX M8U with Serial and want ot get the PVT information.
I am trying around with your library but get no results.
When ich just use a Scetch to out print all bytes that reach my arduino, i get the orignal message like in U-center.
The problem is, these bytes come always as 4. so Serial.available will alwas go out of the while scope after 4 bytes ?!?.
So its not possible to get a complete message over the library
andy advice?

Problem with reading Navpt

Hi,
I'm using the Ublox 7m module. I'm using this library and it has no problem. But every time I power up the module I need to upload Auto-configuration-mega.ino first and then I am able to upload Navpt example and receive the coordinates, But when I restart the module the gps.read() has no value and I should re-upload config sample again. Is there any fix for this?
Thanks.

I2C Support?

Hey,

This library works well for use with UART applications. I wanted to suggest adding I2C support for those who don't want to work with the latency and efficiency of UART, using the Wire.h library..

Thanks!
W0MXX

UBX MON HW

Can I obtain data from HW which is a child message of MON?

Library doesn't appear to work with the u-blox m8q

Hi

I am trying to find a library that will work with the ublox M8Q module and this one looked promising. I have followed the instructions and u-center shows a 3D fix using the Serial-Bridge-Mega app. However, the example app doesn't seem to like the NAVPvt data from this module as it never resolves the gps.ready() function to true.

I am testing this with a Seediono Mega 2560, with the GPS hooked upto serial port 3 (pins 14&15). The GPS is defined as follows :- UbxGpsNavPvt gps(Serial3);

I have also tried softwareserial on the Moteino, but that didn't want to play either.

I don't know enough about the binary protocol to dig any deeper. Any thing else I can try?

Missing 'Graphic' for GPS status info

Hi, in the source, it mentions 'Graphic Below' - Where are these graphics?
char valid; // - Validity Flags (see graphic below)
char flags; // - Fix Status Flags (see graphic below)

I would really like the ability to know if the GPS has a fix or not i.e valid GPS data. This seems like it might be the option I am looking for...

u-blox neo-m9n

Sir, i am support to smartcore, a u-blox representative and i am doing a blog about the NEO-M9N.

The blog going well, gathering info to help the client.

Looking the internet i found your UBXm protocol. Will it works to NEO-M9N ? I see that NEO-M9N implements too UBX protocol.

If yes, i will test and add your GITHUB to it.

Thank you!

UBX checksum is incorrect

According to UBlox documents:

The checksum is calculated over the Message, starting and including the CLASS field up until, but excluding, the Checksum Field

What I've noticed in reality that 2 bytes of class ID are not taken into account when UbxGps.h calculates checksum, thus any NAV-PVT message is never considered valid

For example, this packet (without 2 checksum bytes at the end):

packet =[0xB5,0x62,0x01,0x07,0x54,0x00,0x98,0xBA,0x8A,0x1D,0xE7,0x07,0x04,0x07,0x11,0x28,0x0D,0x07,0x1A,0x00,0x00,
         0x00,0x60,0x17,0xFE,0xFF,0x03,0x01,0x0B,0x08,0x4F,0xA9,0x21,0xF6,0xED,0xC1,0xBC,0x10,0xF0,0xA8,
         0x04,0x00,0xCD,0x1F,0x04,0x00,0x79,0x24,0x00,0x00,0xBB,0x2B,0x00,0x00,0x01,0x00,0x00,0x00,0x52,
         0x00,0x00,0x00,0x2D,0x00,0x00,0x00,0x52,0x00,0x00,0x00,0xD4,0xEA,0xAA,0x00,0x03,0x02,0x00,0x00,
         0x93,0xB8,0x46,0x00,0xC9,0x00,0x00,0x00,0x84,0xD3,0x11,0x00]

The valid checksum would be CK_A = 0xD9 and CK_B = 0x71

Meanwhile the library expects CK_A = 0xC0 and CK_B = 0x16
And fails because it got CK_A = 0x11

If you exclude 2 bytes for class ([0x01,0x07]) then calculated checksum matches i.e. a checksum for

packet =[0x54,0x00,0x98,0xBA,0x8A,0x1D,0xE7,0x07,0x04,0x07,0x11,0x28,0x0D,0x07,0x1A,0x00,0x00,
         0x00,0x60,0x17,0xFE,0xFF,0x03,0x01,0x0B,0x08,0x4F,0xA9,0x21,0xF6,0xED,0xC1,0xBC,0x10,0xF0,0xA8,
         0x04,0x00,0xCD,0x1F,0x04,0x00,0x79,0x24,0x00,0x00,0xBB,0x2B,0x00,0x00,0x01,0x00,0x00,0x00,0x52,
         0x00,0x00,0x00,0x2D,0x00,0x00,0x00,0x52,0x00,0x00,0x00,0xD4,0xEA,0xAA,0x00,0x03,0x02,0x00,0x00,
         0x93,0xB8,0x46,0x00,0xC9,0x00,0x00,0x00,0x84,0xD3]

would indeed be CK_A = 0xC0 and CK_B = 0x16

Basically, checksum is calculated for packet size 4 bytes shorter than it actually is (2 bytes for Class ID and 2 bytes for packet size field which is in Int16 Little Endian format - [0x54,0x00] )

I need a help with fixing this code because without UART debugger playing with byte offsets by printing strings to serial is a nightmare :)

problem while compile

I receive an error message while compiling the test sketch on string #18
UbxGpsNavPvt gps(Serial3);

here is message
UbxGpsNavPvt:18: error: 'Serial3' was not declared in this scope

UbxGpsNavPvt gps(Serial3);
^

exit status 1
'Serial3' was not declared in this scope

What i have to write there?

Ublox 8

Ublox8 in 0x01 0x07 Nav-Pvt message has 92 bytes, not 84.

Combining UbxGpsNavPvt and SoftwareSerial

Many thanks for your great instruction on using u-blox modules with arduino. However, I am a real beginner with arduino programming, so pardon my stupid question. I have connected a CAM-M8Q to an Arduino Uno and am able to monitor UBX binary code on the serial monitor. However, I could not figure out how to feed this into UbxGpsNavPvt to convert it.
The line UbxGpsNavPvt gps(ss); (code below is throwing me: no matching function for call to 'UbxGpsNavPvt::UbxGpsNavPvt(SoftwareSerial&)'

Many thanks for any advice

#define PC_BAUDRATE     9600
#define GPS_BAUDRATE    9600
#define GPS_RX          3
#define GPS_TX          2
#define DATETIME_FORMAT "%04d.%02d.%02d %02d:%02d:%02d"
#define DATETIME_LENGTH 20

#include "UbxGpsNavPvt.h"
#include "SoftwareSerial.h"

SoftwareSerial ss(GPS_TX, GPS_RX);
UbxGpsNavPvt gps(ss);

char datetime[DATETIME_LENGTH];

void setup()
{
    Serial.begin(PC_BAUDRATE);
    ss.begin(GPS_BAUDRATE);
}

// If there is a data from the receiver, read it and send to the PC or vice versa
void loop()
{
    if (gps.ready())
    {
        snprintf(datetime, DATETIME_LENGTH, DATETIME_FORMAT, gps.year, gps.month, gps.day, gps.hour, gps.min, gps.sec);

        Serial.print(datetime);
        Serial.print(',');
        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.print(gps.gSpeed * 0.0036, 5);
        Serial.print(',');
        Serial.print(gps.heading / 100000.0, 5);
        Serial.print(',');
        Serial.print(gps.fixType);
        Serial.print(',');
        Serial.println(gps.numSV);
    } else Serial.print('.');
}
  

'UbxGpsNavPvt' is not a template

Hi,
I tried your code with the arduino software.
I've installed the library with the library manager.
When I compile the code sample I've this error.
Could you help please.
Thanks

no data out from ublox M8P when using UbxGpsNavPvt

Hi,
I am using a u-blox M8N receiver connected to an Arduino Mega as indicated in the instructions. The auto-configuration-mega sketch works fine (i assume) and results in binary data appearing on the arduino console. However when i upload and use the UbxGpsNavPvt sketch i get no output - i assume this is because it cant find the correct UbxGps_Header values. Could this in turn be due to the Ublox8 in 0x01 0x07 Nav-Pvt message having 92 bytes instead of 84. If this is the case, how would i fix this.

Any help is much appreciated.

don't receive data with lib

Hi,
I've tried the Extra sample with my Due , I received the ubx packet starting with 0xB5 and 0x62.
When I try to implement the lib with the same config , nothing append.
I try to add a serial print in the ubxgps.h to debug the UART reception

  boolean ready()
  {
      byte c = this->read();
      serial.print(c,HEX);    
    return true;
}

but nothing print like if the port is not opened .
Do you have a tips ?
Thanks

Error compiling for ESP8266 - Software Serial

got following error:
`In file included from D:\arduino_proj\MyProj\libraries\UbxGps\src/UbxGpsNavPvt.h:4:0,

             from D:\arduino_proj\MyProj\myUBX_8266\myUBX_8266.ino:7:

D:\arduino_proj\MyProj\libraries\UbxGps\src/UbxGps.h: In instantiation of 'void UbxGps::begin(long int) [with T = SoftwareSerial]':

D:\arduino_proj\MyProj\myUBX_8266\myUBX_8266.ino:25:27: required from here

D:\arduino_proj\MyProj\libraries\UbxGps\src/UbxGps.h:14:36: error: return-statement with a value, in function returning 'void' [-fpermissive]

 return this->serial.begin(speed);

                                ^

Using library SoftwareSerial at version 5.0.4 in folder: C:\Users\schoen\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SoftwareSerial
Using library UbxGps at version 1.4.0 in folder: D:\arduino_proj\MyProj\libraries\UbxGps
exit status 1
Error compiling for board LOLIN(WEMOS) D1 R2 & mini.`

Empty data in console

Good afternoon @loginov-rocks
I'm trying to run the library with an example for the neo-6m module.
But nothing is output to the serial port.
Please tell me, have you tried running the library with such an ancient and godforsaken module as NEO-6M?
Perhaps the problem is related to the NEO-6M module itself, but perhaps also to the version of the UBX protocol in it ... perhaps the version is outdated, the module shows through the u-center software 7.03 (45969).
First, I configure the module through the u-center at 5 Hz (tried it at 10 Hz).
RATE_10HZ

Although according to the datasheet for NEO-6M
NEO-6M

up to 1 Hz is possible and the y-center highlights the field in red, in the binary console there is a noticeable change in the output speed, but on the module itself the red LED always blinks with the same frequency - 1 Hz.
I also disabled all NMEA and UBX messages and enabled only three: VEDNED, POSLLH, SOL.
NAV_message_ON

Code, upload to stm32f411

#include <UbxGpsNavPvt.h>

#define BAUDRATE 115200
#define GPS_BAUDRATE 115200


HardwareSerial Serial2(USART2); // PA2(TX2), PA3(RX2)

UbxGpsNavPvt<HardwareSerial> gps(Serial2);

void setup()
{
    Serial.begin(BAUDRATE);
    gps.begin(GPS_BAUDRATE);
}

void loop()
{
    if (gps.ready())
    {
        Serial.print(datetime);
        Serial.print(',');
        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.print(gps.gSpeed * 0.0036, 5);
        Serial.print(',');
        Serial.print(gps.heading / 100000.0, 5);
        Serial.print(',');
        Serial.print(gps.fixType);
        Serial.print(',');
        Serial.println(gps.numSV);
    }
}

Compile OK
compile
There is peace and quiet in the port ...
None of the existing libraries want to work with this module.
I can only read data from the module using a self-written parser, but the parser has a drawback - it does not work if a delay is added to the parser code, even 10 ms, and the messages are no longer parsed.
Therefore, I want to make the module work with normal UBX parsing libraries.

Message Types

Hi and Thanks! The Autoconfig works great for the Neo M8N - I couldn't get the switch to UBX working myself. For actual reading, I use https://github.com/bolderflight/UBLOX, though simply for convenience and because I'm fine with 1Hz updates.

About the autoconfig:

I figured I'd document the messages you're enabling after switching to UBX. Maybe the spec I used is faulty and that may be the reason why I couldn't get it to work - couldn't find all the messages either. I used this: https://www.u-blox.com/sites/default/files/products/documents/u-blox8-M8_ReceiverDescrProtSpec_%28UBX-13003221%29_Public.pdf

    {0xF0, 0x0A}, // DTM - Datum Reference
    {0xF0, 0x09}, // GBS - GNSS Satellite Fault Detection
    {0xF0, 0x00}, // GGA - Global positioning system fix data
    {0xF0, 0x01}, // GLL - Latitude and longitude, with time of position fix and status
    {0xF0, 0x0D}, // GNS - GNSS fix data
    {0xF0, 0x06}, // GRS - GNSS Range Residuals
    {0xF0, 0x02}, // GSA - GNSS DOP and Active Satellites
    {0xF0, 0x07}, // GST - GNSS Pseudo Range Error Statistics
    {0xF0, 0x03}, // GSV - GNSS Satellites in View
    {0xF0, 0x04}, // RMC - Recommended Minimum data
    {0xF0, 0x0E}, // ???
    {0xF0, 0x0F}, // VLW - Dual ground/water distance
    {0xF0, 0x05}, // VTG - Course over ground and Ground speed
    {0xF0, 0x08}, // ZDA - Time and Date
    {0xF1, 0x00}, // POSITION - Lat/Long Position Data
    {0xF1, 0x01}, // ???
    {0xF1, 0x03}, // SVSTATUS - Satellite Status
    {0xF1, 0x04}, // TIME     - Time of Day and Clock Information
    {0xF1, 0x05}, // ???
    {0xF1, 0x06}, // ???

That's all - thanks again!

Settings Gps module function

hello, is it possible to adjust the navigation update speed of 5-10khz, and change the boudrate from 9600 to 115200 via arduino sketch?

saving ubx data for conversion to rinex file format for post processing

HI,
Can your library be used to obtain raw GPS data (which would be stored on an SD card as a .ubx file) for later conversion to the Rinex format for post processing. If so would using UbxGpsNavPvt be the best option? We are looking to accurately track animal movements in remote environments.

Any help is much appreciated.

Regards

NEO-6M0 GPS

Your library works on the NEO-6M0 gps, however its not possible to enable the UbxGpsNavPvt in Ucenter, other messages works fine. For me that's ok since I do not need course information

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.