Serial reading from a GNSS or GPS receiver

I am trying to log data from a GNSS receiver through the SerialX port. the sketch I am using is the example "Example5_Customserial" from the Sparkfun u-blox GNSS v3 library. The Arduino Giga cannot parse any data from the receiver saying it is not connected. I have already tried the same example from older libraries of Sparkfun. Does anyone of you have the same problem?
The GNSS module I use, the GNSS 7 click by Mikroe, has also an USB port, but I am not sure if I can use to log from USB-A on the Arduino

their documentation states

The GNSS 7 click supports both SPI and I2C/UART communication protocol configurations. Therefore, this Click board™ have communication interface selection jumpers, in order to allow the user to set whether to use SPI communication or combination. A USB interface (micro USB port), which is compatible with the USB version 2.0 FS (Full Speed, 12 Mbit/s), can be used for communication as an alternative to the UART. The USB port can be used as a power supply as well if you need the click board™ to be a standalone device.

➜ how is the board configured?

The board has also an RX and TX pin for Serial UART communication at 38400 bps. On Arduino Mega, I used that for ease and stability of Serial; on the other hand, on the Giga, the Serial interface seems bugged and cannot read anything even when I use simple commands like Serial Read or Serial available. I set some parameters, like data to be parsed, on U-center software, to avoid buffer overload in the GNSS. As regarding USB I have not tried it yet because I see no libraries for the communication

So you need to fix that issue first before starting to read GNSS with the library. Start from reading GNSS output by one Serial and output it to the Monitor. It helps you to sure that the receiver outputs correct data.

Please show your connection diagram and the code.

I don't have this hardware but I would be really surprised if a hardware serial port on the Giga does not work as expected.

/*
  Reading Position, Velocity and Time (PVT) via UBX binary commands
  By: Paul Clark
  SparkFun Electronics
  Date: December 21st, 2022
  License: MIT. Please see LICENSE.md for more information.

  This example shows how to query a u-blox module for its position, velocity and time (PVT) data using UART2.

  UART2 is only available on modules like the ZED-F9P/R/T/K etc.. It is not available on the MAX-M10.

  Important note:
  By default, the UBX protocol is enabled for INPUT on UART2, but not for OUTPUT.
  The code needs to enable UBX output for the begin to succeed.

  Feel like supporting open source hardware?
  Buy a board from SparkFun!
  SparkFun GPS-RTK2 - ZED-F9P (GPS-15136)    https://www.sparkfun.com/products/15136
  SparkFun GPS-RTK-SMA - ZED-F9P (GPS-16481) https://www.sparkfun.com/products/16481
  SparkFun MAX-M10S Breakout (GPS-18037)     https://www.sparkfun.com/products/18037
  SparkFun ZED-F9K Breakout (GPS-18719)      https://www.sparkfun.com/products/18719
  SparkFun ZED-F9R Breakout (GPS-16344)      https://www.sparkfun.com/products/16344

  Hardware Connections:
  Hook up the TX, RX and GND pins, plus 3V3 or 5V depending on your needs
  Connect: GNSS TX to microcontroller RX; GNSS RX to microcontroller TX
  Open the serial monitor at 115200 baud to see the output
*/

#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3

SFE_UBLOX_GNSS_SERIAL myGNSS;

#define mySerial Serial1 // Use Serial1 to connect to the GNSS module. Change this if required

void setup()
{
  Serial.begin(115200);
  delay(1000); 
  Serial.println("SparkFun u-blox Example");

  mySerial.begin(38400); // u-blox F9 and M10 modules default to 38400 baud. Change this if required

  //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial

  myGNSS.connectedToUART2(); // This tells the library we are connecting to UART2 so it uses the correct configuration keys

  while (myGNSS.begin(mySerial) == false) //Connect to the u-blox module using mySerial (defined above)
  {
    Serial.println(F("u-blox GNSS not detected"));
    
    Serial.println(F("Attempting to enable the UBX protocol for output"));
    
    myGNSS.setUART2Output(COM_TYPE_UBX); // Enable UBX output. Disable NMEA output
    
    Serial.println(F("Retrying..."));
    delay (1000);
  }

  //myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Optional: save (only) the communications port settings to flash and BBR
}

