So I've been trying to first disable any NMEA messages and instead run NAV-POSLLH messages instead for the Be-880 GPS chip by writing byte values to the chip. My problem is that when I run the second function I have none of the messages come back to the Arduino from the chip. I've been working on this for a weeks now and nothing I do fixes it.
#include <SoftwareSerial.h>
// Connect the GPS RX/TX to arduino pins 3 and 5
SoftwareSerial serial = SoftwareSerial(3,5);
const char UBLOX_INIT[] PROGMEM = {
// Disable NMEA
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
// Disable UBX
0xB5,0x62,0x06,0x01,0x08,0x00,0x01,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x17,0xDC, //NAV-PVT off
0xB5,0x62,0x06,0x01,0x08,0x00,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0xB9, //NAV-POSLLH off
0xB5,0x62,0x06,0x01,0x08,0x00,0x01,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0xC0, //NAV-STATUS off
// Enable UBX
//0xB5,0x62,0x06,0x01,0x08,0x00,0x01,0x07,0x00,0x01,0x00,0x00,0x00,0x00,0x18,0xE1, //NAV-PVT on
0xB5,0x62,0x06,0x01,0x08,0x00,0x01,0x02,0x00,0x01,0x00,0x00,0x00,0x00,0x13,0xBE, //NAV-POSLLH on
//0xB5,0x62,0x06,0x01,0x08,0x00,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x14,0xC5, //NAV-STATUS on
// Rate
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)
};
void setup()
{
serial.begin(9600);
// send configuration data in UBX protocol
for(int i = 0; i < sizeof(UBLOX_INIT); i++) {
serial.write( pgm_read_byte(UBLOX_INIT+i) );
delay(5); // simulating a 38400baud pace (or less), otherwise commands are not accepted by the device.
}
}
void loop() {}
'''
The function below is supposed to print out the NAV-POSLLLH messages I want to the serial monitor but nothing is happening. When going through the code I found that the checksum function isn't working but I'm not sure why.
'''
#include <SoftwareSerial.h>
// Connect the GPS RX/TX to arduino pins 3 and 5
SoftwareSerial serial = SoftwareSerial(3,5);
const unsigned char UBX_HEADER[] = { 0xB5, 0x62 };
struct NAV_POSLLH {
unsigned char cls;
unsigned char id;
unsigned short len;
unsigned long iTOW;
long lon;
long lat;
long height;
long hMSL;
unsigned long hAcc;
unsigned long vAcc;
};
NAV_POSLLH posllh;
void calcChecksum(unsigned char* CK) {
memset(CK, 0, 2);
for (int i = 0; i < (int)sizeof(NAV_POSLLH); i++) {
CK[0] += ((unsigned char*)(&posllh))[i];
CK[1] += CK[0];
}
}
bool processGPS() {
static int fpos = 0;
static unsigned char checksum[2];
const int payloadSize = sizeof(NAV_POSLLH); //32
while ( serial.available() ) {
byte c = serial.read();
byte t = UBX_HEADER[fpos];
if ( fpos < 2 ) {
if ( c == t )
fpos++;
else
fpos = 0;
}
else {
if ( (fpos-2) < payloadSize ) {
((unsigned char*)(&posllh))[fpos-2] = c;
}
fpos++;
if ( fpos == (payloadSize+2) ) {
calcChecksum(checksum);
}
else if ( fpos == (payloadSize+3) ) {
Serial.println(c);
byte y = checksum[0];
Serial.println(y);
if ( c != y) {
fpos = 0;
}
}
else if ( fpos == (payloadSize+4) ) {
fpos = 0;
byte l = checksum[1];
if ( c == l ) {
return true;
}
}
else if ( fpos > (payloadSize+4) ) {
fpos = 0;
}
}
}
return false;
}
void setup()
{
Serial.begin(9600);
serial.begin(9600);
}
void loop() {
if ( processGPS() ) {
Serial.print("iTOW:"); Serial.print(posllh.iTOW);
Serial.print(" lat/lon: "); Serial.print(posllh.lat/10000000.0f); Serial.print(",");
Serial.print(posllh.lon/10000000.0f);
Serial.print(" height: "); Serial.print(posllh.height/1000.0f);
Serial.print(" hMSL: "); Serial.print(posllh.hMSL/1000.0f);
Serial.print(" hAcc: "); Serial.print(posllh.hAcc/1000.0f);
Serial.print(" vAcc: "); Serial.print(posllh.vAcc/1000.0f);
Serial.println();
}
}