Hi there,
I am currently working on creating a cage for Arduino installed in drone using neo 6m GPS module. The problem statement is such that, upon pressing the push button, the current location should be saved and from there around a 50mts cage should be created. I have tried with the following code and I'm getting the error as mentioned below. Can anyone suggest me if there is any alternative to do it?
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
// The TinyGPS++ object
TinyGPSPlus gps;
String fix; // the current GPS fix
const int PUSH_BUTTON = 2;
int buzzer = 12;
long a;
int status;
static const int RXPin = 4, TXPin = 3; //gps module connections
static const uint32_t GPSBaud = 9600;
float lat, lng;
float homeLat = 12.334455;
float homeLon = 05.112233;
#define Radius 0.0005 // Buzzer alert Radius = 50 m
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup(){
pinMode(PUSH_BUTTON, INPUT_PULLUP); //push button input
pinMode(buzzer,OUTPUT);//initialize the buzzer pin as an output
Serial.begin(9600);
ss.begin(GPSBaud);
}
void loop(){
unsigned char i;
while (ss.available() > 0){
gps.encode(ss.read());
if (gps.location.isUpdated()){
Serial.print("Latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print(" Longitude= ");
Serial.println(gps.location.lng(), 6);
}
status = digitalRead(PUSH_BUTTON);
if (status== HIGH){
fix = gps.read(); // save the latest
}
if (fix.valid.location) {
float dist = fix.location.DistanceKm( home );
if (dist >= Radius ){
for(i=0;i<80;i++)
{
digitalWrite(buzzer, HIGH);
}
}
else{
digitalWrite(buzzer, LOW);
}
}
delay(1000);
}
and the error is:
exit status 1
'class TinyGPSPlus' has no member named 'read'
Any lead/suggestion is much appreciated. Thank you!!