Uno R4 Wifi not detecting GPS module (SoftwareSerial)

Hello,
I have spent the last while trying to connect my new L86 GPS module to my Uno R4 Wifi. I have tried to do this to get the time and velocity from the GPS, but have been unable to do so so far. I have been using SoftwareSerial, although it is yet to detect that I have a GPS module so far. Having tried swapping the TX and RX pins around several times, and on separate microcontrollers, I have lost all hope in solving this problem on my own. I am not sure what to do to try solve the problem other than getting a different GPS module which I can't do right now. If I left out any information relevant to solving the problem (probably a lot), please tell me. I'm pretty sure this isn't a TinyGPS++ problem as the SoftwareSerial hasn't even detected the module yet.
I am extremely grateful for any help.

L86 Datasheet

Run this program, it should show the characters coming from the GPS, change the #defines to match the pin numbers you have the GPS connected to;

#define RXpin A3              //this is the pin that the Arduino will use to receive data from the GPS
#define TXpin A2              //this is the pin that the Arduino can use to send data (commands) to the GPS - not used

#include <SoftwareSerial.h>
SoftwareSerial GPS(RXpin, TXpin);

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

void setup()
{
  GPS.begin(9600);
  Serial.begin(115200);
  Serial.println("GPS_Echo Starting");
}

I don't know which pins you used for SoftwareSerial as you didn't post your sketch (hint) but you don't need to use it in the first place

The Rx and Tx pins of the Uno R4 WiFi are used by the Serial1 object. See https://docs.arduino.cc/tutorials/uno-r4-wifi/cheat-sheet#usb-serial--uart

Connect the GPS to pins 0 and 1 and use the Serial1 object to communicate with it

The output was only GPS_Echo Starting.

And if you want to use the Serial1 hardware UART, here is the matching program;

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


void setup()
{
  Serial1.begin(9600);
  Serial.begin(115200);
  Serial.println();
  Serial.println("26B_GPS_Echo_Hardware_Serial Starting");
}

Try the hardware Serial1 program then.

Sorry for not originally including a sketch. I have been using pretty much all the TinyGPS++ and SoftwareSerial example sketches I could find, so I don't really have anything in particular. I have tried using Serial1, however I am having the same issue here again where it is not outputting anything at all. Here is the code I used to test it:

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600); 
}

void loop() {
  if (Serial1.available()) {
    char data = Serial1.read();
    Serial.print(data);
  }
}

Here's a step-by-step approach to diagnose the issue:

1. Hardware Check:

  • Connections: Ensure you've connected the GPS module's TX pin to the Uno's chosen RX pin for SoftwareSerial and the GPS module's RX pin to the Uno's TX pin for SoftwareSerial.

  • Power: Make sure the GPS module is powered appropriately. Some modules operate at 3.3V and some at 5V. Connecting a 3.3V GPS module to 5V could damage it.

  • Antenna: Ensure the GPS module has its antenna connected and is placed in an area with a clear view of the sky. It can take some time for the module to get its first fix.

  • LED Indicators: Most GPS modules have LED indicators that blink at different rates depending on if they've got a satellite lock. Refer to your module's datasheet.

2. SoftwareSerial Setup:

#include <SoftwareSerial.h>

SoftwareSerial gpsSerial(3, 4); // RX, TX

void setup() {
  Serial.begin(9600);
  gpsSerial.begin(9600); // Assuming the GPS module works at 9600 baud rate. Check datasheet.
}

void loop() {
  while (gpsSerial.available()) {
    char c = gpsSerial.read();
    Serial.print(c); // Echo everything received from GPS module to Serial Monitor
  }
}

With this code, you should be able to see raw NMEA sentences from the GPS in the Serial Monitor. If you see data, that means your connections are correct and SoftwareSerial is working.

3. External Power:

Sometimes, the Uno can't provide sufficient power for both itself and the GPS module, especially when connected via USB to a computer. Consider powering the GPS module separately while ensuring that the grounds are connected.

4. Baud Rate:

Make sure the baud rate you've set in SoftwareSerial matches the baud rate of the GPS module. Check the GPS module's datasheet or specification.

5. Try Another Library:

Although you mentioned it's likely not a TinyGPS++ issue, it wouldn't hurt to try another library or even try the module without a library first, as shown in the SoftwareSerial code above.

6. Check Pins:

Uno WiFi R4 might have some pins reserved for the WiFi functionality. Ensure the pins you're using for SoftwareSerial aren't being interfered with by onboard components.

7. Serial Monitor:

Ensure the Serial Monitor's baud rate matches the rate you initialized in Serial.begin(). In the example above, it's set to 9600.

8. Physical Examination:

Examine the GPS module for any signs of physical damage, such as burnt areas, broken pins, or any other anomalies.

9. Alternative Communication:

If your GPS module supports I2C or SPI, consider trying those communication methods.

10. External Tools:

If you have access to a logic analyzer or an oscilloscope, you can probe the TX line of the GPS to see if it's transmitting data.

Final Thoughts:

If after all these steps you're still not getting data, and you've confirmed the GPS module is powered and operational, then there might be an issue with the GPS module itself or a deep compatibility issue. But usually, going step-by-step and isolating each part of the problem helps in identifying the root cause.

I've loaded the code provided by srnet in post #2 on to 3 different Unos:
a Uno R3, a Uno R4 Minima, and a Uno R4 WiFi.

Each behave differently for the same sketch and GPS module.

The results are as follows:

  • Uno R3 - displays "GPS_Echo Starting" and then NMEA sentences on the Serial Monitor.

  • Uno R4 Minima - no output from the Serial Monitor.

  • Uno R4 WiFi - displays "GPS_Echo Starting" from start up().

It's looking to me as though Software Serial hasn't yet been implemented on the Uno R4s.

I used Arduino IDE 2.1.1, and allowed it to update libraries before the test.

The differences in behavior between the boards, especially with SoftwareSerial, suggest some board-specific incompatibilities or unimplemented features. Here's a potential fix:

1. Use Hardware Serial:
When SoftwareSerial causes trouble, one direct solution is to utilize the built-in hardware serial, which is generally more reliable.

void setup() {
  Serial.begin(9600);
  Serial.println("GPS_Echo Starting");
}

void loop() {
  if (Serial.available()) {
    char c = Serial.read();
    Serial.print(c); // Echo the received data back to the Serial Monitor
  }
}

Note: When using the Hardware Serial, you can't use the Serial Monitor to debug simultaneously (unless you have multiple hardware serial ports).

2. Use AltSoftSerial:
AltSoftSerial is an alternative to SoftwareSerial and often works in scenarios where the latter doesn't.

#include <AltSoftSerial.h>
AltSoftSerial altSerial;

void setup() {
  Serial.begin(9600);
  altSerial.begin(9600);
  Serial.println("GPS_Echo Starting");
}

void loop() {
  while (altSerial.available()) {
    char c = altSerial.read();
    Serial.print(c);  // Send the received data to the main serial port
  }
}

Note: AltSoftSerial uses specific pins for RX and TX, so ensure it's compatible with your board and doesn't conflict with other components.

3. Board-specific Definitions:
Make sure you've selected the correct board in the Arduino IDE. Sometimes the pin definitions for SoftwareSerial may differ between board versions.

  • Go to Tools > Board and ensure the correct version (R3, R4 Minima, or R4 WiFi) is selected.

4. Check for Updates:
It's possible that there might be updates or patches available for the newer R4 boards.

  • In the Arduino IDE, go to Tools > Board > Boards Manager and check if there are updates available for the Uno R4 boards.

5. Test Without Libraries:
To ascertain if the issue is specifically with SoftwareSerial, run a basic code that doesn't involve any libraries and see if all the boards behave similarly.

void setup() {
  Serial.begin(9600);
  Serial.println("Testing Basic Serial");
}

void loop() {
  Serial.println("Looping...");
  delay(1000);
}

If all boards display the looping message, then it further narrows down the issue to the SoftwareSerial library or its interaction with the GPS module.

Finally, if none of these solutions work, it may be worth reaching out on specialized forums or the manufacturer's support. There might be known issues with the newer boards or specific configurations that others have encountered and resolved.

That's a good idea, why don't we try it. :scream:

1 Like

So the GPS is working and you have the baud rate correct.

Yes, that is correct. It also verifies that I have the TX and RX the right way round.

I have just noticed that the GPS module I was testing with only has a 3V output (no level converter). Maybe its not enough for the R4s to see as a high, but OK for the R3.

I've got another with 3V3 output that I can try to see if the extra 300mV makes a difference.

Will contributors to this topic please stop suggesting the use of SoftwareSerial to read the GPS output. It is simply not needed when using the Uno R4 WiFi

This works for me, but only when the GPS has got a fix, of course


void setup()
{
    Serial.begin(115200);
    Serial1.begin(9600);
}

void loop()
{
    if (Serial1.available())
    {
        Serial.write(Serial1.read());
    }
}

1 Like

I'm having the same problem and I wonder if the original poster has found a solution?

The following code (the commented out sections) works perfectly with the UNO R3 but I cannot read any serial data from the GPS module when it's connected the the UNO R4 WiFi board. The GPS module's serial tx pin is connected to the R4's pin 0.

Any help will greatly appreciated.

/*
 * Rui Santos 
 * Complete Project Details http://randomnerdtutorials.com
 */

#include <TinyGPS++.h>
//#include <SoftwareSerial.h>

static const int RXPin = 0, TXPin = 1; // RXPin = 4 for UNO 3 
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
//SoftwareSerial ss(RXPin, TXPin);

void setup() {
  Serial.begin(9600);
  //ss.begin(GPSBaud);
  Serial1.begin(GPSBaud);
}

void loop() {
  // This sketch displays information every time a new sentence is correctly encoded.
  while (Serial1.available() > 0) {
    Serial1.write(Serial1.read());
    gps.encode(Serial1.read());
    if (gps.location.isUpdated()) {
      Serial.print("Latitude= ");
      Serial.print(gps.location.lat(), 6);
      Serial.print(" Longitude= ");
      Serial.println(gps.location.lng(), 6);
    }
  //while (ss.available() > 0) {
  //  gps.encode(ss.read());
  //  if (gps.location.isUpdated()) {
  //    Serial.print("Latitude= ");
  //    Serial.print(gps.location.lat(), 6);
  //    Serial.print(" Longitude= ");
  //    Serial.println(gps.location.lng(), 6);
  //  }
  }
}

FIrst, do you want to echo the character back to the gps by writing to Serial1, or did you intend to use Serial to send to the serial monitor?
Next, you read the character out of the buffer in the following line:

    Serial1.write(Serial1.read());

You have not lost that character, and cannot read it again for the 2nd read to the gps.encode().

Instead try the following line to send the character to the serial monitor without removing it from the receive buffer.

  Serial.write(Serial1.peek());

Thank you david_2018.

The idea is to display the lat and lon on the serial monitor. The code that ran on the UNO 3 did just that. However, I'm now thinking that the problem is the data level not being compatible with the UNO R4. Perhaps the UNO R4 expects the data level to be 0 - 5 volts rather that 0 - 3 volts.

This piece of code from UKHeliBob should read something but it doesn't. I have serial data connected to pin 0.

void setup()
{
    Serial.begin(115200);
    Serial1.begin(9600);
}

void loop()
{
    if (Serial1.available())
    {
        Serial.write(Serial1.read());
    }
}

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