GPS is connected but will not display data to OLED screen

Hi all, Im new to Arduino and the forms so if I mess anything up as far as formation or the like goes just let me know and ill fix it.

I have been working on a recent project where I'm trying to use a GT-U7 GPS module to display basic GPS info (lat, long, altitude, date, time, and satellite count) to a small OLED screen. One small thing to note is that the screen in the diagram has an SCK pin whereas the screen I'm using has an SCL instead. When I have used this GPS with test code it has been able to display GPS info to the serial monitor. When I have it hooked up to the screen simply displays all zeros for the values even though the GPS will have a blinking red light, indicating it has a connection to a satellite. I have tried adding code that tells it not to display anything until the GPS updates but even when the light flashes on the GPS it displays zeros. It's pretty simple wiring and I have tested all the components so I am sure they work, so I'm assuming it's a coding issue. I have included the code file so let me know if you have any ideas.


#include "TinyGPS++.h"
#include "SoftwareSerial.h"
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

SoftwareSerial serial_connection(10, 11);
TinyGPSPlus gps;

Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

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

  Serial.println("GPS Start");

  if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    while (true);
  }

  delay(2000);

  oled.clearDisplay();
  oled.setTextSize(1);
  oled.setTextColor(WHITE);

}

void loop() {
if (!serial_connection.available())
    return; 

  if (!gps.encode(serial_connection.read())
    return;

  Serial.println("Satellite Count:");
  Serial.println(gps.satellites.value());
  Serial.println("Latitude:");
  Serial.println(gps.location.lat(), 6);
  Serial.println("Longitude:");
  Serial.println(gps.location.lng(), 6);
  Serial.println("Speed MPH:");
  Serial.println(gps.speed.mph());
  Serial.println("Altitude Feet:");
  Serial.println(gps.altitude.feet());
  Serial.println("");

  oled.setCursor(0, 9);
  oled.println("Sat Cnt: ");
  oled.setCursor(49, 9);
  oled.println(gps.satellites.value());
  oled.display();

  oled.setCursor(62, 0);
  oled.println(gps.date.month());
  oled.setCursor(69, 0);
  oled.println(gps.date.day());
  oled.setCursor(76, 0);
  oled.println(gps.time.second());
  oled.display();

  oled.setCursor(0, 0);
  oled.println(gps.time.hour());
  oled.setCursor(7, 0);
  oled.println(gps.time.minute());
  oled.setCursor(14, 0);
  oled.println(gps.date.year());
  oled.display();

  oled.setCursor(0, 19);
  oled.println("Lat: ");
  oled.setCursor(25, 19);
  oled.println(gps.location.lat(), 6);
  oled.display();

  oled.setCursor(0, 29);
  oled.println("Lon: ");
  oled.setCursor(25, 29);
  oled.println(gps.location.lng(), 6);
  oled.display();

  oled.setCursor(0, 39);
  oled.println("Alt: ");
  oled.setCursor(25, 39);
  oled.println(gps.altitude.meters());
  oled.display();

  oled.setCursor(0, 49);
  oled.println("kph: ");
  oled.setCursor(25, 49);
  oled.println(gps.speed.kmph());
  oled.display();

  delay(500);

  oled.clearDisplay();

}

-Cheers

Which Arduino are you using? Pins 0 & 1 are generally reserved for uploading and serial monitor connection. They should never be used with SoftwareSerial.

The reason you are not getting any data appears to be because you are not using using TinyGPS++ correctly.

Make sure that the simple example in the TinyGPS++ library works with the serial monitor and SWSerial before trying to use the display.

Don't use pins 0 & 1 for software serial... they are used for the serial monitor.

Given you are using a Mega it has multiple hardware serial ports... you don't even need to use software serial. Anyway for now just try using pins other tham 0 & 1 and see if you get some data.

Looks like you are talking to the display OK... it the connection to the GPS that is the problem.

Im using a mega 2560, I've switched the pins, RX is now 10 and TX is now 11 and the same problem persists it's been sitting outside with the new pins for over a half hour.

Post the revised code. Did you verify that the example programs in the TinyGPS++ library work?

Better, learn to use the additional hardware serial ports on the Mega, and try this echo program to determine if the GPS is working and has a fix.

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);  //connect to Serial1 RX and TX
  Serial.println("GPS start");
}

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

ok I've switched the pins to 10 and 11, its been outside for a good bit now and is still having the same issue

First off thank you for the help, I ran this exact code and it displayed the GPS start message in the serial and it hasnt done much else, the light on my GPS is blinking indicating it does have a connection.

I do wonder what that "much else" might be.

Would you care to enlighten us? Like post some of the text output?

it legit is just saying GPS start

That tells me that this line has executed:

  Serial.println("GPS start");

If nothing else is printed, you have not made valid serial connections to the GPS.

Connect Mega pin labeled RX1 to GPS TX and Mega GND to GPS GND.

Can the GPS module also see satellites or only your ceiling?

You forgot to read data from the GPS!

Try adding that part:

void loop() {
  if (!serial_connection.available())
    return; // No characters to process

  if (!gps.encode(serial_connection.read()))
    return; // No new message received.

  // A new, complete message has arrived from the GPS
  // Now we might have data to display!

  Serial.println("Satellite Count:");
  Serial.println(gps.satellites.value());

Thank you for the help. I apologize if this is a silly question but when I paste that bit of code in the programmer reads an error and says this "

gps_oled_test_1:40:5: error: expected ';' before 'return'

 return; // No new message received.

 ^~~~~~

gps_oled_test_1:42:37: error: expected ')' before ';' token

Serial.println("Satellite Count:");

                                ^

exit status 1

expected ';' before 'return' "

Im Very new to programing what should I do?

Looks like it was pasted in the wrong place.

I'm afraid I don't understand, I pasted the bit of code right after the void loop command and it is inside of the brackets. Could you be more specific on where I should put it?
-Thanks

Post your latest code, using code tags.

I just updated the code in the original post to be the latest version.

Please Do Not update the original post.

It makes the thread nearly impossible to follow.

Fix the parentheses:

  if (!gps.encode(serial_connection.read())
      return;