I am new to arduino and getting this error while trying to working with TinyGPS++ library. I think there is some error in the arguments of the function distanceKm but don't know what it is. Any help will be appritiated. Thank you.
#include<TinyGPS++.h>
#include<SoftwareSerial.h>
TinyGPSPlus gps;
SoftwareSerial ss(4, 3);
const double STR_LAT = 48.85826; // moved all const's and variable here
const double STR_LNG = 2.294516;
int lap = 0;
float latt;
float lan;
float spd;
float alt;
double distanceKm;
void setup()
{
Serial.begin(115200);
ss.begin(4800);
}
void loop()
{
while (ss.available() > 0) { // <<< missing an open brace { here
gps.encode(ss.read());
if (gps.altitude.isUpdated())
{
if (gps.altitude.isValid())
{
alt = (gps.altitude.meters());
Serial.println(alt);
}
}
if (gps.location.isUpdated())
{
if (gps.location.isValid())
{
Serial.print("LAT=");
latt = (gps.location.lat(), 6);
Serial.println(latt);
Serial.print("LNG=");
lan = (gps.location.lng(), 6);
Serial.println(lan);
}
}
if ((latt == STR_LAT ) && (lan = STR_LNG))
lap = lap + 1;
if (gps.speed.isUpdated())
{
if (gps.speed.isValid())
{
spd = gps.speed.kmph();
Serial.println(spd);
}
}
distanceKm = (TinyGPSPlus.distanceBetween(gps.location.lat(), gps.location.lng(), STR_LAT, STR_LNG)) / 1000.0;
}// <<< closing brace } for the while
}
What are you doing with distanceKm besides calculating it?
I don't have all the library's so I can't speak as to any formatting/usage problem there might be with distanceKm.
Maybe it should be float instead of double?
'TinyGPSPlus' is an object CLASS, not an object INSTANCE. You are trying to call a CLASS STATIC function (one belonging to the class and not any particular instance) so the syntax is: