Issues with GPS using tinygps.h

So I am using LoRa gps shield which attaches to arduino to get my gps readings but if use the example code it works but for some weird reason in my code, I get incorrect readings.

This is my code for the GPS part :

void GPSRead()
{
  unsigned long age;
  gps.f_get_position(&flat, &flon, &age);
  falt=gps.f_altitude();  //get altitude       
  flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places 
  flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
  falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places
  int32_t lat = flat * 10000;
  int32_t lon = flon * 10000;
  int32_t alt = falt * 100;

  mydata[10] = lat >> 16;
  mydata[11] = lat >> 8;
  mydata[12] = lat;
  mydata[13] = lon >> 16;
  mydata[14] = lon >> 8;
  mydata[15] = lon;
  mydata[16] = alt >> 16;
  mydata[17] = alt >> 8;
  mydata[18] = alt;
  
}

and this is the example which gives correct values :

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

TinyGPS gps;
SoftwareSerial ss(10, 11); // Arduino TX, RX , 

static void smartdelay(unsigned long ms);
static void print_float(float val, float invalid, int len, int prec);
static void print_int(unsigned long val, unsigned long invalid, int len);
static void print_date(TinyGPS &gps);
static void print_str(const char *str, int len);

void setup()
{
  // initialize both serial ports:
  Serial.begin(9600);  // Serial to print out GPS info in Arduino IDE
  ss.begin(9600); // SoftSerial port to get GPS data. 
  while (!Serial) {
     ;
  };
  Serial.println("Minitor Dragino LoRa GPS Shield Status");
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println();
  Serial.println("Sats HDOP Latitude  Longitude  Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum");
  Serial.println("          (deg)     (deg)      Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail");
  Serial.println("-------------------------------------------------------------------------------------------------------------------------------------");
}

void loop()
{
  float flat, flon;
  unsigned long age, date, time, chars = 0;
  unsigned short sentences = 0, failed = 0;
  static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

  print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);
  print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);
  gps.f_get_position(&flat, &flon, &age);
  print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6);
  print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
  print_date(gps);
  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 7, 2);
  print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);
  print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6);
  print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0xFFFFFFFF : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? TinyGPS::GPS_INVALID_F_ANGLE : TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);

  gps.stats(&chars, &sentences, &failed);
  print_int(chars, 0xFFFFFFFF, 6);
  print_int(sentences, 0xFFFFFFFF, 10);
  print_int(failed, 0xFFFFFFFF, 9);
  Serial.println();
  
  smartdelay(1000);
  //delay(1000);
}

static void smartdelay(unsigned long ms)
{
  unsigned long start = millis();
  do 
  {
    while (ss.available())
    {
      //ss.print(Serial.read());
      gps.encode(ss.read());
    }
  } while (millis() - start < ms);
}

static void print_float(float val, float invalid, int len, int prec)
{
  if (val == invalid)
  {
    while (len-- > 1)
      Serial.print('*');
    Serial.print(' ');
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    int flen = prec + (val < 0.0 ? 2 : 1); // . and -
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
      Serial.print(' ');
  }
  smartdelay(0);
}

static void print_int(unsigned long val, unsigned long invalid, int len)
{
  char sz[32];
  if (val == invalid)
    strcpy(sz, "*******");
  else
    sprintf(sz, "%ld", val);
  sz[len] = 0;
  for (int i=strlen(sz); i<len; ++i)
    sz[i] = ' ';
  if (len > 0) 
    sz[len-1] = ' ';
  Serial.print(sz);
  smartdelay(0);
}

static void print_date(TinyGPS &gps)
{
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned long age;
  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  if (age == TinyGPS::GPS_INVALID_AGE)
    Serial.print("********** ******** ");
  else
  {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d ",
        month, day, year, hour, minute, second);
    Serial.print(sz);
  }
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
  smartdelay(0);
}

static void print_str(const char *str, int len)
{
  int slen = strlen(str);
  for (int i=0; i<len; ++i)
    Serial.print(i<slen ? str[i] : ' ');
  smartdelay(0);
}

