# GPS Programming

**URL:** <https://forum.arduino.cc/t/gps-programming/434169>\
**Category:** Programming\
**Created:** [January 29, 2017, 8:31am UTC](https://forum.arduino.cc/t/gps-programming/434169 "2017-01-29T08:31:38Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![Rezapazoki777](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Rezapazoki777](https://forum.arduino.cc/u/Rezapazoki777)\
**Post date:** [May 1, 2018, 12:26pm UTC](https://forum.arduino.cc/t/gps-programming/434169/21 "2018-05-01T12:26:53Z")

</div>

i use arduino uno and i don't understand what do you mean "application" . i only open arduino IDE and after that Tools and opening Serial monitor,when i open Serial monitor it sends the coordinates and it works until i change the battery that is really ridiculous my american friend 🙂 🙂

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 1, 2018, 12:55pm UTC](https://forum.arduino.cc/t/gps-programming/434169/22 "2018-05-01T12:55:32Z")

</div>

I really don't understand what you are trying to do, with that code.

In loop(), you are reading data from the GPS, in the while loop. In that same loop, you are determining whether serial data has arrived.

Why? Those are COMPLETELY independent sources of data.

Re-write loop(). If should call three functions:

```cpp
void loop()
{
  collectGPSData();
  collectGSMData();
  if(tracking)
      sendGPSData();
}

```

NONE of those functions should use serialEvent(). That crutch is NOT necessary.

If you write your code like this, it will be IMPOSSIBLE to mix the reading of data from the GPS and from the GSM.

I don't see why the GSM would ever send you anything unsolicited, but that, or some input that you provide when you open the Serial Monitor app (that you have not disclosed), is all that will ever cause stringComplete to be true.

Until stringComplete is true, no calls to Serial.print() are ever made.

I also do not understand expecting a text message containing "@light on#" to be the trigger for sending GPS data. Now, "@Just shoot me#" maybe...

---

<div class="post-metadata">

**Author:** ![Rezapazoki777](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Rezapazoki777](https://forum.arduino.cc/u/Rezapazoki777)\
**Post date:** [May 7, 2018, 2:03pm UTC](https://forum.arduino.cc/t/gps-programming/434169/23 "2018-05-07T14:03:48Z")

</div>

Hello paul.  
after you wrote that message for me i felt really bad but i write a simple car tracker program but like the past the code has a problem,the problem is that after i upload the code it return 0.000000,i know that is because using two modules at same time .Serial.print() in code is for myself to watch the latitude and longitude in serial monitor

please help me,i gonna crazy gradually.  
if you have a code could you give that to me please  
my gps module is ublox m8n and arduino is nano.

[ssrt.ino](https://forum.arduino.cc/uploads/short-url/17lK2rB8IXUHsTHN13dBOccayzh.ino) (1.34 KB)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 7, 2018, 2:27pm UTC](https://forum.arduino.cc/t/gps-programming/434169/24 "2018-05-07T14:27:23Z")

</div>

You seem to have missed, or misunderstood, the part about only one instance of SoftwareSerial being able to listen at a time.

You spend most of your time listening to the GSM. If it sends a reply containing "@Track#", you listen to the GPS. For how long? A few dozen nanoseconds. If no data comes in from the GPS in that time, you assume that it did, and do something foolish.

Then, you go back to listening to the GSM.

You absolutely MUST get a Mega or other model with multiple hardware serial ports AND you MUST separate reading GSM data from sending GPS data.

To me, "Track" implies continuously getting GPS data and sending that data. "Find" implies that you want to know where the device is right now (or where it was the last time that it knew).

---

<div class="post-metadata">

**Author:** ![Rezapazoki777](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Rezapazoki777](https://forum.arduino.cc/u/Rezapazoki777)\
**Post date:** [May 7, 2018, 6:57pm UTC](https://forum.arduino.cc/t/gps-programming/434169/25 "2018-05-07T18:57:49Z")

</div>

Thank you paul but i am new in arduino coding and i don't know how to prolong interfacing time with gps module to get coordinates. 😕  
Do you have any suggestion ?  
Another problem is that arduino mega is too big and also expensive to use in car tracker .  
Could you please change my code in that section(getting gps coordinates) ?  
I need a book to read all functions and libraries in arduino do you have any suggestion ?  
Thank you bro

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 8, 2018, 9:11am UTC](https://forum.arduino.cc/t/gps-programming/434169/26 "2018-05-08T09:11:49Z")

</div>

> i don't know how to prolong interfacing time with gps module to get coordinates.

You could put a in a while loop to wait for the GPS to wake up and supply data, until you got a complete NMEA sentence of the correct type.

But, that is still only going to get you ONE point before you go back to listening to the GSM.

> Another problem is that arduino mega is too big and also expensive to use in car tracker .

Bullshit. If you expect to be able to track your car after it is stolen, saving 50 cents on the Arduino is foolish. If the size of an official Mega is a problem, there are Mega clones that are the SAME size as a UNO.

> Could you please change my code in that section(getting gps coordinates) ?

When you get the right hardware, yes. Until then, NO, YOU CAN NOT ACHIEVE YOUR GOALS!

---

<div class="post-metadata">

**Author:** ![Rezapazoki777](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@Rezapazoki777](https://forum.arduino.cc/u/Rezapazoki777)\
**Post date:** [May 11, 2018, 1:31pm UTC](https://forum.arduino.cc/t/gps-programming/434169/27 "2018-05-11T13:31:07Z")

</div>

Hello paul my american bro.this is me again  
i started a car tracker project without gps module.i want to do it only with gsm module sim800l and arduino nano.  
i have a little problem, i want to save this AT command response in string variable (AT + CIPGSMLOC = 1,1) and send it with gsm module but gsm module send me this :

AT + SAPBR = 3,1,"Contype","GPRS"

ok

AT + SAPBR = 3,1,"APN","CMNET"

17:45(this is the time when i wrote the code)

please help me like always 🙂 🙂

[gsm\_car\_tracker.ino](https://forum.arduino.cc/uploads/short-url/r2Hudi8h3IUxG2UYuZ8htaCJaXv.ino) (1.16 KB)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 10:18pm UTC](https://forum.arduino.cc/t/gps-programming/434169/28 "2021-05-05T22:18:31Z")

</div>

Closed on May 5, 2021, 10:18pm UTC



[Previous page](https://forum.arduino.cc/t/gps-programming/434169.md?page=1)
