I have created a class that represents a NE0-6M GPS Module but if I create the TinyGPSPlus gps object and begin the SoftwareSerial in the constructor, I can not use it in any future functions
The class code:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
class NEO_6Mgps
{
private:
// byte pinRX, pinTX;
static const uint16_t GPSBaud = 9600;
public:
NEO_6Mgps(byte aPinRX,byte aPinTX)
{
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(aPinRX, aPinTX);
ss.begin(GPSBaud);
}
void GPSlocation()
{
if (ss.available() > 0)
{
gps.encode(ss.read());
if (gps.location.isUpdated())
{
Serial.print("Latitude= ");
Serial.print(gps.location.lat(), 6); // 6 = no of digits
Serial.print(" Longitude= ");
Serial.println(gps.location.lng(), 6);
}
Serial.print("Speed in m/s = ");
Serial.println(gps.speed.mps());
}
}
};
Error:
exit status 1
'ss' was not declared in this scope
I have tried using a new function Start() -that contains the TinyGPSPlus object and SoftwareSerial.begin- which is called at the start of void GPSlocation() only once, but the same problem persists.
How can I resolve this without creating a new object every time GPSlocation() is called?