Please if anyone could help me out. I have been at this for 3 days.

This is not C++

  flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places 
  flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
  falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places

in C++ the comma operator is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).

So when you do flon, 6, you return 6 for example - not 6 digits precision

if you try this code:

volatile float x = 0.123;
void setup()
{
  Serial.begin(115200);
  x = (x > 3) ? 3 : (x , 5);
  Serial.println(x, 6); // here in the x,6 this is not the same thing, it's two parameters of the print function, the second one tells how many decimal point the function should use
}

void loop() {}

You'll see that x took the value 5 .

Don't confuse the comma operator with parameters in functions though, which is what is used in the print command. the second one tells how many decimal point the function should use

J-M-L:
This is not C++

  flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places 

flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
 falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places




in C++ the comma operator is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).

So when you do `flon, 6`, you return 6 for example - not 6 digits precision

So what should I do?

why do you want to only keep 6 decimals? just keep the full value. display 6 decimals when you need to print it..

 flon = (flon == TinyGPS::GPS_INVALID_F_ANGLE) ? 0.0 : flon; 
flat = (flat == TinyGPS::GPS_INVALID_F_ANGLE) ? 0.0 : flat;
falt = (falt == TinyGPS::GPS_INVALID_F_ANGLE) ? 0.0 : falt;

The data is actually going to cayenne using LoRa. I used this code : TTN_mydevice and removed dht and added my own sensors. The data needs to be sent as per the payload format. Even after using the edit you mentioned I am still getting null values. The GPS is kept under open sky.

Post your full code

J-M-L:
Post your full code

Here it is :

#include <lmic.h>
#include <OneWire.h> 
#include <DallasTemperature.h>
#include <hal/hal.h>
#include <SPI.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>
TinyGPS gps;
SoftwareSerial ss(10, 11); // Arduino RX, TX to conenct to GPS module.

#define SENSOR_PIN A3
#define Turbidity_dpin A0

OneWire oneWire(SENSOR_PIN);
DallasTemperature sensors(&oneWire);

float temperature;
int turbidity;
float turbidity1;
uint16_t temp;
int turb;

static void smartdelay(unsigned long ms);
unsigned int count = 1;        //For times count
 
float flat, flon,falt;

static uint8_t mydata[19] = {0x05,0x67,0x00,0x00,0x02,0x67,0x00,0x00,0x03,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};     

/* LoRaWAN NwkSKey, network session key
   This is the default Semtech key, which is used by the prototype TTN
   network initially.
   ttn*/
static const PROGMEM u1_t NWKSKEY[16] = {  };  //Removed For Security

/* LoRaWAN AppSKey, application session key
   This is the default Semtech key, which is used by the prototype TTN
   network initially.
   ttn*/
static const u1_t PROGMEM APPSKEY[16] = {  }; //Removed For Security

/*
 LoRaWAN end-device address (DevAddr)
 See http://thethingsnetwork.org/wiki/AddressSpace
 ttn*/
static const u4_t DEVADDR = 0x******; // Removed For Security

/* These callbacks are only used in over-the-air activation, so they are
  left empty here (we cannot leave them out completely unless
   DISABLE_JOIN is set in config.h, otherwise the linker will complain).*/
void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }


static osjob_t initjob,sendjob,blinkjob;

/* Schedule TX every this many seconds (might become longer due to duty
 cycle limitations).*/
const unsigned TX_INTERVAL = 10;

// Pin mapping
const lmic_pinmap lmic_pins = {
    .nss = 10,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 9,
    .dio = {2, 6, 7},
};

void do_send(osjob_t* j){
    // Check if there is not a current TX/RX job running
    if (LMIC.opmode & OP_TXRXPEND) {
        Serial.println("OP_TXRXPEND, not sending");
    } else {
        GPSRead();
        Tem();
        printdata();
        // Prepare upstream data transmission at the next possible time.
        //  LMIC_setTxData2(1,datasend,sizeof(datasend)-1,0);
        LMIC_setTxData2(1, mydata, sizeof(mydata), 0);
        Serial.println("Packet queued");
        Serial.print("LMIC.freq:");
        Serial.println(LMIC.freq);
        Serial.println("Receive data:");
        
    } 
    // Next TX is scheduled after TX_COMPLETE event.
}

