Thanks again /dev. I'm using only latitude and longitude so I believe the message I need is GLL. Oddly, and still using TinyGPS++, when I disable the NMEA sentences other than GLL and change the rate to 5Hz, the updates still come no faster than once a second. Even with GLL disabled lat and lon values are still sent, so I wonder if the ublox config changes are having any effect.
If you wouldn't mind, please have a look over my sketch below, which includes code for an additional motion sensor
cheers,
#include "TinyGPS++.h"
#include <SoftwareSerial.h>
#include "NAxisMotion.h" //Contains the bridge code between the API and the Arduino Environment
#include <Wire.h>
static const int RXPin = 9, TXPin = 8;
static const uint32_t GPSBaud = 9600;
const unsigned char UBLOX_INIT[] PROGMEM = {
// Rate (pick one)
// 0xB5,0x62,0x06,0x08,0x06,0x00,0x64,0x00,0x01,0x00,0x01,0x00,0x7A,0x12, //(10Hz)
0xB5,0x62,0x06,0x08,0x06,0x00,0xC8,0x00,0x01,0x00,0x01,0x00,0xDE,0x6A, //(5Hz)
// 0xB5,0x62,0x06,0x08,0x06,0x00,0xE8,0x03,0x01,0x00,0x01,0x00,0x01,0x39, //(1Hz)
// Disable specific NMEA sentences
0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x24, // GxGGA off
//0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x2B, // GxGLL off
0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x32, // GxGSA off
0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x39, // GxGSV off
0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x04,0x00,0x00,0x00,0x00,0x00,0x01,0x04,0x40, // GxRMC off
0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x05,0x00,0x00,0x00,0x00,0x00,0x01,0x05,0x47 // GxVTG off
};
/*uint8_t gps_config_change[63]={// Rate to 250 ms
// 0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xFA, 0x00, 0x01, 0x00, 0x01, 0x00,
// 0x10, 0x96,
// Rate to 200 ms
0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, 0xC8, 0x00, 0x01, 0x00, 0x01, 0x00,
0xDE, 0x6A,
// Baud Change
// 0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08,
// 0x00, 0x00, 0x00, 0xC2, 0x01, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0xBF, 0x78,
0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x00, 0xC2,
0x01, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x7E,
// Save Config
0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1D, 0xAB};
*/
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
NAxisMotion mySensor; //Object that for the sensor
unsigned long lastStreamTime = 0; //To store the last streamed time stamp
const int streamPeriod = 20; //To stream at 50Hz without using additional timers (time period(ms) =1000/frequency(Hz))
unsigned long lat = 0;
unsigned long lng = 0;
void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
for(unsigned int i = 0; i < sizeof(UBLOX_INIT); i++) {
ss.write( pgm_read_byte(UBLOX_INIT+i) );
};
I2C.begin(); //Initialize I2C communication to the let the library communicate with the sensor.
//Sensor Initialization
mySensor.initSensor(); //The I2C Address can be changed here inside this function in the library
mySensor.setOperationMode(OPERATION_MODE_NDOF); //Can be configured to other operation modes as desired
mySensor.setUpdateMode(MANUAL); //The default is AUTO. Changing to MANUAL requires calling the relevant update functions prior to calling the read functions
//Setting to MANUAL requires fewer reads to the sensor
}
void loop()
{
while (ss.available() > 0) {
if (gps.encode(ss.read())){
if (gps.location.isValid())
{
if (gps.location.isValid()) {
float latf = gps.location.lat();
float lngf = gps.location.lng();
lat = (latf + 90) * (2147483647 / 180);
lng = (lngf + 180) * (2147483647 / 360);
}
}
}
}
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
while(true);
}
// This sketch displays information every time a new sentence is correctly encoded.
if ((millis() - lastStreamTime) >= streamPeriod)
{
lastStreamTime = millis();
mySensor.updateEuler(); //Update the Euler data into the structure of the object
//mySensor.updateCalibStatus(); //Update the Calibration Status
float headingf;
// correct heading data for 90deg rotation of hardware
headingf = mySensor.readEulerHeading() - 90;
if (headingf < 0) {
headingf = (360 + headingf);
};
// adjust data to suit the receiving software software
if (headingf > 180) {
headingf = -180 + (headingf - 180);
};
headingf = headingf * 3.1415926535898 / 180; // convert heading to radians
float rollf;
rollf = mySensor.readEulerRoll();
if (rollf > 180) {
rollf = -180 + (rollf - 180);
};
rollf = rollf * 3.1415926535898 / 180; // convert to radians
float pitchf;
pitchf = mySensor.readEulerPitch() * -1;
if (pitchf > 180) {
pitchf = -180 + (pitchf - 180);
};
pitchf = pitchf * 3.1415926535898 / 180; // convert to radians
// note pitch and roll are swapped below because I rotate z axis of device bt 90 degrees
unsigned int heading = (headingf + 3.1415926535898) * 100;
unsigned int pitch = (rollf + 3.1415926535898) * 100;
unsigned int roll = (pitchf + 3.1415926535898) * 100;
Serial.write(251);
Serial.write(252);
Serial.write(253);
Serial.write(254);
Serial.write(heading >> 8); //high 8bits
Serial.write(heading & 255); //low 8bits
Serial.write(roll >> 8);
Serial.write(roll & 255);
Serial.write(pitch >> 8);
Serial.write(pitch & 255);
Serial.write(lat & 255);
Serial.write((lat >> 8) & 255);
Serial.write((lat >> 16) & 255);
Serial.write((lat >> 24) & 255);
Serial.write(lng & 255);
Serial.write((lng >> 8) & 255);
Serial.write((lng >> 16) & 255);
Serial.write((lng >> 24) & 255);
Serial.write(255);
}
}