Arduino determining distance between two points recorded by gps

Can comebody help me, i have a project on going and i need to, store the coordinates on point a, go to point b, then store the coordinates of point b, then determine the distance, i am very confused with other questions, also confused on what library i should use (tiny gps or tiny gps plus), the gps must work alongside the rfid scanner. when i got the code of the gps and combined it with the main code (with rfid) it just releases a value of 0.000...

#include <SPI.h> //spi bus for rfid
#include <MFRC522.h> //rfid
#include <Wire.h> //rfid
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
//includes all libraries

#define SS_PIN 10 //rfid pin 10
#define RST_PIN 9 //rfid pin 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

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

struct User {
String Name;
String UID;
int Credits;
};

User Alinus = {"Alinus", "43 C8 42 21", 100};
//Users

void setup()
{

Serial.begin(9600); // Initiate a serial communication
ss.begin(GPSBaud);
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println("Approximate your card to the reader..."); //print wait for cards
Serial.println(); //space
Serial.println(gps.location.lat(),6); //this guy returns 0 whats the problem?
Serial.println(gps.location.lng(),6);
}

thanks!

1 Like

Did you look at the examples for the library? Check this one out here

and you will see that you need to read the gps, encode it and check that it is valid before calling location.lat().

It is always best to get each part of a project working separately, before combining them.

Make sure that you are out of doors, with a clear view of the sky, when testing the GPS examples. With a new module, it can take several minutes to get the first satellite fix.

i was using the full example of tiny gps ++ to see if it has detected satellites, etc. each code was working properly, and i was outside, can somebody tell me another solution? cuz i think that the serial of rfid is interfering with the serial of gps, as they have the same baud rate?

can somebody tell me another solution?

blh64 did, in reply #1. Fix the code as indicated.

Please use code tags when posting code.

Goodyminds123:
i was using the full example of tiny gps ++ to see if it has detected satellites, etc. each code was working properly, and i was outside, can somebody tell me another solution? cuz i think that the serial of rfid is interfering with the serial of gps, as they have the same baud rate?

Very unclear what your saying here.

If 'each code was working properly' means that you had the GPS working with one of the TinyGPS plus examples, then the reason your own code does not work should be obvious by comparing the two codes.

The code you posted wont work, you appear to have made an incorrect assumption as to how the GPS library works.