void onEvent (ev_t ev) {
    Serial.print(os_getTime());
    Serial.print(": ");
    Serial.println(ev);
    switch(ev) {
        case EV_SCAN_TIMEOUT:
            Serial.println(F("EV_SCAN_TIMEOUT"));
            break;
        case EV_BEACON_FOUND:
            Serial.println(F("EV_BEACON_FOUND"));
            break;
        case EV_BEACON_MISSED:
            Serial.println(F("EV_BEACON_MISSED"));
            break;
        case EV_BEACON_TRACKED:
            Serial.println(F("EV_BEACON_TRACKED"));
            break;
        case EV_JOINING:
            Serial.println(F("EV_JOINING"));
            break;
        case EV_JOINED:
            Serial.println(F("EV_JOINED"));
            break;
        case EV_RFU1:
            Serial.println(F("EV_RFU1"));
            break;
        case EV_JOIN_FAILED:
            Serial.println(F("EV_JOIN_FAILED"));
            break;
        case EV_REJOIN_FAILED:
            Serial.println(F("EV_REJOIN_FAILED"));
            break;
        case EV_TXCOMPLETE:
            Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
            Serial.println(F(""));
            if(LMIC.dataLen) {
                // data received in rx slot after tx
                Serial.print(F("Data Received: "));
                Serial.write(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
                Serial.println();
            }
            // Schedule next transmission
            os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
            break;
        case EV_LOST_TSYNC:
            Serial.println(F("EV_LOST_TSYNC"));
            break;
        case EV_RESET:
            Serial.println(F("EV_RESET"));
            break;
        case EV_RXCOMPLETE:
            // data received in ping slot
            Serial.println(F("EV_RXCOMPLETE"));
            break;
        case EV_LINK_DEAD:
            Serial.println(F("EV_LINK_DEAD"));
            break;
        case EV_LINK_ALIVE:
            Serial.println(F("EV_LINK_ALIVE"));
            break;
         default:
            Serial.println(F("Unknown event"));
            break;
    }
}

void setup() {
     // initialize digital pin  as an output.
   
    Serial.begin(9600);
     ss.begin(9600);  
    sensors.begin();
    while(!Serial);
    Serial.println(F("LoRa GPS Example---- "));
    Serial.println(F("Connect to TTN"));
    #ifdef VCC_ENABLE
    // For Pinoccio Scout boards
    pinMode(VCC_ENABLE, OUTPUT);
    digitalWrite(VCC_ENABLE, HIGH);
    delay(1000);
    #endif

    // LMIC init
    os_init();
    // Reset the MAC state. Session and pending data transfers will be discarded.
    LMIC_reset();
    /*LMIC_setClockError(MAX_CLOCK_ERROR * 1/100);
     Set static session parameters. Instead of dynamically establishing a session
     by joining the network, precomputed session parameters are be provided.*/
    #ifdef PROGMEM
    /* On AVR, these values are stored in flash and only copied to RAM
       once. Copy them to a temporary buffer here, LMIC_setSession will
       copy them into a buffer of its own again.*/
    uint8_t appskey[sizeof(APPSKEY)];
    uint8_t nwkskey[sizeof(NWKSKEY)];
    memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
    memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
    LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);
    #else
    // If not running an AVR with PROGMEM, just use the arrays directly 
    LMIC_setSession (0x1, DEVADDR, NWKSKEY, APPSKEY);
    #endif
    
    // Disable link check validation
    LMIC_setLinkCheckMode(0);

    // TTN uses SF9 for its RX2 window.
    LMIC.dn2Dr = DR_SF9;

   
    
    // Set data rate and transmit power (note: txpow seems to be ignored by the library)
    LMIC_setDrTxpow(DR_SF7,14);

    // Start job
    do_send(&sendjob);
}
void GPSRead()
{
  unsigned long age;
  gps.f_get_position(&flat, &flon, &age);
  falt=gps.f_altitude();  //get altitude       
  flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places 
  flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
  falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places
  int32_t lat = flat * 10000;
  int32_t lon = flon * 10000;
  int32_t alt = falt * 100;

  mydata[10] = lat >> 16;
  mydata[11] = lat >> 8;
  mydata[12] = lat;
  mydata[13] = lon >> 16;
  mydata[14] = lon >> 8;
  mydata[15] = lon;
  mydata[16] = alt >> 16;
  mydata[17] = alt >> 8;
  mydata[18] = alt;
  
}

void Tem()
{
       sensors.requestTemperatures();
       temperature = sensors.getTempCByIndex(0);    //Temperature detection
       turbidity1 = analogRead(Turbidity_dpin); //Get A0 Status
       float voltage = turbidity1 * (5.0 / 1024.0);
       turbidity = ((-1120.4*voltage*voltage)+(5742.3*voltage)-(4352.9)); 
       
      
       temp = temperature * 10;
       turb = turbidity * 10;
       mydata[2] = temp >> 8;
       mydata[3]= temp & 0xFF;
       mydata[6] = turb >> 8;
       mydata[7] = turb & 0xFF;
}

void printdata(){
       Serial.print(F("###########    "));
       Serial.print(F("NO."));
       Serial.print(count);
       Serial.println(F("    ###########"));
       count++;
       Serial.println(F("The temperautre and turbidity :"));
       Serial.print(F("["));
       Serial.print(temperature);
       Serial.print(F("℃"));
       Serial.print(F(","));
       Serial.print(turbidity);
       Serial.print(F("NTU"));
       Serial.print(F("]"));
       Serial.println(F(""));
    
       Serial.println(F("The longtitude and latitude and altitude are:"));
       Serial.print(F("["));
       Serial.print(flon);
       Serial.print(F(","));
       Serial.print(flat);
       Serial.print(F(","));
      Serial.print(falt);
       Serial.print(F("]"));
     Serial.println(F(""));
     

      

smartdelay(1000);

}
static void smartdelay(unsigned long ms)
{
  unsigned long start = millis();
  do 
  {
    while (ss.available())
    {
      gps.encode(ss.read());
    }
  } while (millis() - start < ms);
}


void loop() {
    os_runloop_once(); 
}

what are you expecting this to do?

  flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places
  flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
  falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places

You only do tests and don't use it to store in any variables and still have the comma at the end

what do you want this to really do?

  int32_t lat = flat * 10000;
  int32_t lon = flon * 10000;
  int32_t alt = falt * 100;

  mydata[10] = lat >> 16;
  mydata[11] = lat >> 8;
  mydata[12] = lat;
  mydata[13] = lon >> 16;
  mydata[14] = lon >> 8;
  mydata[15] = lon;
  mydata[16] = alt >> 16;
  mydata[17] = alt >> 8;
  mydata[18] = alt;

J-M-L:
what are you expecting this to do?

  flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places

flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
 falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places



You only do tests and don't use it to store in any variables and still have the comma at the end

what do you want this to really do?


int32_t lat = flat * 10000;
 int32_t lon = flon * 10000;
 int32_t alt = falt * 100;

mydata[10] = lat >> 16;
 mydata[11] = lat >> 8;
 mydata[12] = lat;
 mydata[13] = lon >> 16;
 mydata[14] = lon >> 8;
 mydata[15] = lon;
 mydata[16] = alt >> 16;
 mydata[17] = alt >> 8;
 mydata[18] = alt;

I am expecting this :

flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places
  flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
  falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places

to get the longitude, latitude and altitude and then I want to send my latitude, longitude and altitude to thingsnetwork server which then gets forwarded to cayenne. for example :

