Raspberry Pi Pico with (u-blox) GPS Mini NEO-6M

Im using Raspberry Pi Pico for development as this project requires a low power drain.

I've configured my Arduino IDE using the Earle Philhower's RP2040 core (GitHub - earlephilhower/arduino-pico: Raspberry Pi Pico Arduino core, for all RP2040 boards)

This is the GPS module: Link to the product -> https://www.amazon.es/dp/B09J916W5V

These are the pins for the module:

VCC: Power supply voltage (typically 3.3V or 5V).
GND: Ground connection.
TXD: UART transmit pin for sending data from the GPS module to the microcontroller (e.g., RP2040 board).
RXD: UART receive pin for receiving data from the microcontroller (e.g., RP2040 board) to the GPS module.

Connected pins as such:

module -> pico

VCC -> 3V3
GND -> GND
TXD -> GP1
RXD -> GP0

I've used many code samples as such:

#include <Arduino.h>

// Define the hardware UART pins
#define GPS_SERIAL Serial1

void setup() {
  // Start the hardware UART at 9600 bps
  GPS_SERIAL.begin(9600);
  Serial.begin(115200); // Initialize Serial for debugging
}

void loop() {
  // Check if data is available from GPS
  if (GPS_SERIAL.available()) {
    // Read the incoming GPS data
    String gpsData = GPS_SERIAL.readStringUntil('\n');
    // Process the GPS data
    // ...
    // Print the GPS data for debugging
    Serial.println(gpsData);
  }
}

GPS module on board LED blinks meaning that a fix was adquired and data is available (as I've readed)

However looks like the problem is with the UART communication since GPS_SERIAL.available() retrieves 0 always.

Do you have any tips to overcome this issue?

Thanks in advace

If you are using Serial1 shouldn't you be using pins GP4 and GP5 on the Pico or defining the pins to be used like this ?

Serial1.setRX(pin);
Serial1.setTX(pin);
Serial1.begin(baud);

afaik GP0 and GP1 are the default pins for the UART0 interface.

In any case will try it

as I've seen here Serial Ports (USB and UART) — Arduino-Pico 3.1.1 documentation

I changed the UART interface to use UART1

#include <Arduino.h>

// Define the hardware UART pins
#define GPS_SERIAL Serial2

void setup() {
  // Start the hardware UART at 9600 bps
  GPS_SERIAL.setRX(5);
  GPS_SERIAL.setTX(4);
  GPS_SERIAL.begin(9600);
  Serial.begin(115200); // Initialize Serial for debugging
}

void loop() {
  // Check if data is available from GPS
  if (GPS_SERIAL.available()) {
    // Read the incoming GPS data
    String gpsData = GPS_SERIAL.readStringUntil('\n');
    // Process the GPS data
    // ...
    // Print the GPS data for debugging
    Serial.println(gpsData);
  } else {
    Serial.println("gps not available");
    }
}

Serial output shows gps not available all the time. Even though the GPS module blinks. UART communication seems to be broken :\

But are you using the UART0 interface when you use Serial1 in the sketch ?

That is a genuine question and I don't know the answer

I would suggest checking the GPS is working by connecting it to a standard USB to serial adapter and reading the output (or not) on a PC.

Its a case of starting at the begining, you need to be sure that the GPS is actually putting out serial. A scope is my go to tool for checking.

Is there a way to redirect UART using the microcontroller (pico) traffic to the usb serial to get direct reading by using minicom?

Yes, UART0 stands for Serial1, and UART1 stands for Serial2

What a stupid naming scheme

Yes, and to use it you would have the GPS_SERIAL.available() line
in the code, but you have already said that bit of code never sees characters from the GPS, but this would be the code ..................

void loop()
{
  while (Serial2.available())
  {
    Serial.write(Serial2.read());
  }
}


void setup()
{
  Serial2.begin(9600);
  Serial.begin(115200);
  Serial.println();
  Serial.println("GPS_Echo_Hardware_Serial Starting");
}

yes, this code doesn't work. Im going to try the same with the C SDK

So, brief update. I've end up trying the C sdk and even micropython without success.

Looks like the module has some problems with communication.

I've ordered a new GPS module

hello mates, it appears that the issue behind the GPS module not providing any data was related to its power needs since the NEO-6M module draws up to 40ma and the pico was only providing 16. I had the same issue with other modules.

Now the issue is that the module is providing encoded data..

It is not. Serial is a virtual serial over USB so, to accommodate to the Arduino schema, UART0 became Serial1 and UART1 became Serial2. :wink:

Why didn't UART0 become Serial0 and UART1, Serial1 ?

It would make more sense logically

I guess they used the same logic as in the Nano 33 IOT. :wink:

I am sure that they did. Mistakes, once made, are often propagated and, of course, once code has been written to use what is defined then it is very difficult to change the definition without breaking an unknown amount of code

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.