Gps module on Arduino

  • Am working with ardunio and neo-6m…i went to compare current location with new location if ther change it send sms but the my code is not read the new locatin…wht can i do

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
double slong = 7.4;
double slat = 38.6;
static const int rx = 9, tx = 8;
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial ss(rx, tx);

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
ss.begin(GPSBaud);
}

void loop() {
// put your main code here, to run repeatedly:
while (ss.available() > 0){
gps.encode(ss.read());

if (gps.location.isUpdated()){
double newlong = gps.location.lat();
double newlat = gps.location.lng();
if( (slong = newlong )&& (slat = newlat)){
Serial.println("in school ");
Serial.print("latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print("longtuide= ");
Serial.print(gps.location.lng(), 6);
Serial.println(“HELLO”);
}else{
Serial.println(“out side school”);
Serial.print("latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print("longtuide= ");
Serial.print(gps.location.lng(), 6);

}
delay(1000);
}
}
}

.wht can i do

Start by posting your code and use code tags when you do

I did not get the new reading it read as 0

UKHeliBob: Start by posting your code and use code tags when you do

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
double slong = 7.4;
double slat = 38.6;
static const int rx = 9, tx = 8;
static const uint32_t GPSBaud = 9600;
TinyGPSPlus gps;
SoftwareSerial ss(rx, tx);

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
ss.begin(GPSBaud);
}

void loop() {
// put your main code here, to run repeatedly:
while (ss.available() > 0){
gps.encode(ss.read());

if (gps.location.isUpdated()){
double newlong = gps.location.lat();
double newlat = gps.location.lng();
if( (slong = newlong )&& (slat = newlat)){
Serial.println("in school ");
Serial.print("latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print("longtuide= ");
Serial.print(gps.location.lng(), 6);
Serial.println(“HELLO”);
}else{
Serial.println(“out side school”);
Serial.print("latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print("longtuide= ");
Serial.print(gps.location.lng(), 6);

}
delay(1000);
}
}
}
[/quote]

UKHeliBob:

      double newlong = gps.location.lat();
      double newlat = gps.location.lng();
      if ( (slong = newlong ) &&  (slat = newlat))

Some obvious problems.

Firstly you seem to have mixed up latitude and longitude. Then there is the problem whereby you have used = instead of == for comparison. Then there is the problem whereby you are trying to compare float values which is not going to work because, for instance, 7.4 is never going to exactly equal say 7.41234

Write a simple sketch that tries to detect a position update and prints the lat/long values before and after the move