# GPS Tracker Creation

**URL:** <https://forum.core-electronics.com.au/t/gps-tracker-creation/3312>\
**Category:** Uncategorized\
**Created:** [28 August 2018 05:18 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312 "2018-08-28T05:18:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [28 August 2018 05:18 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/1 "2018-08-28T05:18:16Z")

</div>

hi i have followed the diagram from this tutorial [https://core-electronics.com.au/tutorials/how-to-use-gps-with-arduino.html](https://core-electronics.com.au/tutorials/how-to-use-gps-with-arduino.html) however i get an error about myserial was not declared in this scope any ideas please  
i am using the code provided in the tutorial

Can someone advise what value i need to add in the merserial and where do i find said value

---

<div class="post-metadata">

**Author:** ![Aidan](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/aidan/32/1243_2.png) [@Aidan](https://forum.core-electronics.com.au/u/Aidan)\
**Post date:** [28 August 2018 05:45 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/2 "2018-08-28T05:45:41Z")

</div>

Hey Claude,  
That sample code didn’t specifically declare any object called myserial. You’ll just need to do it in the step before that reads:  
SoftwareSerial OurGPSModule(RxPin, TxPin);

For example:  
SoftwareSerial mySerial(3, 2);

Let us know if that gets you through it.

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [28 August 2018 06:18 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/3 "2018-08-28T06:18:33Z")

</div>

Hi

In the tutorial it clearly shows that line as per screen shot

 ![](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/a/ad6c62c47cbba0d113a13b4a2d8f294e503bf428.png)

When I comment that line out I then get the following error further down the code

Serial does not have a name type

Below is the full sketch I am using

```
#include <Adafruit_GPS.h>

#include <SofwareSerial.h>

SoftwareSerial OurGPSModule(2, 3);

// Adafruit_GPS GPS(&mySerial)

Serial.begin(115200); //This baud rate will help a lot in printing all of the data that comes from the GPS Module to the serial monitor

GPS.begin(9600);

GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); //Sets output to only RMC and GGA sentences

GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); //Sets the output to 1/second. If you want you can go higher/lower

GPS.sendCommand(PGCMD_ANTENNA); //Can report if antenna is connected or not

GPS.parse(GPS.lastNMEA()); //This is going to parse the last NMEA sentence the Arduino has received, breaking it down into its constituent parts.

GPS.newNMEAreceived(); //This will return a boolean TRUE/FALSE depending on the case.

Serial.print("\nTime: ");

    Serial.print(GPS.hour, DEC); Serial.print(':');

    Serial.print(GPS.minute, DEC); Serial.print(':');

    Serial.print(GPS.seconds, DEC); Serial.print('.');

    Serial.println(GPS.milliseconds);

    Serial.print("Date: ");

    Serial.print(GPS.day, DEC); Serial.print('/');

    Serial.print(GPS.month, DEC); Serial.print("/20");

    Serial.println(GPS.year, DEC);

    Serial.print("Fix: "); Serial.print((int)GPS.fix);

    Serial.print(" quality: "); Serial.println((int)GPS.fixquality);

    if (GPS.fix) {

      Serial.print("Location: ");

      Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);

      Serial.print(", ");

      Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);

      Serial.print("Location (in degrees, works with Google Maps): ");

      Serial.print(GPS.latitudeDegrees, 4);

      Serial.print(", ");

      Serial.println(GPS.longitudeDegrees, 4);

      Serial.print("Speed (knots): "); Serial.println(GPS.speed);

      Serial.print("Angle: "); Serial.println(GPS.angle);

      Serial.print("Altitude: "); Serial.println(GPS.altitude);

      Serial.print("Satellites: "); Serial.println((int)GPS.satellites);

```

Regards

Claude

---

<div class="post-metadata">

**Author:** ![Graham](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/graham/32/54_2.png) [@Graham](https://forum.core-electronics.com.au/u/Graham)\
**Post date:** [28 August 2018 06:52 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/4 "2018-08-28T06:52:11Z")

</div>

Heyo,

Did you include the Adafruit library?

- **Adafruit GPS library** - Open up your Arduino IDE and head to your Sketch \> Include Library \> Manage Libraries window. Search for GPS and select the option, “Adafruit GPS Library”.

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [28 August 2018 06:56 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/5 "2018-08-28T06:56:01Z")

</div>

Also i am using the following for my gps hardware

 ![image1.jpeg](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/8/85a451ae41d23ec72418c8c0eb57e00c8f52792c.jpeg)

The hardware in the tutorial is the ultimate gps module and from the images i do not see the gps chip set just the aerial ???

Claude Raiola

0414 228 948

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [28 August 2018 07:15 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/6 "2018-08-28T07:15:52Z")

</div>

Yes

Claude Raiola

0414 228 948

---

<div class="post-metadata">

**Author:** ![Aidan](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/aidan/32/1243_2.png) [@Aidan](https://forum.core-electronics.com.au/u/Aidan)\
**Post date:** [28 August 2018 23:00 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/7 "2018-08-28T23:00:44Z")

</div>

Hey Claude,  
The name of the Software Serial Object you set up needs to match the one you are calling in the GPS line

```
SoftwareSerial mySerial(2, 3);
Adafruit_GPS GPS(&mySerial);
```

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [28 August 2018 23:43 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/8 "2018-08-28T23:43:17Z")

</div>

Sorry i do not understand

I transposed the tx,rx values to 2,3 to reflect the connection ports on the arduino board

And the this line

> ```auto
> GPS(&amp;mySerial);
> 
> ```

Is used as shown in the instructions of the tutorial

May be the tutorial needs to give more detail as clearly i cannot get it working from following it

Claude Raiola

0414 228 948

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [29 August 2018 01:54 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/9 "2018-08-29T01:54:06Z")

</div>

Hi Aidan

PROGESS

I have sorted the code as per your last email

SoftwareSerial mySerial(2, 3);

Adafruit\_GPS GPS(&mySerial);

My next compile error is

Serial does not have a name

And it relates to

```
Serial.print(" quality: "); Serial.println((int)GPS.fixquality);

```

You assistance is much appreciated

Regards

Claude Raiola

0414 228 948

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [29 August 2018 01:55 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/10 "2018-08-29T01:55:24Z")

</div>

Hi Again

Sorry the error message is

Serial does not name a type

Relating to

```
Serial.print(" quality: "); Serial.println((int)GPS.fixquality);

```

Regards

Claude Raiola

0414 228 948

---

<div class="post-metadata">

**Author:** ![Clinton](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/clinton/32/1515_2.png) [@Clinton](https://forum.core-electronics.com.au/u/Clinton)\
**Post date:** [31 August 2018 05:57 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/11 "2018-08-31T05:57:32Z")

</div>

Hi Claude,

I can’t see a problem with that specific line are you able to post the line previous as well.

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [3 September 2018 03:09 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/12 "2018-09-03T03:09:29Z")

</div>

Here is the full code i am using

#include \<Adafruit\_GPS.h\>  
#include \<SofwareSerial.h\>  
SoftwareSerial mySerial(2, 3);  
Adafruit\_GPS GPS(&mySerial);  
Serial.begin(115200); //This baud rate will help a lot in printing all of the data that comes from the GPS Module to the serial monitor  
GPS.begin(9600);  
GPS.sendCommand(PMTK\_SET\_NMEA\_OUTPUT\_RMCGGA); //Sets output to only RMC and GGA sentences  
GPS.sendCommand(PMTK\_SET\_NMEA\_UPDATE\_1HZ); //Sets the output to 1/second. If you want you can go higher/lower  
GPS.sendCommand(PGCMD\_ANTENNA); //Can report if antenna is connected or not  
GPS.parse(GPS.lastNMEA()); //This is going to parse the last NMEA sentence the Arduino has received, breaking it down into its constituent parts.  
GPS.newNMEAreceived(); //This will return a boolean TRUE/FALSE depending on the case.  
Serial.print("\nTime: ");  
Serial.print(GPS.hour, DEC); Serial.print(’:’);  
Serial.print(GPS.minute, DEC); Serial.print(’:’);  
Serial.print(GPS.seconds, DEC); Serial.print(’.’);  
Serial.println(GPS.milliseconds);  
Serial.print(“Date: “);  
Serial.print(GPS.day, DEC); Serial.print(’/’);  
Serial.print(GPS.month, DEC); Serial.print(”/20”);  
Serial.println(GPS.year, DEC);  
Serial.print("Fix: “); Serial.print((int)GPS.fix);  
Serial.print(” quality: "); Serial.println((int)GPS.fixquality);  
if (GPS.fix) {  
Serial.print("Location: “);  
Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);  
Serial.print(”, ");  
Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);  
Serial.print("Location (in degrees, works with Google Maps): “);  
Serial.print(GPS.latitudeDegrees, 4);  
Serial.print(”, ");  
Serial.println(GPS.longitudeDegrees, 4);  
Serial.print("Speed (knots): "); Serial.println(GPS.speed);  
Serial.print("Angle: "); Serial.println(GPS.angle);  
Serial.print("Altitude: "); Serial.println(GPS.altitude);  
Serial.print("Satellites: "); Serial.println((int)GPS.satellites);

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [3 September 2018 04:24 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/13 "2018-09-03T04:24:13Z")

</div>

i have just tried another sketch as per below and it generates a serial2 error

i am spending days search the web trying supposed solutions and none of them work each having one error on another its totally frustrating when i am following the steps exactly

I want to be able to store geo fence co ordinates on the arduino so that as the unit detects entering one of the geo fences then the unit alerts via light flash or sound

sadly despite my tenacity i am getting no where fast

the sketch is as follows

#include \<Arduino.h\>  
#include “NMEAGPS.h”

NMEAGPS gps;  
gps\_fix fix; // the current GPS fix  
HardwareSerial & gps\_port = Serial2; // an alias

NeoGPS::Location\_t home( 254139360L, 682662360L ); // degrees \* 10,000,000  
const float thresholdDistance = 1.00; //km  
uint8\_t gpsSeconds; // for counting elapsed time instead of using delay

void setup()  
{  
Serial.begin(9600);  
Serial.println(“Hello!”);

gps\_port.begin(9600);

} // setup

void loop()  
{  
while (gps.available( gps\_port )) {  
fix = gps.read(); // save the latest

```
// Instead of delay, count the number of GPS fixes
gpsSeconds++;
if (gpsSeconds >= 3) {
  gpsSeconds = 0;

  displayInfo();
  checkDist();
}

```

}  
} // loop

void displayInfo()  
{  
Serial.print("Position: ");

if (fix.valid.location) {  
Serial.print("lat: “); Serial.print(fix.latitude(), 6); Serial.print(” ");// print latitude  
Serial.print("lon: "); Serial.println(fix.longitude(), 6); // print longitude  
} else  
Serial.println( ‘?’ );

} //end displayInfo()

void checkDist()  
{  
if (fix.valid.location) {  
float dist = fix.location.DistanceKm( home );

```
if (dist >= thresholdDistance )
{
  Serial.print("Subject is ");
  Serial.print(dist - thresholdDistance, 6);
  Serial.println("KM beyond threshold");
}
else
{
  Serial.println("Subject within threshold, no worries!");
}

```

}  
}

---

<div class="post-metadata">

**Author:** ![Aidan](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/aidan/32/1243_2.png) [@Aidan](https://forum.core-electronics.com.au/u/Aidan)\
**Post date:** [3 September 2018 05:08 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/14 "2018-09-03T05:08:08Z")

</div>

Hey Claude,  
It turns out there have been some updates to the IDE, and the SoftwareSerial command is now inbuilt. I’ve made the changes required to that tutorial and posted them. Bear in mind this tutorial assumes that you have correctly installed the Adafruit GPS Library and simply shows you how you can read GPS data from the Adafruit Ultimate GPS Module.

Moving forward, can you try the code again (in a new sketch) and see if it compiles and runs (by opening the Serial Monitor @ 115200 Baud).

You should see data being written out that looks like this:

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/3/37651f9a08468176d448d6bc85e7c83c56dc2596.png)

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [3 September 2018 06:05 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/15 "2018-09-03T06:05:01Z")

</div>

Hi Aiden

\Well the good news is that it works and i am getting the same output as you have indicated so thats progress indeed

HOWEVER i am now sitting outside to open sky and when i run the process i still recieve the same output without any gps fix / quality or date / time from gps

given we have jumped over hurdle one can you direct me where i can learn why i am not getting gps data given i am outside

---

<div class="post-metadata">

**Author:** ![Graham](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/graham/32/54_2.png) [@Graham](https://forum.core-electronics.com.au/u/Graham)\
**Post date:** [3 September 2018 06:07 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/16 "2018-09-03T06:07:21Z")

</div>

That sounds normal - A cold start can take a few minutes to get a lock

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [3 September 2018 06:23 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/17 "2018-09-03T06:23:00Z")

</div>

Photo of hardware used

 ![image1.jpeg](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/7/7fcc7cfaf4db414bfac5fa32465427c9fbbffcea.jpeg)

Claude Raiola

0414 228 948

---

<div class="post-metadata">

**Author:** ![Aidan](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/aidan/32/1243_2.png) [@Aidan](https://forum.core-electronics.com.au/u/Aidan)\
**Post date:** [3 September 2018 23:00 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/18 "2018-09-03T23:00:06Z")

</div>

Hey Claude,  
That’s good to hear. Take a look at [this tutorial](http://core-electronics.com.au/tutorials/sensors/how-GPS-works.html) for more information about GPS and it’s operation. I’d specifically note the Cold/Warm/Hot start section toward the bottom.

---

<div class="post-metadata">

**Author:** ![claude69103](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@claude69103](https://forum.core-electronics.com.au/u/claude69103)\
**Post date:** [4 September 2018 00:03 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/19 "2018-09-04T00:03:45Z")

</div>

Thanks

Ok will do

I am wanting to store at least 100 records of geofence co ordinates for my project without having to go to the next step of adding an sd card to the project

Do you think the memory of the arduino uno will be able to hold that data as well as the program code ??

I need the geofences to be checked if they have been entered every 3-4 seconds

Thanks in advance

Claude Raiola

0414 228 948

---

<div class="post-metadata">

**Author:** ![Graham](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/graham/32/54_2.png) [@Graham](https://forum.core-electronics.com.au/u/Graham)\
**Post date:** [4 September 2018 03:44 UTC](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312/20 "2018-09-04T03:44:15Z")

</div>

Hi Claude,

If the area is a rectangle, you only need 8 floating point numbers (32-bit values) to build that logic, along with inclusion of some floating point math. It’s very possible to do with an Arduino.

With that said, you’ll quickly hit the RAM limits on the ATmega328 if the project becomes more complicated. If that happens, it would be best to consider other hardware with more elbow room such as the Particle Photon or some newer Arduino.

[Next page](https://forum.core-electronics.com.au/t/gps-tracker-creation/3312.md?page=2)
