Skip to main content

NEO-M9N-00B - Debug Output

This page contains an example of enabling the library's debug output, which prints the raw UBX packets and internal status messages the library sends and receives. Use this to troubleshoot communication issues or see what's actually happening under the hood.


Initialization

Include the required libraries and create the module object:

#include <Wire.h>
#include <Soldered-GNSS.h>

Soldered_GNSS myGNSS;

unsigned long lastTime = 0;
int counter = 0;

In the setup() function, initialize the module and turn on debugging:

void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println("Soldered u-blox GNSS Example - Debug Output");

Wire.begin();

if (myGNSS.begin() == false)
{
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}

myGNSS.setI2COutput(COM_TYPE_UBX);

myGNSS.enableDebugging(); // Print all debug messages to Serial
// myGNSS.enableDebugging(Serial, true); // Or print only critical messages
}

myGNSS.begin()

Initializes the GNSS module and establishes I2C communication

Returns value: Boolean value, true if the module is detected and communication succeeds, false otherwise

myGNSS.enableDebugging()

Prints the library's internal debug messages (UBX packets sent/received, parsing status, errors) to a Serial port

Returns value: None

Function parameters:

TypeNameDescription
Stream &debugPortOptional. The Serial port to print debug messages to. Defaults to Serial
boolprintLimitedDebugOptional. When true, only critical messages are printed instead of everything. Defaults to false

Taking measurements

In the loop() function, the module is polled once per second. Debug messages print alongside the readings, then automatically stop after 20 readings:

void loop()
{
if (millis() - lastTime > 1000)
{
lastTime = millis();

long latitude = myGNSS.getLatitude();
Serial.print(F("Lat: "));
Serial.print(latitude);

long longitude = myGNSS.getLongitude();
Serial.print(F(" Long: "));
Serial.print(longitude);
Serial.print(F(" (degrees * 10^-7)"));

long altitude = myGNSS.getAltitude();
Serial.print(F(" Alt: "));
Serial.print(altitude);
Serial.print(F(" (mm)"));

byte SIV = myGNSS.getSIV();
Serial.print(F(" SIV: "));
Serial.println(SIV);

counter++;
if (counter == 20)
{
myGNSS.disableDebugging();
}
}
}
Serial monitor debug output
Serial monitor

myGNSS.getLatitude()

Reads the current latitude from the GNSS module

Returns value: Long value, latitude in degrees multiplied by 10^-7

myGNSS.getLongitude()

Reads the current longitude from the GNSS module

Returns value: Long value, longitude in degrees multiplied by 10^-7

myGNSS.getAltitude()

Reads the current altitude from the GNSS module

Returns value: Long value, altitude in millimeters

myGNSS.getSIV()

Reads the number of satellites currently in view

Returns value: Byte value, number of satellites in view

myGNSS.disableDebugging()

Stops the library from printing debug messages

Returns value: None


Full example

You can find the full sketch below:

DebugOutput.ino

An example of enabling debug output while reading GPS position data with the NEO-M9N-00B module