static uint8_t mydata[19] = {0x05,0x67,0x00,0x00,0x02,0x67,0x00,0x00,0x03,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

Here 0x05,0x67 is for channel 5, temperature and 0x00 and 0x00 is used for the temperature values. Similarly 0x02,0x67 is channel 2, temperature though I am using it to send turbidity and then 0x03,0x088 and the next 9 0x00 are for GPS coordinates. 0x67,0x88 is defined by cayenne.

This would

flon = (flon == TinyGPS::GPS_INVALID_F_ANGLE) ? 0.0 : flon; 
flat = (flat == TinyGPS::GPS_INVALID_F_ANGLE) ? 0.0 : flat;
falt = (falt == TinyGPS::GPS_INVALID_F_ANGLE) ? 0.0 : falt;

those variables will be of type float, most likely stored on 4 bytes with the standard encoding for float numbers

when you do

  int32_t lat = flat * 10000;
  int32_t lon = flon * 10000;
  int32_t alt = falt * 100;

you get indeed integers scaled by your factor (10000 or 100) - and they fit on 4 bytes too.

This code

  mydata[10] = lat >> 16;
  mydata[11] = lat >> 8;
  mydata[12] = lat;

will stick only 3 bytes into your myData array. Not sure it makes much sense if the data can be negative or does not fit in 3 bytes?

EDIT: Latitudes range from 0 to 90. Longitudes range from 0 to 180 so they should fit.

 flon = (flon == TinyGPS::GPS_INVALID_F_ANGLE) ? 0.0 : flon;
flat = (flat == TinyGPS::GPS_INVALID_F_ANGLE) ? 0.0 : flat;
falt = (falt == TinyGPS::GPS_INVALID_F_ANGLE) ? 0.0 : falt;

So I should just change this part of the code?

This the Output I get :

The temperautre and turbidity :
00:48:26.867 -> [-127.00℃,1737NTU]
00:48:26.867 -> The longtitude and latitude and altitude are:
00:48:26.935 -> [0.00,0.00,1000000.00]
00:48:27.921 -> 17358555: 17
00:48:27.921 -> Unknown event
00:48:27.921 -> Packet queued
00:48:27.955 -> LMIC.freq:868300000
00:48:27.989 -> Receive data:

I have attached a pdf, that shows the output at each and every step. If anyone could help me out regarding the gps readings.

Testscreens.pdf (1.09 MB)

Do I understand correctly that your GPS Serial is attached both to your computer and your arduino?

J-M-L:
Do I understand correctly that your GPS Serial is attached both to your computer and your arduino?

Ummm I have attached the Arduino mega at com 7 and usb-ttl at com 5.
TX pin is connected to 10 of Arduino mega and Rx of usb-ttl
Rx pin is connected to 11 of Arduino mega and tx of usb-ttl

I've had weird behavior when connecting a Serial device to two "readers"

would suggest you try without your usb-ttl and only connect the GPS to the Arduino

J-M-L:
I've had weird behavior when connecting a Serial device to two "readers"

would suggest you try without your usb-ttl and only connect the GPS to the Arduino

Actually I opened two separate Arduino ide and then opened different serial monitor. And I did that only to check what data I am getting. Regardless even if I remove the usb-ttl , The error still remains.

Whilst the Mega does support Software Serial RX on pin 10 of a Mega, you would be far better off using one of the hardware serial ports of the Mega.

In any case you code says your using pin 10 for the GPS RX input and NSS output to the LoRa device, so a direct conflict.

Which LoRa GPS shiled are you using, its possible its not Mega compatible ?

srnet:
Whilst the Mega does support Software Serial RX on pin 10 of a Mega, you would be far better off using one of the hardware serial ports of the Mega.

In any case you code says your using pin 10 for the GPS RX input and NSS output to the LoRa device, so a direct conflict.

Which LoRa GPS shiled are you using, its possible its not Mega compatible ?

I understand that but the tinygps example code works perfectly with software serial. The NSS output didn't cross my mind, will try and use different pins and see if it works.
This is module that I am using : LoRa GPS Shield

It worked! I changed the pins to 12,13 for Software serial and now it works perfectly fine. Thanks a lot

Congrats!