void loop()
{
  // Request (poll) the position, velocity and time (PVT) information.
  // The module only responds when a new position is available. Default is once per second.
  // getPVT() returns true when new data is received.
  if (myGNSS.getPVT() == true)
  {
    int32_t latitude = myGNSS.getLatitude();
    Serial.print(F("Lat: "));
    Serial.print(latitude);

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

    int32_t altitude = myGNSS.getAltitudeMSL(); // Altitude above Mean Sea Level
    Serial.print(F(" Alt: "));
    Serial.print(altitude);
    Serial.print(F(" (mm)"));

    Serial.println();
  }
}

here is the code I used.


I connected:

  • TX to Giga pin 19 (RX1)
  • RX to Giga pin 18 (TX1)
  • and supplying pin
    Serial output is:
    u-blox GNSS not detected
    Attempting to enable the UBX protocol for output
    Retrying...

did you connect the GNDs?

Yes, even if it should be a common ground

It looks like a too much contradicted settings about GNSS serial:

Is UART2 and Serial1 are the same on Giga?

just reading from the code's comments

and what you said

does it make sense ?

Uart2 is the communication port on the GNSS chip, not on Arduino, which correspond on tx and rx on the chip

OK I don't know enough about that module then

(does your module support UART2 ? is it the right one? have you tried without calling this?)

I have just done some tests with the Giga, the Mega and an oscilloscope. On Mega, the library works flawlessly and with an oscilloscope, I can see that the board can receive and send data. Before the GNSS board starts streaming data needs a prompt from the Arduino Board when the code reaches the line:

myGNSS.connectedToUART2(); 

On the Giga, there is no communication when the code reaches this line

It is quite possible that the library is simply not adapted to Giga. I see inside the code there are conditional compilation directives for different types of Arduino, the Arduino Giga is not there.

after reading a bit about the Giga, it seems that Serial.begin(); is reserved for USB communication and not using one of the UART and the HardwareSerial objects are as follows:

  • Serial1 -> TX0/RX0 (D1, D0)
  • Serial2 -> TX1/RX1 (D18,D19)
  • Serial3 -> TX2/RX2 (D16,D17)
  • Serial4 -> TX3/RX3 (D14,D15)

➜ so if you

then you are not using Serial1 but Serial2


I would change

into

#define mySerial Serial2 // Use Serial1 to connect to the GNSS module. Change this if required

and give it a try

silly using an old label for the Serial ports

Serial without number for what it is?

BTW it works

:cold_face: that's bad from them indeed... I guess that had some stock of those headers with the marking that was suitable for the Mega and they reused them :slight_smile:

great !

Pins 0, 1 should be for Serial1:
Arduino GIGA R1 Cheat Sheet | Arduino Documentation

From that page:

Serial.begin(9600); //initialize serial communication over USB
Serial1.begin(9600); //initialize serial communication on RX0/TX0
Serial2.begin(9600); //initialize serial communication on RX1/TX1
Serial3.begin(9600); //initialize serial communication on RX2/TX2
Serial4.begin(9600); //initialize serial communication on RX3/TX3

Where:

  • RX0 - D0
  • TX0 - D1
  • RX1 - D19
  • TX1 - D18
  • RX2 - 17
  • TX2 - 16
  • RX3 - 15
  • TX3 - 14

yes, that's what I posted in #15

The misleading decision that Arduino made was to use the wrong labels on the pins

pins 14 and 15 are labeled TX3 and RX3 and they refer to Serial4...
(same issue for the others)

Yep - as I believe they do on the Arduino DUE and Mega 2560 R3 at least that is what it looks like
on the website page: Serial - Arduino Reference

Not saying I like it... Just that I think Arduino found that there was no right answer...
Other than simply not putting that labeling on the pins at all

Which the above picture is also confusing as at least with some of them Serial1 is actually Serial2...
:laughing: