#include "UBLOX.h"
UBLOX gps(Serial, 9600); //Serial-not Serial 1-3!!!!!
bool led = LOW;
void setup()
{
pinMode(2, OUTPUT);
gps.begin();
}
void loop()
{
if (gps.readSensor()) {
led = !led;
digitalWrite(2, led);
}
}
Get rid of the delay in your test program, it might be causing issues:
Make sure you aren't sending any packets other than UBX-NAV-PVT and turn down the rate to 1 Hz for now.
#include "UBLOX.h"
UBLOX gps(Serial, 9600); //Serial-not Serial 1-3!!!!!
bool led = LOW;
void setup()
{
pinMode(2, OUTPUT);
gps.begin();
}
void loop()
{
if (gps.readSensor()) {
led = !led;
digitalWrite(2, led);
Serial.print(gps.getNumSatellites()); ///< [ND], Number of satellites used in Nav Solution
Serial.print("\t");
Serial.print(gps.getLatitude_deg(), 10); ///< [deg], Latitude
Serial.print("\t");
Serial.print(gps.getLongitude_deg(), 10); ///< [deg], Longitude
Serial.print("\t");
Serial.println(gps.getMSLHeight_ft()); ///< [ft], Height above mean sea level
}
}
#include "UBLOX.h"
double Latitude_deg = 0;
double Longitude_deg = 0;
double Latitude_rad = 0;
double Longitude_rad = 0;
double MSLHeight_m = 0;
uint8_t NumSatellites = 0;
double GroundSpeed_ms = 0;
float pDOP = 0;
UBLOX gps(Serial, 9600);
void setup()
{
//my code here
}
void loop {
if (gps.readSensor())
{
Longitude_rad = gps.getLongitude_rad();
Latitude_rad = gps.getLatitude_rad();
Longitude_deg = gps.getLongitude_deg();
Latitude_deg = gps.getLatitude_deg();
MSLHeight_m = gps.getMSLHeight_m();
GroundSpeed_ms = gps.getGroundSpeed_ms();
pDOP = gps.getpDOP();
}
//my code here
}
Hi!
Thanks you! You helped me a lot! It all worked! Added output to terminal on the same serial port. It works too !!!!
Code:#include "UBLOX.h" UBLOX gps(Serial, 9600); //Serial-not Serial 1-3!!!!! bool led = LOW; void setup() { pinMode(2, OUTPUT); gps.begin(); } void loop() { if (gps.readSensor()) { led = !led; digitalWrite(2, led); Serial.print(gps.getNumSatellites()); ///< [ND], Number of satellites used in Nav Solution Serial.print("\t"); Serial.print(gps.getLatitude_deg(), 10); ///< [deg], Latitude Serial.print("\t"); Serial.print(gps.getLongitude_deg(), 10); ///< [deg], Longitude Serial.print("\t"); Serial.println(gps.getMSLHeight_ft()); ///< [ft], Height above mean sea level } }
Data from terminal :
7 50.7201324462 30.9476091766 369.85
Now I can use your library in my project. Please check if I did it right?
Code:#include "UBLOX.h" double Latitude_deg = 0; double Longitude_deg = 0; double Latitude_rad = 0; double Longitude_rad = 0; double MSLHeight_m = 0; uint8_t NumSatellites = 0; double GroundSpeed_ms = 0; float pDOP = 0; UBLOX gps(Serial, 9600); void setup() { //my code here } void loop { if (gps.readSensor()) { Longitude_rad = gps.getLongitude_rad(); Latitude_rad = gps.getLatitude_rad(); Longitude_deg = gps.getLongitude_deg(); Latitude_deg = gps.getLatitude_deg(); MSLHeight_m = gps.getMSLHeight_m(); GroundSpeed_ms = gps.getGroundSpeed_ms(); pDOP = gps.getpDOP(); } //my code here }
Could you indicate at what time the execution of my code in the Loop after the acceptance of the UBX-NAV-PVT data will be stable and the data will be received correctly? The speed is 9600, 1Hz. I have given that the parsing takes place asynchronously as the new packet arrives from the receiver and the program cycle time does not matter. I think my code will take up to one hundred milliseconds.
UPD:
I inserted a delay of 100 milliseconds. Almost does not work. Set a delay of 50. Earned. If there are problems with the duration of the execution of my code, I will have to insert into the program a trigger waiting for decoding data and only after that put my code into operation in each cycle. Thus, the likelihood of “capturing” data from NEO will increase.
Best regards,
Gennady
if (gps.readSensor())
if (gps.readSensor())
Thereturns true only on a valid packet. It is safe to use that data afterwards.Code:if (gps.readSensor())
The issue with delays in your code seem to be your arduino board (a nano) seems to have a very small serial buffer. Too long of a delay and received GPS data falls out of buffer and you get corrupted packets. You could calloften during your code so that it can parse the incoming serial data. Or you can try to increase the buffer size (I don't know how to do this on a nano), tie into the serial receive interrupt (again, don't know how to do this on a nano), or get a more capable board.Code:if (gps.readSensor())
I have to check this one.
Hi!
I needed to get some data from the UBX_MON-HW package. Not all, but only three parameters. I will, with your permission, change your library to fit my needs. In principle, I understood how it works. But I think that I myself can hardly achieve the result. May I ask you to help me in case I fail.
Thanks in advance!
Gennady
The beauty of the MIT license is that you can do what you want with the code. I can take a look if I have time, no guarantees.
loop{
if (gps.readSensor())
{ digitalWrite(6, HIGH);
Longitude_deg = gps.getLongitude_deg();
Latitude_deg = gps.getLatitude_deg();
GnssFixOk = gps.isGnssFixOk();
startLatitude_rad = gps.getLatitude_rad();
startLongitude_rad = gps.getLongitude_rad();
MSLHeight_m = gps.getMSLHeight_m();
NumSatellites = gps.getNumSatellites();
triggerParse = 1;
digitalWrite(6, LOW);
}
if ( triggerParse == 1 )
{ digitalWrite(9, HIGH);
//my code here....
triggerParse = 0;
digitalWrite(9, LOW);
}
}
in nano! but problem not in speed!
There is only one problem — I can't force M8N to save UBX-NAV-PVT mode in memory. After turning off the power of the M8N, it jumps to UBX-NAV-SOL with the UART1 port turned off. See screen. But packages in the UBX-NAV-PVT format are still transmitted to format continue to be transmitted to the U-Center or to another terminal program TERMITE 3.2 both via Arduino and so on via Uart -> Usb.
//Setup UART connection
//Increase to Baud 38400
static const byte UBX_CFG_PRT[] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x00, 0x96,
0x00, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x93, 0x90
};
//MSG Config
//Turn on NAV-PVT
static const byte UBX_CFG_MSG[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0x01, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x19, 0xE7,
//Turn off GGA
0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x23,
//Turn off GLL
0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A,
//Turn off GSA
0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x31,
//Turn off GSV
0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x38,
//Turn off RMC
0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3F,
//Turn off VTG
0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x46
};
//Setup Ext Power
//EXINT 0, ExBackup
static const byte UBX_CFG_PM2[] = {0xB5, 0x62, 0x06, 0x3B, 0x2C, 0x00, 0x01, 0x06, 0x00, 0x00, 0x4E, 0x18, 0x42, 0x01, 0xC8, 0x00, 0x00,
0x00, 0x10, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x01, 0x00, 0x00,
0x4F, 0xC1, 0x03, 0x00, 0x86, 0x02, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x64, 0x40, 0x01, 0x00, 0x87,
0x39
};
//Save Config, Not sure exactly what this does but U-Center does it, so...
static const byte UBX_CFG_CFG[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1D, 0xAB };
@jacky4566-
The NEO 6,7,8 chip has a memory that is powered by a battery. If you save the configuration in BBR, with a normal battery, it will automatically load every time you turn it on. This info is in neo pdf and checked many time.