Combining UbxGpsNavPvt and SoftwareSerial
Closed this issue · 2 comments
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('.');
}
Hi, @mkschneider!
I see, the problem is that the UbxGps
constructor is waiting for HardwareSerial
instance, instead of SoftwareSerial
. My bad, I described the problem with SoftwareSerial, but did not test it.
Thank you a lot for your feedback! Just gimme a couple of days and I will update the library. Then I'll wait for your feedback about using the CAM-M8Q, since I haven't tested the library with 8th generation of u-blox modules.
Hi, here I found a workaround.
I need to make some adjustment for my Atmega328p.
See below !
UbxGpsNavPvt gps( (HardwareSerial&) ss);
void setup()
{
gps.begin(GPS_SPEED);
ss.begin(GPS_SPEED); // GPS don't sync without this line
}
Next, I had to modify UbxGps.cpp and UbxGpx.h and UbxGpsNavPvt.h (see attachement).