NEO-6M GPS data problem with OLED(SSD1306)

I am currently trying to display the received data from the NEO-6M GPS module on an OLED with Arduino UNO.
I have launched the following Sample 1 program, and I am able to receive the desired GPS data as shown on the serial monitor.

---Sample1

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

const int P_RX = 8; // for SoftwareSerial RX
const int P_TX = 7; // for SoftwareSerial TX

TinyGPSPlus gps;
SoftwareSerial mySS(P_RX, P_TX);

void setup() {
  Serial.begin(9600); // Serial Speed
  mySS.begin(9600);   // SoftwareSerial Speed
}

void loop() {
  while (mySS.available() > 0){
    gps.encode(mySS.read());
    display_monitor();
  }
}

void display_monitor() {
  if (gps.location.isUpdated()) {
    Serial.print("GPS Time ");
    Serial.print(gps.time.hour());
    Serial.print(":");
    Serial.print(gps.time.minute());
    Serial.print(":");
    Serial.println(gps.time.second());
    Serial.print(" SateNum=");
    Serial.println(gps.satellites.value());
    Serial.print(" LNG=");
    Serial.print(gps.location.lng(), 6);
    Serial.println(" ");
  }
}


Serial Log

GPS Time 0:8:48
SateNum=8
LNG=140.880020
GPS Time 0:8:49
SateNum=8
LNG=140.880035
GPS Time 0:8:49
SateNum=8
LNG=140.880035
GPS Time 0:8:50
SateNum=8
LNG=140.880035

The following Sample 2 program is intended to display the GPS received data on the OLED. It seems that the GPS time and longitude (LNG) data are displayed correctly, but the display of the number of GPS satellites is always zero.
---Sample2

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

const int P_RX = 8; // for SoftwareSerial RX
const int P_TX = 7; // for SoftwareSerial TX

TinyGPSPlus gps;
SoftwareSerial mySS(P_RX, P_TX);

#include<Wire.h>             
#include<Adafruit_GFX.h>     
#include<Adafruit_SSD1306.h>

#define OLED_RST -1
#define OLED_WIDTH 128
#define OLED_HEIGHT 64

Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT, &Wire, OLED_RST);

void setup() {
  Serial.begin(9600); // Serial Speed
  mySS.begin(9600);   // SoftwareSerial Speed

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.clearDisplay();  
}

void loop() {
  while (mySS.available() > 0){
    gps.encode(mySS.read());
    //display_monitor();
    display_OLED();
  }
}

void display_monitor() {
  if (gps.location.isUpdated()) {
    Serial.print("GPS Time ");
    Serial.print(gps.time.hour());
    Serial.print(":");
    Serial.print(gps.time.minute());
    Serial.print(":");
    Serial.println(gps.time.second());
    Serial.print(" SateNum=");
    Serial.println(gps.satellites.value());
    Serial.print(" LNG=");
    Serial.print(gps.location.lng(), 6);
    //Serial.print(" ALT=");
    //Serial.print(gps.altitude.meters());
    //Serial.print(" SPEED=");
    //Serial.print(gps.speed.kmph());
    Serial.println(" ");
  }
}

void display_OLED() {
  if (gps.location.isUpdated()) {
    display.clearDisplay();
    display.setCursor(0,0);
    display.println("GPS Time");
    display.print(gps.time.hour());
    display.print(":");
    display.print(gps.time.minute());
    display.print(":");
    display.println(gps.time.second());
    display.print(" SateNum=");
    display.println(gps.satellites.value());
    display.print(" LNG=");
    display.println(gps.location.lng(), 6);
    display.display();
  }
}

When operated together with the OLED, the data for the number of GPS satellites seems to become abnormal, but I cannot understand the cause.

Could you please instruct me on how to address this issue?

This should not be in the time-critical section of code that updates TinyGPS, in both examples. Put the call elsewhere.

For example

  while (mySS.available() > 0){
    gps.encode(mySS.read());
 }
   if (gps.location.isUpdated()) display_monitor();
  }

If you are using an Uno or other ATmega328 Arduino, keep in mind that the display allocates half of the available dynamic memory, sometimes leading to unexpected behavior or program crashes.

You need to be careful when using an OLED with a GPS, updating the display can easily result in overflowing the Rx buffer and losing some of the GPS data. This is especially true when running SoftwareSerial, because the interrupts used by SoftwareSerial slow everything else down.

The GPS is likely sending the GPRMC sentence first.

Thus when its received, the GPS library updates the location and your code then goes off and prints and displays a whole lot of stuff which takes a long time.

By the time you get back to reading the GPS, you have missed the GPGGA sentence which contains the number of satellites, hence this number is not updated.

Just because the location data is updated it does not mean all the other bit of GPS data have also been updated, you need to check ......

Thak you for your comment and example.
I’ve been trying to do this project with Arduino UNO. I have got understood that there is a problem with the memory capacity.
I am going to consider using other Arduino Board.

Thank you for your advice.
I tried using hardware serial, but this problem persisted.
I suspect that the overflow is occurring in the RX buffer, regardless of whether it is related to software serial communication or hardware serial communication.

As I said in post #4 I suspect the issue is with the way you are reading the GPS.

Easy to fix.

Thank you for your comment.
As demonstrated in sample 1 of Post #1, I have confirmed that the satellite data updates are displayed using a similar reading method when shown on the serial monitor.
Therefore, I anticipate that the issue arises when displaying GPS data using an OLED connected via I2C.

A hint, you have incorrectly assumed that if the location has been updated then the number of satellites has been updated as well, this is not the case.

So if you are missing the satellites make sure that they are updated before printing and displaying stuff. Try this;

if (gps.location.isUpdated() && (gps.satellites.isUpdated())
{

And if you want to be sure that both GPRMC and GPGGA sentences have been received and encoded use this;

if (gps.speed.isUpdated() && gps.satellites.isUpdated()) //ensures that GGA and RMC sentences have been received